Effective Ad-Blocking with DD-WRT OpenDNS and Startup Script

Post new topic   Reply to topic    DD-WRT Forum Forum Index -> Atheros WiSOC based Hardware
Author Message
o0110o
DD-WRT Novice


Joined: 10 Jan 2011
Posts: 3

PostPosted: Tue Jan 11, 2011 0:58    Post subject: Effective Ad-Blocking with DD-WRT OpenDNS and Startup Script Reply with quote
Hey everybody, this is my first post and I look forward to being part of the community Smile

I recently purchased a D-Link DIR-615-E1, and installed DD-WRT v24-sp2 (12/24/10) std - build 15962 flawlessly with the greatest of ease. I am first time DD-WRT user and I am really pleased with this open, linux-based firmware :)

This forum is full of useful information and I just so happened to stumble across this ad-block start-up script (by frater I think):

Code:

_rogue=127.0.0.1
echo -e "n=1\nwhile ! wget -q -O /tmp/hsts http://www.mvps.org/winhelp2002/hosts.txt ; do\n\t[ \$n -gt 5 ] && break\n\tlet n+=1\n\tsleep 60\ndone\ngrep \"^127.0.0.1\" /tmp/hsts | grep \"^127.0.0.1\" | grep -v localhost | awk '{print \"$_rogue\\\t\"\$2}' | tr -d '\\\015' >/tmp/dlhosts\nrm /tmp/hsts\nkillall -HUP dnsmasq" >/tmp/wh
sh /tmp/wh &


The script worked great however I kept getting the well known error message in place of the ads on a lot of websites.

After some searching I found out about PixelServ which seemed like a great solution but unfortunately would not work for me because I couldn't enable JFFS due to the 4Mb flash limitation of the DIR-615.

After playing with the DNSMasq settings I came up with this configuration:
Code:

DNSMasq Settings (Enable all):
cache-size=2000
addn-hosts=/tmp/dlhosts
no-resolv
strict-order
server=208.67.222.222
server=208.67.222.220


The change here that made a big difference for me was the addition of the OpenDNS servers. For reasons unknown to me I no longer get the aforementioned error message Smile

Now I have error-free ad-blocking with no JFFS, and no PixelServ, which is great considering the limited memory on the flash :)

Feel free to test this out or explain how it works. Any feedback is appreciated. Thanks in advance! :)

o0110o
Sponsor
buddee
DD-WRT Guru


Joined: 06 Feb 2010
Posts: 7386
Location: Little Rock

PostPosted: Tue Jan 11, 2011 2:25    Post subject: Reply with quote
Thanx for the useful info! We need more of this kind of info in this part of the forum, now if i could only get you on an Atheros router with USB so we could get an auto optware package scripted like broadcom has with Optware the right way. Smile
_________________
Wireless N Config | Linking Routers | DD-WRT Wiki | DD-WRT Builds | Peacock - Broadcom FAQ

Having problems with port forwarding? Check out Port Forward Troubleshooting for more info.
mstombs
DD-WRT User


Joined: 31 Oct 2007
Posts: 148

PostPosted: Fri Jan 21, 2011 1:10    Post subject: Reply with quote
If you use Firefox and adblock you do not really need pixelserv, but adding OpenDNS can't have any effect I can see - are you sure the script is run at an appropriate time when the WAN is up to populate /tmp/dlhosts? If not adblocking on the router OpenDNS does have optional website filtering functions.
anees.sw
DD-WRT User


Joined: 17 Sep 2010
Posts: 267
Location: India

PostPosted: Sat Jan 22, 2011 7:45    Post subject: Reply with quote
is dns masq the onnly thing that needs to be configured?
yousaf465
DD-WRT User


Joined: 12 Sep 2010
Posts: 330

PostPosted: Sat Jan 22, 2011 8:37    Post subject: Reply with quote
So how is opendns is helping this any theory ?
anees.sw
DD-WRT User


