找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
广告投放联系QQ68610888
楼主: phrnet

【0428更新】【支持OP潘多拉毛子】Dns智能解析、去广告dnsmasq脚本!!!!!稳定发布

 火... [复制链接]
发表于 2016-4-19 21:26 来自手机 | 显示全部楼层
我就想问问 利用dns能去掉多少广告?误伤的也不少吧
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2016-4-19 21:49 | 显示全部楼层
这个好东西啊。8M的flash能用不?
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

 楼主| 发表于 2016-4-20 00:05 | 显示全部楼层
修复了啊!
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2016-4-20 08:47 来自手机 | 显示全部楼层
phrnet 发表于 2016-4-9 17:25
脚本只支持毛之 其他配置文件支持linux 剩下自己折腾写个脚本  有意见别玩。。

意见都不给有,撸主肝火旺盛啊
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2016-4-20 10:22 | 显示全部楼层
要是能跟hiboy合作让他集成你这个就更好了
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2016-4-20 10:45 | 显示全部楼层
真的好用,谢谢您的贡献。
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2016-4-20 11:16 | 显示全部楼层
Jerry1984 发表于 2016-4-20 10:22
要是能跟hiboy合作让他集成你这个就更好了

期待合作完善固件
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2016-4-20 11:21 | 显示全部楼层
  1. [root@Pandora:/etc/storage]#./QAD.sh
  2. ./QAD.sh: line 3: nvram: not found
  3. ifconfig: br0: error fetching interface information: Device not found
  4. ./QAD.sh: line 5: /bin/iptables: not found
  5. ./QAD.sh: line 6: /bin/iptables: not found
  6. ./QAD.sh: line 7: /bin/iptables-save: not found
  7. wget: not an http or ftp url: https://c.cn-clouds.com/GL/openwrt/dnsmasq/resolv.conf
  8. wget: not an http or ftp url: https://c.cn-clouds.com/GL/openwrt/dnsmasq/ruigeek.conf
  9. wget: not an http or ftp url: https://c.cn-clouds.com/GL/openwrt/dnsmasq/dnsmasq.servers
  10. ./QAD.sh: line 35: /sbin/restart_dhcpd: not found
  11. wget: not an http or ftp url: https://c.cn-clouds.com/GL/openwrt/sh/update/phrnet_autoupdate.sh
  12. ./QAD.sh: line 38: /usr/bin/dos2unix: not found
  13. ./QAD.sh: line 40: can't create /etc/storage/cron/crontabs/: Is a directory
复制代码
潘多拉小米mini固件执行后提示这样的错,谁知道怎么解决帮忙一下
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2016-4-20 12:01 | 显示全部楼层
好的,有空试试
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2016-4-21 09:25 | 显示全部楼层
本帖最后由 lukme 于 2016-4-23 00:56 编辑

我又搞了个新脚本,整合并去除重复广告规则,用了几天没出问题~

注意:因为下载的广告规则文件稍大,这类脚本最好只用一个,不然可能会造成内存空间不足的问题。

注意:如果遇到重启路由清空脚本问题,请用 路由管理界面 > 系统管理 > 恢复/导出/上传设置 > 提交现在的NVRAM内容到闪存 和 提交现在的内部存储到闪存 功能。

  1. #!/bin/sh
  2. ###该脚本只需要运行一次###
  3. ###该脚本只需要运行一次###
  4. ###该脚本只需要运行一次###

  5. # 移动到用户命令文件夹
  6. cd /usr/bin/

  7. # 创建广告规则与更新脚本存放的文件夹
  8. mkdir -p /etc/storage/dnsmasq/adblocks

  9. # dnsmasq.conf 添加广告规则路径
  10. cat >> /etc/storage/dnsmasq/dnsmasq.conf <<EOF
  11. addn-hosts=/etc/storage/dnsmasq/adblock/malwaredomainlist.conf
  12. addn-hosts=/etc/storage/dnsmasq/adblock/noad.conf
  13. EOF

  14. # 下载广告缓存(sed命令: 保留127开头>删除含"iqiyi | .jd.com | .taobao.com | 5173.com | www.hao123.com | localhost | # |"内容的规则)
  15. wget --no-check-certificate -tries=5 -qO - https://raw.githubusercontent.com/vokins/simpleu/master/hosts | sed -n '/127/p' | sed '/www.hao123.com/d' | sed '/localhost/d' | sed '/#/d' | sed '/.5173.com/d' | sed '/.taobao.com/d' | sed '/.jd.com/d' | sed '/iqiyi/d' > /etc/storage/dnsmasq/adblock/simpleu
  16. wget --no-check-certificate -tries=5 -qO - http://www.malwaredomainlist.com/hostslist/hosts.txt | sed -n '/127/p' | sed '/localhost/d' > /etc/storage/dnsmasq/adblock/malwaredomainlist.conf
  17. wget --no-check-certificate -tries=5 -qO - https://raw.githubusercontent.com/vokins/yhosts/master/hosts | sed '/iqiyi/d' > /etc/storage/dnsmasq/adblock/yhosts
  18. # 合并广告规则缓存
  19. cat /etc/storage/dnsmasq/adblock/simpleu /etc/storage/dnsmasq/adblock/yhosts > /etc/storage/dnsmasq/adblock/noad
  20. # 删除下载缓存
  21. rm /etc/storage/dnsmasq/adblock/simpleu
  22. rm /etc/storage/dnsmasq/adblock/yhosts
  23. # 删除重复规则
  24. cd /usr/bin/ | sort /etc/storage/dnsmasq/adblock/noad | uniq > /etc/storage/dnsmasq/adblock/noad.conf
  25. # 删除缓存文件
  26. rm /etc/storage/dnsmasq/adblock/noad
  27. # 重启dnsmasq服务
  28. restart_dhcpd

  29. # 创建广告规则更新脚本
  30. cat > /etc/storage/dnsmasq/adblock/noad_update.sh <<EOF
  31. #!/bin/sh
  32. # 移动到用户命令文件夹
  33. cd /usr/bin/
  34. # 下载广告缓存(sed命令: 保留127开头>删除含"iqiyi | .jd.com | .taobao.com | 5173.com | www.hao123.com | localhost | # |"内容的规则)
  35. wget --no-check-certificate -tries=5 -qO - https://raw.githubusercontent.com/vokins/simpleu/master/hosts | sed -n '/127/p' | sed '/www.hao123.com/d' | sed '/localhost/d' | sed '/#/d' | sed '/.5173.com/d' | sed '/.taobao.com/d' | sed '/.jd.com/d' | sed '/iqiyi/d' > /etc/storage/dnsmasq/adblock/simpleu
  36. wget --no-check-certificate -tries=5 -qO - http://www.malwaredomainlist.com/hostslist/hosts.txt | sed -n '/127/p' | sed '/localhost/d' > /etc/storage/dnsmasq/adblock/malwaredomainlist.conf
  37. wget --no-check-certificate -tries=5 -qO - https://raw.githubusercontent.com/vokins/yhosts/master/hosts | sed '/iqiyi/d' > /etc/storage/dnsmasq/adblock/yhosts
  38. # 合并simpleu与yhosts下载缓存
  39. cat /etc/storage/dnsmasq/adblock/simpleu /etc/storage/dnsmasq/adblock/yhosts > /etc/storage/dnsmasq/adblock/noad
  40. # 删除下载缓存
  41. rm /etc/storage/dnsmasq/adblock/simpleu
  42. rm /etc/storage/dnsmasq/adblock/yhosts
  43. # 删除重复规则
  44. sort /etc/storage/dnsmasq/adblock/noad | uniq > /etc/storage/dnsmasq/adblock/noad.conf
  45. # 删除合并缓存
  46. rm /etc/storage/dnsmasq/adblock/noad
  47. # 重启dnsmasq服务
  48. restart_dhcpd
  49. EOF

  50. # 注入8小时更新任务
  51. http_username=`nvram get http_username`
  52. cat >> /etc/storage/cron/crontabs/$http_username <<EOF
  53. 8 */8 * * * /bin/sh /etc/storage/dnsmasq/adblock/noad_update.sh
  54. EOF

复制代码


我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2016-4-21 10:00 | 显示全部楼层
本帖最后由 lukme 于 2016-5-11 18:24 编辑

                                                         openwrt与潘多拉类固件的dnsmasq去广告+自动更新脚本

如果有问题还需要你的反馈。

反馈:
路由型号
路由固件
脚本运行记录

广告反馈:
                 QQ群:AD hosts爱好群
                 yhosts项目提交: https://github.com/vokins/yhosts/issues


PS:如果以前运行过类似脚本或命令,最好恢复出厂设置。
PS:因为有的固件携带的wget命令不支持https下载,需要重装wget或者使用http脚本。

20160511   adblock批量替换成adblocks,手残党

20160430   http-50K脚本下载广告规则文件命名错误,已修正。

20160428   修改上游DNS查询方式为并发查询
                   帖子底部更新4合1去广告脚本,可选以下脚本使用:
                   HTTPS——192.168.2.1  (广告规则250K)
                   HTTPS——192.168.1.1  (广告规则250K)

                   HTTP——192.168.2.1    (广告规则60K)
                   HTTP——192.168.1.1    (广告规则60K)

                  

