Step 1: Install block-list script

Create a new script named /overlay/


echo -n "updating domains list..." wget -q -O- ""|grep address >/var/ sed -i s/$dummyhost/g /var/ echo " done"

echo -n "updating adhosts list..." wget -q -O-|grep "" >/var/adblock.hosts sed -i -e 's/\r//g' /var/adblock.hosts sed -i -e 's/$dummyhost/g' /var/adblock.hosts echo " done"

echo -n "restarting dnsmasq..." /etc/init.d/dnsmasq restart echo " done"

Make it executable

chmod +x /overlay/

Force creation of files at boot and create a scheduled run (I'll use 07:23 every Sunday) with crontab -e

@reboot                 touch /var/ /var/adblock.hosts
23 7         * * 0         /overlay/

Step 2: Add additional config for dnsmasq

Add the following line to /etc/dnsmasq.conf


Make sure that these files exists at boot, or else dnsmasq will fail. Add the following lines to /etc/rc.local

touch /var/
touch /var/adblock.hosts

Step 3: Update and restart dnsmasq

Run the update manually with /overlay/

Now all your hosts on your network will be redirected to the dummyhost for the blocked domains and hosts. The lists will also be regulary updated. For further security, block outgoing DNS directly from clients (only allow the router to be source of DNS on your network)