Joined: 17 Sep 2010
Posts: 267
Location: India

PostPosted: Sat Jan 22, 2011 20:08    Post subject: Reply with quote
so what exactly must be done?
mstombs
DD-WRT User


Joined: 31 Oct 2007
Posts: 148

PostPosted: Tue Feb 01, 2011 23:03    Post subject: Reply with quote
One well-written up method is

http://sysadmingeek.com/articles/how-to-remove-advertisements-with-pixelserv-on-dd-wrt/

This prompted user Oki to build & test an Atheros pixelserv binary

http://secure.dd-wrt.com/phpBB2/viewtopic.php?t=52112&postdays=0&postorder=asc&start=31

There's also a couple of other threads in the Broadcom Forum, and several using Tomato and Tomatousb. One word of caution - when automatically creating and parsing blocklists do be aware that syntax errors in the dnsmasq config file can cause dnsmasq to fail to start-up - and this blocks internet access for any users dependent on it!
mac913
DD-WRT Guru


Joined: 02 May 2008
Posts: 729
Location: Canada

PostPosted: Fri Apr 29, 2011 15:34    Post subject: Re: Effective Ad-Blocking with DD-WRT OpenDNS and Startup Sc Reply with quote
o0110o wrote:
Hey everybody, this is my first post and I look forward to being part of the community :)

I recently purchased a D-Link DIR-615-E1, and installed DD-WRT v24-sp2 (12/24/10) std - build 15962 flawlessly with the greatest of ease. I am first time DD-WRT user and I am really pleased with this open, linux-based firmware :)

This forum is full of useful information and I just so happened to stumble across this ad-block start-up script (by frater I think):

Code:

_rogue=127.0.0.1
echo -e "n=1\nwhile ! wget -q -O /tmp/hsts http://www.mvps.org/winhelp2002/hosts.txt ; do\n\t[ \$n -gt 5 ] && break\n\tlet n+=1\n\tsleep 60\ndone\ngrep \"^127.0.0.1\" /tmp/hsts | grep \"^127.0.0.1\" | grep -v localhost | awk '{print \"$_rogue\\\t\"\$2}' | tr -d '\\\015' >/tmp/dlhosts\nrm /tmp/hsts\nkillall -HUP dnsmasq" >/tmp/wh
sh /tmp/wh &


The script worked great however I kept getting the well known error message in place of the ads on a lot of websites.

After some searching I found out about PixelServ which seemed like a great solution but unfortunately would not work for me because I couldn't enable JFFS due to the 4Mb flash limitation of the DIR-615.

After playing with the DNSMasq settings I came up with this configuration:
Code:

DNSMasq Settings (Enable all):
cache-size=2000
addn-hosts=/tmp/dlhosts
no-resolv
strict-order
server=208.67.222.222
server=208.67.222.220


The change here that made a big difference for me was the addition of the OpenDNS servers. For reasons unknown to me I no longer get the aforementioned error message :)

Now I have error-free ad-blocking with no JFFS, and no PixelServ, which is great considering the limited memory on the flash :)

Feel free to test this out or explain how it works. Any feedback is appreciated. Thanks in advance! :)

o0110o


I to use OpenDNS to block Adds and Content. In addition to your router settings, I also added a firewall script to Intercept all DNS requests to OpenDNS even if someone on my network has manual added their own DNS addresses in their Device (PC, Laptop, Smart Phone, etc...).

# Intercept & Force all br0 DNS Requests to Router's DNS
iptables -t nat -A PREROUTING -i br0 -p udp --dport 53 -j DNAT --to $(nvram get lan_ipaddr)
iptables -t nat -A PREROUTING -i br0 -p tcp --dport 53 -j DNAT --to $(nvram get lan_ipaddr)