20160426   个人理解出错,需要将潘多拉lan网关IP设为默认DNS才能按规则去广告。
                    添加上游DNS设置
                   设置监听地址为:192.168.1.1和127.0.0.1(lan网关ip不是192.168.1.1请自行编辑脚本内容)

20160423  定时更新脚本搞错了,已修改。

20160422  修改版脚本,命令与路径已确认,帖子底部还有手动还原方法。

使用该脚本需要将dns设置为潘多拉lan网关(如192.168.1.1 ; 192.168.0.1)
http://moper.me/pandorabox-dreambox-openwrt-dhcp-set-dns.html

  1. #!/bin/sh
  2. ###仅限潘多拉与openwrt类固件使用###
  3. ###仅限潘多拉与openwrt类固件使用###

  4. ###请将DNS设置为lan网关###
  5. ###请将DNS设置为lan网关###

  6. ###该脚本只需要运行一次###
  7. ###该脚本只需要运行一次###

  8. # 移动到用户命令文件夹
  9. cd /usr/bin/

  10. # 创建广告规则与更新脚本存放的文件夹
  11. mkdir -p /etc/dnsmasq/adblocks

  12. # dnsmasq.conf 添加广告规则路径
  13. cat >> /etc/dnsmasq.conf <<EOF
  14. # 并发查询所有上游DNS
  15. all-servers
  16. # 按顺序查询上游DNS
  17. # strict-order
  18. # 添加监听地址(将192.168.1.1修改为你的lan网关ip)
  19. listen-address=192.168.1.1,127.0.0.1
  20. # 添加上游DNS服务器
  21. resolv-file=/etc/dnsmasq/resolv.conf
  22. # 添加广告规则路径
  23. addn-hosts=/etc/dnsmasq/adblocks/malwaredomainlist.conf
  24. addn-hosts=/etc/dnsmasq/adblocks/noad.conf
  25. EOF

  26. # 创建上游DNS配置文件
  27. cat > /etc/dnsmasq/resolv.con <<EOF
  28. nameserver 127.0.0.1
  29. nameserver 114.114.114.119
  30. nameserver 223.5.5.5
  31. nameserver 119.29.29.29
  32. EOF

  33. # 下载广告缓存(sed命令: 保留127开头>删除含"iqiyi | .jd.com | .taobao.com | 5173.com | www.hao123.com | localhost | # |"内容的规则)
  34. wget --no-check-certificate -qO - http://raw.githubusercontent.com/vokins/simpleu/master/hosts | sed -n '/127/p' | sed '/www.hao123.com/d' | sed '/localhost/d' | sed '/#/d' | sed '/.5173.com/d' | sed '/.taobao.com/d' | sed '/.jd.com/d' | sed '/iqiyi/d' > /etc/dnsmasq/adblocks/simpleu
  35. wget --no-check-certificate -qO - http://www.malwaredomainlist.com/hostslist/hosts.txt | sed -n '/127/p' | sed '/localhost/d' > /etc/dnsmasq/adblocks/malwaredomainlist.conf
  36. wget --no-check-certificate -qO - http://code.taobao.org/svn/yhosts/hosts | sed '/iqiyi/d' > /etc/dnsmasq/adblocks/yhosts
  37. # 合并广告规则缓存
  38. cat /etc/dnsmasq/adblocks/simpleu /etc/dnsmasq/adblocks/yhosts > /etc/dnsmasq/adblocks/noad
  39. # 删除下载缓存
  40. rm /etc/dnsmasq/adblocks/simpleu
  41. rm /etc/dnsmasq/adblocks/yhosts
  42. # 删除重复规则
  43. sort /etc/dnsmasq/adblocks/noad | uniq > /etc/dnsmasq/adblocks/noad.conf
  44. # 删除缓存文件
  45. rm /etc/dnsmasq/adblocks/noad
  46. # 重启dnsmasq服务
  47. killall dnsmasq
  48. /usr/sbin/dnsmasq

  49. # 创建广告规则更新脚本
  50. cat > /etc/dnsmasq/adblocks/noad_update.sh <<EOF
  51. #!/bin/sh
  52. # 移动到用户命令文件夹
  53. cd /usr/bin/
  54. # 下载广告缓存(sed命令: 保留127开头>删除含"iqiyi | .jd.com | .taobao.com | 5173.com | www.hao123.com | localhost | # |"内容的规则)
  55. wget --no-check-certificate -qO - http://raw.githubusercontent.com/vokins/simpleu/master/hosts | sed -n '/127/p' | sed '/www.hao123.com/d' | sed '/localhost/d' | sed '/#/d' | sed '/.5173.com/d' | sed '/.taobao.com/d' | sed '/.jd.com/d' | sed '/iqiyi/d' > /etc/dnsmasq/adblocks/simpleu
  56. wget --no-check-certificate -qO - http://www.malwaredomainlist.com/hostslist/hosts.txt | sed -n '/127/p' | sed '/localhost/d' > /etc/dnsmasq/adblocks/malwaredomainlist.conf
  57. wget --no-check-certificate -qO - http://code.taobao.org/svn/yhosts/hosts | sed '/iqiyi/d' > /etc/dnsmasq/adblocks/yhosts
  58. # 合并simpleu与yhosts下载缓存
  59. cat /etc/dnsmasq/adblocks/simpleu /etc/dnsmasq/adblocks/yhosts > /etc/dnsmasq/adblocks/noad
  60. # 删除下载缓存
  61. rm /etc/dnsmasq/adblocks/simpleu
  62. rm /etc/dnsmasq/adblocks/yhosts
  63. # 删除重复规则
  64. sort /etc/dnsmasq/adblocks/noad | uniq > /etc/dnsmasq/adblocks/noad.conf
  65. # 删除合并缓存
  66. rm /etc/dnsmasq/adblocks/noad
  67. # 重启dnsmasq服务
  68. killall dnsmasq
  69. /usr/sbin/dnsmasq
  70. EOF

  71. # 注入每8小时更新一次的任务
  72. http_username=`nvram get http_username`
  73. cat >> /etc/crontabs/$http_username <<EOF
  74. 8 */8 * * * /bin/sh /etc/dnsmasq/adblocks/noad_update.sh
  75. #EOF
