找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
广告投放联系QQ68610888
查看: 14217|回复: 43

路由器端脚本---屏蔽广告/恶意网站(整合版)

[复制链接]
本帖最后由 824626242 于 2014-3-18 10:29 编辑

其实我也是在论坛找的 整合了一下,自动更新,用到adblock-chinalist屏蔽部分广告、someonewhocares、mwsl的host屏蔽恶意网站. 去广告效果只能说一般,恶意网站只要在数据库都可废话少说
步骤
1.添加定时任务
  1. 0 6 * * * /jffs/block.sh #自行改写目录,表示每天6点运行更新脚本,Openwrt界面上改或者改/etc/crontab/root,Tomato web界面-系统管理-定时重启/连接
复制代码
2.如果你是Openwrt或者石像鬼,新建block.sh,给777权限,放在重启不丢失目录,如新建/jffs/
  1. #去.1.zip后缀即可
复制代码
3.如果你是Tomato,新建block.sh,给777权限,放在重启不丢失目录,如/jffs/分区
在Web界面-高级设置-DHCP/DNS-dnsmasq自定义设置加入
  1. addn-hosts=/tmp/hosts1
  2. conf-dir=/jffs/dnsmasq/
复制代码
block.sh
  1. #去.2.zip后缀即可
复制代码

如果你想立即生效,可以在系统命令或putty输入/jffs/block.sh

本帖子中包含更多资源

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

×

评分

参与人数 1恩山币 +1 收起 理由
f*** + 1 土豪,我们做朋友吧!

查看全部评分

我的恩山、我的无线 The best wifi forum is right here.
 楼主| | 显示全部楼层
本帖最后由 824626242 于 2014-4-27 20:33 编辑

既然adblock下载无效了 新版源也不适用 是不是考虑弃用呢
1.如果你要继续用adblock,得把下载好的adblock.txt放到重启不丢失的目录,比如路由flash,挂载的硬盘等,以下以/jffs/adblock.txt为例
block.sh代码如下
  1. #!/bin/sh
  2. mkdir -p /jffs/dnsmasq
  3. wget -O /tmp/hosts1 http://someonewhocares.org/hosts/hosts
  4. wget -O /tmp/mwsl http://www.mwsl.org.cn/hosts/hosts
  5. sed -i "s/103.31.241.171/127.0.0.1/g" /tmp/mwsl
  6. tail +9 /tmp/mwsl >>/tmp/hosts1
  7. cat /jffs/adblock-lazy.txt|grep ^\|\|[^\*]*\^$ |sed -e "s/||/address=\//g" -e "s/\^/\/127.0.0.1/g" >/jffs/dnsmasq/adblock
  8. rm /tmp/mwsl
  9. service dnsmasq restart
  10. exit 0
复制代码

2.弃用adblock,只屏蔽恶意网站
block.sh代码如下
  1. #!/bin/sh
  2. wget -O /tmp/hosts1 http://someonewhocares.org/hosts/hosts
  3. wget -O /tmp/mwsl http://www.mwsl.org.cn/hosts/hosts
  4. sed -i "s/103.31.241.171/127.0.0.1/g" /tmp/mwsl
  5. tail +9 /tmp/mwsl >>/tmp/hosts1
  6. rm /tmp/mwsl
  7. service dnsmasq restart
  8. exit 0
复制代码



本帖子中包含更多资源

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

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

使用道具 举报


不错不错,很有价值,收藏啦~~
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

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

使用道具 举报

能屏蔽视频广告
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

来自手机 | 显示全部楼层
能屏蔽广告就好哦
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

很有价值,收藏啦
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

Tomato DualWAN 按教程设置后上不了网,什么情况?是不是还要设置其它地方?可以最详细一下教程吗?
还是Tomato DualWAN不支持?
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

 楼主| | 显示全部楼层
  1. #!/bin/sh
  2. rm /tmp/hosts1
  3. rm /tmp/adblock-lazy.txt
  4. mkdir -p /jffs/dnsmasq
  5. wget -O /tmp/hosts1 http://someonewhocares.org/hosts/hosts
  6. wget -P /tmp http://adblock-chinalist.googlecode.com/svn/trunk/adblock-lazy.txt
  7. wget -O /tmp/mwsl http://www.mwsl.org.cn/hosts/hosts
  8. tail +9 /tmp/mwsl >>/tmp/hosts1
  9. sed -i "s/115.28.8.59/127.0.0.1/g" /tmp/hosts1
  10. cat /tmp/adblock-lazy.txt|grep ^\|\|[^\*]*\^$ |sed -e "s/||/address=\//g" -e "s/\^/\/127.0.0.1/g" >/jffs/dnsmasq/adblock
  11. service dnsmasq restart
  12. exit 0
复制代码
Tomato  block.sh
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

 楼主| | 显示全部楼层
孤星追月 发表于 2014-3-17 19:02
Tomato DualWAN 按教程设置后上不了网,什么情况?是不是还要设置其它地方?可以最详细一下教程吗?
还是T ...

不好意思 试试9L的
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

这个要学习啊
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

强帖,留名
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

tomato  都可以操作?
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

本帖最后由 qq6253614 于 2014-3-17 20:19 编辑

确实,屏蔽效果一般,就目前而言,hosts库并不完整
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

这个应该好用!
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

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

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-4-27 13:25

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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

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