_________________
Wired GigaBit Backbone
Netgear R7000 K3.x KONGAC 25090M | Gateway | OpenVPN Client
Netgear R7000 K3.x KONGAC 25580M | Gateway | AP+VAPs | OpenVPN Client
Netgear R7000 K3.x KONGAC 25090M | Spare
Linksys E3000 K2.6 KONG-VPN 22000++M | SSH | QoS | DDNS
Linksys E2000 (OC 500Mhz) Tomato Shibby 123 | OpenVPN Client
jmel
DD-WRT Novice


Joined: 12 Dec 2011
Posts: 3

PostPosted: Mon Dec 12, 2011 1:28    Post subject: Re: Effective Ad-Blocking with DD-WRT OpenDNS and Startup Sc Reply with quote
Is this still current? I'm trying to find a simple ad block startup script, but it seems like everyone scattered in a million directions with this. I don't want to use jffs, I don't want to use pixelserv. I want something simple. This seemed like a great solution, but it doesn't work for me. I've searched around and can't seem to find a definitive script.

o0110o wrote:
Hey everybody, this is my first post and I look forward to being part of the community Smile

I recently purchased a D-Link DIR-615-E1, and installed DD-WRT v24-sp2 (12/24/10) std - build 15962 flawlessly with the greatest of ease. I am first time DD-WRT user and I am really pleased with this open, linux-based firmware Smile

This forum is full of useful information and I just so happened to stumble across this ad-block start-up script (by frater I think):

Code:

_rogue=127.0.0.1
echo -e "n=1\nwhile ! wget -q -O /tmp/hsts http://www.mvps.org/winhelp2002/hosts.txt ; do\n\t[ \$n -gt 5 ] && break\n\tlet n+=1\n\tsleep 60\ndone\ngrep \"^127.0.0.1\" /tmp/hsts | grep \"^127.0.0.1\" | grep -v localhost | awk '{print \"$_rogue\\\t\"\$2}' | tr -d '\\\015' >/tmp/dlhosts\nrm /tmp/hsts\nkillall -HUP dnsmasq" >/tmp/wh
sh /tmp/wh &


The script worked great however I kept getting the well known error message in place of the ads on a lot of websites.

After some searching I found out about PixelServ which seemed like a great solution but unfortunately would not work for me because I couldn't enable JFFS due to the 4Mb flash limitation of the DIR-615.

After playing with the DNSMasq settings I came up with this configuration:
Code:

DNSMasq Settings (Enable all):
cache-size=2000
addn-hosts=/tmp/dlhosts
no-resolv
strict-order
server=208.67.222.222
server=208.67.222.220


The change here that made a big difference for me was the addition of the OpenDNS servers. For reasons unknown to me I no longer get the aforementioned error message Smile

Now I have error-free ad-blocking with no JFFS, and no PixelServ, which is great considering the limited memory on the flash Smile

Feel free to test this out or explain how it works. Any feedback is appreciated. Thanks in advance! Smile

o0110o
/tmp/wh
sh /tmp/wh
makaveli101
DD-WRT Novice


Joined: 17 May 2010
Posts: 42

PostPosted: Wed May 30, 2012 20:23    Post subject: Re: Effective Ad-Blocking with DD-WRT OpenDNS and Startup Sc Reply with quote
o0110o wrote:
Hey everybody, this is my first post and I look forward to being part of the community Smile

I recently purchased a D-Link DIR-615-E1, and installed DD-WRT v24-sp2 (12/24/10) std - build 15962 flawlessly with the greatest of ease. I am first time DD-WRT user and I am really pleased with this open, linux-based firmware Smile

This forum is full of useful information and I just so happened to stumble across this ad-block start-up script (by frater I think):

Code:

_rogue=127.0.0.1
echo -e "n=1\nwhile ! wget -q -O /tmp/hsts http://www.mvps.org/winhelp2002/hosts.txt ; do\n\t[ \$n -gt 5 ] && break\n\tlet n+=1\n\tsleep 60\ndone\ngrep \"^127.0.0.1\" /tmp/hsts | grep \"^127.0.0.1\" | grep -v localhost | awk '{print \"$_rogue\\\t\"\$2}' | tr -d '\\\015' >/tmp/dlhosts\nrm /tmp/hsts\nkillall -HUP dnsmasq" >/tmp/wh
sh /tmp/wh &


