主页 > 路由器 > 在Openwrt上增加广告过滤拦截

在Openwrt上增加广告过滤拦截

2016年9月4日 在Openwrt上增加广告过滤拦截无评论 阅读: 20,981 次

原理:利用dnsmasq和广告网站列表,将广告网站的地址设置为127.0.0.1,从而达到屏蔽广告的效果

 

1、安装全能版本的wget

由于要用到https进行下载,自带的wget不支持,需下载一个全能版wget,下图第一个:

2、下载easylist列表并转换成dnsmasq格式

下载后生成的文件放入/etc/dnsmasq.d/dnsmasq.ads

wget --no-check-certificate -O - https://easylist-downloads.adblockplus.org/easylistchina+easylist.txt | grep ^\|\|[^\*]*\^$ | sed -e 's:||:address\=\/:' -e 's:\^:/127\.0\.0\.1:' > /etc/dnsmasq.d/dnsmasq.ads

 

3、在/etc/dnsmasq.conf文件的最后增加一句

conf-dir=/etc/dnsmasq.d

4、重启dnsmasq生效

/etc/init.d/dnsmasq restart

 

easylist的列表示例,4天刷新一次,每4天运行一下上面的wget命令即可,也可放入crontab中自动执行:

转换后的/etc/dnsmasq.d/dnsmasq.ads:

 

 

发表评论

新用户的评论需审核后才会显示;

电子邮件地址不会被公开;
必填项已用*标注