block ads in openwrt routers
27 Nov 2017
In previous posts I wrote about how to block YouTube and other services by ip, this time I’ll show how to do the same by dns, kind of adblock for openwrt.
Since revision 39312 OpenWRT configures the dnsmasq service to read from /tmp/dnsmasq.d/, so it’s easy to dump block list there and reload the dnsmasq service to block undesired domains.
# wget http://rawgit.com/javier-lopez/learn/master/sh/is/adblockupdater-openwrt -O /usr/bin/adblockupdater-openwrt # chmod +x /usr/bin/adblockupdater-openwrt # adblockupdater-openwrt Getting yoyo ad list... Getting winhelp2002 ad list... Getting adaway ad list... Getting hosts-file ad list... Getting malwaredomainlist ad list... Getting adblock.gjtech ad list... Failed to establish connection Getting someone who cares ad list... 69191 ad domains blocked. Everything fine, restarting dnsmasq to implement new serverlist...
Add it to the cron job manager:
# crontab -e 0 0 */1 * * /usr/bin/adblockupdater.sh
That’s it, happy blocking 😋