复制代码




手动复原方法
  1. 打开/etc/dnsmasq.conf
  2. 删除以下参数
  3. # 同时查询所有上游DNS
  4. # all-servers
  5. # 按顺序查询上游DNS
  6. strict-order
  7. # 添加监听地址(将192.168.1.1修改为你的lan网关ip)
  8. listen-address=192.168.1.1,127.0.0.1
  9. # 添加上游DNS服务器
  10. resolv-file=/etc/dnsmasq/resolv.conf
  11. # 添加广告规则路径
  12. addn-hosts=/etc/dnsmasq/adblocks/malwaredomainlist.conf
  13. addn-hosts=/etc/dnsmasq/adblocks/noad.conf

  14. 删除adblocks文件夹
  15. /etc/dnsmasq/adblocks/

  16. 删除定时任务
  17. 找到  /etc/crontabs/以你的用户名命名的文件
  18. 删除下面的命令
  19. 8 */8 * * * /bin/sh /etc/dnsmasq/adblocks/noad_update.sh
复制代码

















本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

×
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2016-4-21 10:23 | 显示全部楼层
d'd'd
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2016-4-21 11:25 | 显示全部楼层
LZ。能否把智能解析和去广告这两个脚本分开?这个去广告好像没有adbyby好用,用这个爱奇艺看不了视频
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2016-4-21 19:22 | 显示全部楼层
本帖最后由 lukme 于 2016-4-21 19:56 编辑

哦,对了,我这里还有一条注入etc\storage\script_script.sh脚本的命令,可以确保开机启动阶段自动修改/etc/resolv.conf(也就是上游DNS服务器)

说明

完整命令
搜索 etc\storage\script_script.sh 脚本里的 关键字 223.5.5.5 并在该关键字上一行注入
  1. sed -i '/223.5.5.5/i\echo -e "nameserver 127.0.0.1\nnameserver 223.5.5.5\nnameserver 114.114.114.114" > /etc/resolv.conf' /etc/storage/script_script.sh
复制代码


注入内容
  1. #说明
  2. echo -e "nameserver 127.0.0.1\nnameserver 223.5.5.5\nnameserver 114.114.114.114" > /etc/resolv.conf
复制代码



点评

非常好,感谢, 晚点我把它置顶到1L  详情 回复 发表于 2016-4-22 11:24
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2016-4-22 08:59 | 显示全部楼层
重启后还会生效吗

点评

有 更新固件后重置脚本就木有了  详情 回复 发表于 2016-4-22 11:28
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

有疑问请添加管理员QQ86788181|手机版|小黑屋|Archiver|恩山无线论坛(常州市恩山计算机开发有限公司版权所有) ( 苏ICP备05084872号 )

GMT+8, 2024-3-29 03:02

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

| 江苏省互联网有害信息举报中心 举报信箱:js12377 | @jischina.com.cn 举报电话:025-88802724 本站不良内容举报信箱:68610888@qq.com 举报电话:0519-86695797

快速回复 返回顶部 返回列表