Ad blocking with LEDE

Ad blocking

This is a Utility script that downloads a custom HOSTS file from 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!"


This (which gives the possibility to add some custom hosts in /mnt/sda1/hosts or /mnt/sdb1/hosts)


export DLHOSTS=/var/dlhosts_log
echo "" > $DLHOSTS
echo -e "#!/bin/sh\nn=1\nwhile sleep 60\ndo\n\twget -q -O - | grep \"^\" | 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


Put in /etc

Make executable

Run "chmod +x /etc/" from the command line

From Web UI add, Network > DHCP and DNS > Resolv and Hosts file > Additional Hosts files /tmp/dlhosts

Run "/etc/ &" from your startup



This is a Utility script to download a custom HOSTS file from, 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


The script creates a file called "dlhosts" and the hosts "names" have a IP then dnsmasq on the router uses IP and blocks the host site.

There is a similar script in packages feed

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.

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 :slight_smile: