gufus
November 9, 2016, 10:23pm
#1
Ad blocking
This is a Utility script that downloads a custom HOSTS file from http://www.winhelp2002.mvps.org/ the purpose of this file is to block unwanted Ad's
"
MVPS HOSTS now includes entries for most major parasites, hijackers and unwanted Adware/Spyware programs!"
NEW
This (which gives the possibility to add some custom hosts in /mnt/sda1/hosts or /mnt/sdb1/hosts)
dl_hosts.sh
#!/bin/sh
export DLHOSTS=/var/dlhosts_log
echo "" > $DLHOSTS
_rogue=0.0.0.0
echo -e "#!/bin/sh\nn=1\nwhile sleep 60\ndo\n\twget -q -O - http://www.mvps.org/winhelp2002/hosts.txt | grep \"^0.0.0.0\" | grep -v localhost | awk '{print \"$_rogue\\\t\"\$2}' | tr -d '\\\015' >/var/dlhosts\n" >/var/write_dlhosts
echo -e "\t[ \`grep -il doubleclick /var/dlhosts\` ] && break\n\t[ \$n -gt 5 ] && break\n\tlet
n+=1\ndone\n[ -e /mnt/sda1/hosts ] && cat /mnt/sda1/hosts >>/var/dlhosts\n[ -e /mnt/sdb1/hosts ] && cat /mnt/sdb1/hosts >>/var/dlhosts\nkillall -HUP dnsmasq" >>/var/write_dlhosts
chmod +x /var/write_dlhosts
/var/write_dlhosts &
echo "Download Sequence Completed!" >> $DLHOSTS
NOTES:
Put dl_hosts.sh in /etc
Make dl_hosts.sh executable
Run "chmod +x /etc/dl_hosts.sh" from the command line
From Web UI add, Network > DHCP and DNS > Resolv and Hosts file > Additional Hosts files /tmp/dlhosts
Run "/etc/dl_hosts.sh &" from your startup
reboot
Enjoy!
dlang
November 9, 2016, 10:48pm
#2
This is a Utility script to download a custom HOSTS file from winhelp2002.mvps.org , the purpose of this file is to block unwanted Ad's
The hosts file is only used by the local machine. Wouldn't you need to load this
data into DNS to have it affect everything on your local network?
David Lang
gufus
November 9, 2016, 11:33pm
#3
Nope.
The script creates a file called "dlhosts" and the hosts "names" have a IP 0.0.0.0 then dnsmasq on the router uses IP 0.0.0.0 and blocks the host site.
hnyman
November 10, 2016, 12:17pm
#5
And if you need more versatile ad blocking, there is the 'adblock' package with LuCI support from luci-app-adblock
That package makes browsers to behave nicely with the blocked sites, as it serves pixel links for the blocked sites via uhttpd instances.
# dns based ad/abuse domain blocking
## Description
A lot of people already use adblocker plugins within their desktop browsers, but what if you are using your (smart) phone, tablet, watch or any other wlan gadget...getting rid of annoying ads, trackers and other abuse sites (like facebook ;-) is simple: block them with your router. When the dns server on your router receives dns requests, you will sort out queries that ask for the resource records of ad servers and return a simple 'NXDOMAIN'. This is nothing but **N**on-e**X**istent Internet or Intranet domain name, if domain name is unable to resolved using the dns server, a condition called the 'NXDOMAIN' occurred.
## Main Features
* support of the following domain blocklist sources (free for private usage, for commercial use please check their individual licenses):
* [adaway](https://adaway.org)
* => infrequent updates, approx. 400 entries (enabled by default)
* [adguard](https://adguard.com)
* => numerous updates on the same day, approx. 12.000 entries
* [bitcoin](https://github.com/hoshsadiq/adblock-nocoin-list)
* => infrequent updates, approx. 15 entries
* [blacklist]()
* => static local blacklist, located by default in '/etc/adblock/adblock.blacklist'
* [disconnect](https://disconnect.me)
* => numerous updates on the same day, approx. 6.500 entries (enabled by default)
* [dshield](http://dshield.org)
* => daily updates, approx. 4.500 entries
* [feodotracker](https://feodotracker.abuse.ch)
This file has been truncated. show original
Hi, I am just trying this, and the script works fine and generates the file. However I am not sure that dnsmasq is reading the /var/dlhosts file, or if there is a way to make it read it? It doesn't appear to prevent access to any of the listed domains so far.
I'm actually trying to use this as a way of blocking social media sites for set periods, to stop my kids (and myself!) from accessing them