The script worked great however I kept getting the well known error message in place of the ads on a lot of websites.

After some searching I found out about PixelServ which seemed like a great solution but unfortunately would not work for me because I couldn't enable JFFS due to the 4Mb flash limitation of the DIR-615.

After playing with the DNSMasq settings I came up with this configuration:
Code:

DNSMasq Settings (Enable all):
cache-size=2000
addn-hosts=/tmp/dlhosts
no-resolv
strict-order
server=208.67.222.222
server=208.67.222.220


The change here that made a big difference for me was the addition of the OpenDNS servers. For reasons unknown to me I no longer get the aforementioned error message Smile

Now I have error-free ad-blocking with no JFFS, and no PixelServ, which is great considering the limited memory on the flash Smile

Feel free to test this out or explain how it works. Any feedback is appreciated. Thanks in advance! Smile

o0110o


thanks i will give this a try
makaveli101
DD-WRT Novice


Joined: 17 May 2010
Posts: 42

PostPosted: Thu May 31, 2012 1:22    Post subject: Reply with quote
all you needed was

startup script:

Code:
_rogue=127.0.0.1
echo -e "n=1\nwhile ! wget -q -O /tmp/hsts http://www.mvps.org/winhelp2002/hosts.txt ; do\n\t[ \$n -gt 5 ] && break\n\tlet n+=1\n\tsleep 60\ndone\ngrep \"^127.0.0.1\" /tmp/hsts | grep \"^127.0.0.1\" | grep -v localhost | awk '{print \"$_rogue\\\t\"\$2}' | tr -d '\\\015' >/tmp/dlhosts\nrm /tmp/hsts\nkillall -HUP dnsmasq" >/tmp/wh
sh /tmp/wh &


Additional DNSMasq Options script:

Code:
addn-hosts=/tmp/dlhosts


the only 1 line of dnsmasq script needed, i highly doubt opendns helped.
Detection
DD-WRT User


Joined: 19 Jan 2012
Posts: 210
Location: UK

PostPosted: Thu May 31, 2012 12:01    Post subject: Reply with quote
makaveli101 wrote:
all you needed was

startup script:

Code:
_rogue=127.0.0.1
echo -e "n=1\nwhile ! wget -q -O /tmp/hsts http://www.mvps.org/winhelp2002/hosts.txt ; do\n\t[ \$n -gt 5 ] && break\n\tlet n+=1\n\tsleep 60\ndone\ngrep \"^127.0.0.1\" /tmp/hsts | grep \"^127.0.0.1\" | grep -v localhost | awk '{print \"$_rogue\\\t\"\$2}' | tr -d '\\\015' >/tmp/dlhosts\nrm /tmp/hsts\nkillall -HUP dnsmasq" >/tmp/wh
sh /tmp/wh &


Additional DNSMasq Options script:

Code:
addn-hosts=/tmp/dlhosts


the only 1 line of dnsmasq script needed, i highly doubt opendns helped.


Does anyone know the URLs of the ads that WP7 use ?

Seems I can block the majority of PC and Android apps pretty easily, but WP7 ads get through each time

_________________
WRT160NL
makaveli101
DD-WRT Novice


Joined: 17 May 2010
Posts: 42

PostPosted: Thu May 31, 2012 16:04    Post subject: Reply with quote
Detection wrote:
makaveli101 wrote:
all you needed was

startup script:

Code:
_rogue=127.0.0.1
echo -e "n=1\nwhile ! wget -q -O /tmp/hsts http://www.mvps.org/winhelp2002/hosts.txt ; do\n\t[ \$n -gt 5 ] && break\n\tlet n+=1\n\tsleep 60\ndone\ngrep \"^127.0.0.1\" /tmp/hsts | grep \"^127.0.0.1\" | grep -v localhost | awk '{print \"$_rogue\\\t\"\$2}' | tr -d '\\\015' >/tmp/dlhosts\nrm /tmp/hsts\nkillall -HUP dnsmasq" >/tmp/wh
sh /tmp/wh &


Additional DNSMasq Options script:

Code:
addn-hosts=/tmp/dlhosts


the only 1 line of dnsmasq script needed, i highly doubt opendns helped.


Does anyone know the URLs of the ads that WP7 use ?

Seems I can block the majority of PC and Android apps pretty easily, but WP7 ads get through each time


try
Code:

rad.msn.com
Detection
DD-WRT User


Joined: 19 Jan 2012
Posts: 210
Location: UK

PostPosted: Sat Jun 02, 2012 0:46    Post subject: Reply with quote
makaveli101 wrote:
Detection wrote:
makaveli101 wrote:
all you needed was

startup script:

Code:
_rogue=127.0.0.1
echo -e "n=1\nwhile ! wget -q -O /tmp/hsts http://www.mvps.org/winhelp2002/hosts.txt ; do\n\t[ \$n -gt 5 ] && break\n\tlet n+=1\n\tsleep 60\ndone\ngrep \"^127.0.0.1\" /tmp/hsts | grep \"^127.0.0.1\" | grep -v localhost | awk '{print \"$_rogue\\\t\"\$2}' | tr -d '\\\015' >/tmp/dlhosts\nrm /tmp/hsts\nkillall -HUP dnsmasq" >/tmp/wh
sh /tmp/wh &


Additional DNSMasq Options script:

Code:
addn-hosts=/tmp/dlhosts


the only 1 line of dnsmasq script needed, i highly doubt opendns helped.


Does anyone know the URLs of the ads that WP7 use ?

Seems I can block the majority of PC and Android apps pretty easily, but WP7 ads get through each time


try
Code:

rad.msn.com



Thanks Smile That seems to have blocked some of them, there are still some getting through, mainly ones advertising "IE9 - The beauty of the web"

_________________
WRT160NL
ApokalipseMeow
DD-WRT Novice


Joined: 23 Jul 2010
Posts: 19

PostPosted: Thu May 30, 2013 13:38    Post subject: Reply with quote
This is what I do:

• get a USB drive (you can also use a microsd card if you have an RT-N66U)

• Format it to EXT2 with the label "optware". You can use EaseUS Partition Master free edition or gparted.

• Install Ext2IFS so that Windows can access the EXT2 partition (if you use Windows).

• Download this and extract it to the usb drive. it includes a pixelserv binary, hosts file and a couple of scripts.

• Telnet or SSH into your router (use Putty for Windows), and enter the following:
Code:
echo LABEL=optware /opt ext2 rw,noatime 1 1 >> /tmp/etc/fstab
nvram setfile2nvram /tmp/etc/fstab
nvram commit


• Insert your USB drive / microsd card into the router and reboot it.

• Telnet into your router again and enter these:
Code:
cd /opt
wget http://www.3iii.dk/linux/optware/optware-install-ddwrt.sh -O - | tr -d '\r' > optware-install.sh
chmod +x optware-install.sh
./optware-install.sh
ipkg install sed


• Make this your startup script:
Code:
#!/bin/sh
sleep 7
/opt/etc/*.init


• use the scheduler to make this run periodically (say every week):
Code:
./opt/etc/update_adblock.sh

You can also manually run this in telnet.

And if you want to add extra entries to block, add them to the more.hosts file like this:
Code:
10.63.63.1 example.com
Display posts from previous:    Page 1 of 1
Post new topic   Reply to topic    DD-WRT Forum Forum Index -> Atheros WiSOC based Hardware All times are GMT

Navigation

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum