Ad blocking
From DD-WRT Wiki
(Difference between revisions)
Revision as of 14:45, 24 October 2010 (edit) Lamelogin (Talk | contribs) ← Previous diff |
Revision as of 06:26, 30 June 2011 (edit) (undo) Sash (Talk | contribs) Next diff → |
||
Line 1: | Line 1: | ||
- | This script, courtesy of several people on the forums, who probably should be named, will enable host-based ad blocking; I tested this on my WRT54GS v4 and WRT54GL v1.0 both running dd-wrt RC5 std. | + | This script, courtesy of several people on the forums, who probably should be named, will enable host-based ad blocking via dns; I tested this on my WRT54GS v4 and WRT54GL v1.0 both running dd-wrt RC5 std. |
- | Current uptime is 11 days, memory hovers around 700kb free (14108 avail), was approximately 2000kb free before the script: | + | Current uptime is 11 days, memory hovers around 700kb free (14108 avail), was approximately 2000kb free before the script. |
+ | Just put this script into "Startup": | ||
<code> | <code> | ||
Line 15: | Line 16: | ||
#!/bin/sh | #!/bin/sh | ||
logger Downloading http://www.mvps.org/winhelp2002/hosts.txt | logger Downloading http://www.mvps.org/winhelp2002/hosts.txt | ||
- | wget -O - http://www.mvps.org/winhelp2002/hosts.txt | | + | wget -O - http://www.mvps.org/winhelp2002/hosts.txt | grep 127.0.0.1 | |
- | + | ||
sed '2,$s/127.0.0.1/0.0.0.0/g; s/[[:space:]]*#.*$//g;' | | sed '2,$s/127.0.0.1/0.0.0.0/g; s/[[:space:]]*#.*$//g;' | | ||
- | grep -v localhost | | + | grep -v localhost | tr ' ' '\t' | |
- | + | tr -s '\t' | tr -d '\015' | sort -u >/tmp/hosts0 | |
- | tr -s '\t' | | + | |
- | + | ||
- | + | ||
grep addn-hosts /tmp/dnsmasq.conf || | grep addn-hosts /tmp/dnsmasq.conf || | ||
echo "addn-hosts=/tmp/hosts0" >>/tmp/dnsmasq.conf | echo "addn-hosts=/tmp/hosts0" >>/tmp/dnsmasq.conf |
Revision as of 06:26, 30 June 2011
This script, courtesy of several people on the forums, who probably should be named, will enable host-based ad blocking via dns; I tested this on my WRT54GS v4 and WRT54GL v1.0 both running dd-wrt RC5 std.
Current uptime is 11 days, memory hovers around 700kb free (14108 avail), was approximately 2000kb free before the script.
Just put this script into "Startup":
#!/bin/sh logger WAN up script executing sleep 5 if test ! -s /tmp/dlhosts then cat >/tmp/dlhosts <<"EOF" #!/bin/sh logger Downloading http://www.mvps.org/winhelp2002/hosts.txt wget -O - http://www.mvps.org/winhelp2002/hosts.txt | grep 127.0.0.1 | sed '2,$s/127.0.0.1/0.0.0.0/g; s/[[:space:]]*#.*$//g;' | grep -v localhost | tr ' ' '\t' | tr -s '\t' | tr -d '\015' | sort -u >/tmp/hosts0 grep addn-hosts /tmp/dnsmasq.conf || echo "addn-hosts=/tmp/hosts0" >>/tmp/dnsmasq.conf logger Restarting dnsmasq killall dnsmasq dnsmasq --conf-file=/tmp/dnsmasq.conf EOF chmod 777 /tmp/dlhosts /tmp/dlhosts fi grep -q '/tmp/dlhosts' /tmp/crontab || echo "45 23 * * 5 root /tmp/dlhosts" >>/tmp/crontab
Enable DNSMasq and Local DNS in Services tab; no Additional DNSMasq options necessary.
Ensure cron is enabled.