ad-blocking with DD-WRT revisited (simple)

Post new topic   Reply to topic    DD-WRT Forum Index -> Broadcom SoC based Hardware
Goto page Previous  1, 2, 3 ... 7, 8, 9 ... 12, 13, 14  Next
Author Message
Dark_Shadow
DD-WRT Guru


Joined: 31 Aug 2009
Posts: 2448
Location: Third Rock from the Sun

PostPosted: Sun Aug 22, 2010 14:27    Post subject: Reply with quote
1. Does this require the use of DNSMasq as DNS server?

2. Will this work on a setup that is using a private DNS server on the network other that the main router?

3. Has the first post been updated to include the most recent changes?

_________________
Peacock Thread-FAQ -- dd-wrt Wiki

Testing Multiple Routers -- Bootloader Collection Project -- My Wiki
Sponsor
lamelogin
DD-WRT Novice


Joined: 18 Sep 2010
Posts: 25

PostPosted: Sun Oct 17, 2010 17:19    Post subject: Wiki - Change Reply with quote
Note #1: I've modified the Wiki page for the mvps script. According to the dnsmasq man page, sending a HUP does NOT reread /tmp/hosts0. You have to restart the daemon.

Note #2: This probably isn't the best solution, as I bet some folks are starting dnsmasq with some wierd options. Is there a "service" script that will restart the daemon in a better way? I'm not familiar with the init system for dd-wrt. ie: service dns restart or svcadm restart dns.

Note #3: I've also added a "tr" entry to remove the ^M's from the Weendows file format.

# man page
http://www.thekelleys.org.uk/dnsmasq/docs/dnsmasq-man.html

# Wiki script
http://www.dd-wrt.com/wiki/index.php/Useful_Scripts#Block_URLs_with_an_Automatically_Downloaded_Host_File
calee4nyaboy
DD-WRT User


Joined: 03 Aug 2010
Posts: 81

PostPosted: Mon Nov 29, 2010 5:26    Post subject: Reply with quote
MKruer wrote:
Donny:
This should run on all builds.
What is does is takes any request from a system and checks it against the list of URLS. If the URL matches, it returns the IP 0.0.0.0 instead of passing it though and getting the ad.


This is incorrect information. It does NOT run on micro builds. Runs on mini or standard.
frater
DD-WRT Guru


Joined: 07 Jun 2006
Posts: 2777

PostPosted: Mon Nov 29, 2010 7:39    Post subject: Reply with quote
calee4nyaboy wrote:
This is incorrect information. It does NOT run on micro builds. Runs on mini or standard.
What are you doing in this thread? I am busy with you in another thread and invested time to try and solve your problem. You still haven't done the things I've told you, like putting that script there.
_________________
Asus RT16N + OTRW
Kingston 4GB USB-disk 128 MB swap + 1.4GB ext3 on /opt + 2 GB ext3 on /mnt
Copperjet 1616 modem in ZipB-config
Asterisk, pixelserv & Pound running on router
Another Asus RT16N as WDS-bridge

DD-WRT v24-sp2 vpn (c) 2010 NewMedia-NET GmbH
Release: 12/16/10 (SVN revision: 15758M)
frater
DD-WRT Guru


Joined: 07 Jun 2006
Posts: 2777

PostPosted: Mon Nov 29, 2010 7:46    Post subject: Re: Wiki - Change Reply with quote
lamelogin wrote:
Note #1: I've modified the Wiki page for the mvps script. According to the dnsmasq man page, sending a HUP does NOT reread /tmp/hosts0. You have to restart the daemon.

Not true.
And very silly to use a manual to tell someone he is wrong.
I tested it. You obviously NOT
Are you working for the civil service or something?
Code:
~# host bla.gakijken.nl
bla.gakijken.nl has address 82.150.128.70
~# killall -HUP dnsmasq
~# host bla.gakijken.nl
bla.gakijken.nl has address 10.63.63.1

Stop vandalizing wiki's!

PS And learn to read as well. The manual says something else than you understood.
http://www.dd-wrt.com/wiki/index.php/Blocking_URL%27s/IP%27s#Block_URLs_with_an_Automatically_Downloaded_Host_File

_________________
Asus RT16N + OTRW
Kingston 4GB USB-disk 128 MB swap + 1.4GB ext3 on /opt + 2 GB ext3 on /mnt
Copperjet 1616 modem in ZipB-config
Asterisk, pixelserv & Pound running on router
Another Asus RT16N as WDS-bridge

DD-WRT v24-sp2 vpn (c) 2010 NewMedia-NET GmbH
Release: 12/16/10 (SVN revision: 15758M)
lamelogin
DD-WRT Novice


Joined: 18 Sep 2010
Posts: 25

PostPosted: Thu Dec 16, 2010 3:16    Post subject: Reply with quote
EDIT: I see someone updated the Wiki page with a new script, which may make my original point moot. (unless the new one has the same issue?)

frater,

I'm sorry for upsetting you. I must be doing something wrong then, sorry for insulting you by updating a Wiki page ONCE with info I thought was correct. I have tested it several times. Your output dosen't show if you tested the script after a fresh reboot, have you?

The entry I was refering to was the following: "When it receives a SIGHUP, dnsmasq clears its cache and then re-loads /etc/hosts and /etc/ethers and any file given by --dhcp-hostsfile, --dhcp-optsfile or --addn-hosts. The dhcp lease change script is called for all existing DHCP leases. If --no-poll is set SIGHUP also re-reads /etc/resolv.conf. SIGHUP does NOT re-read the configuration file. "

root@DD-WRT:/tmp# uptime
21:13:16 up 5 min, 0 users, load average: 0.12, 0.40, 0.22

root@DD-WRT:/tmp# cat /tmp/.rc_firewall
#!/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 -HUP dnsmasq
EOF
chmod 777 /tmp/dlhosts
/tmp/dlhosts
fi
grep -q '/tmp/dlhosts' /tmp/crontab ||
echo "45 23 * * 5 root /tmp/dlhosts" >>/tmp/crontab
root@DD-WRT:/tmp# tail -1 /tmp/hosts0
0.0.0.0 zzz.clickbank.net
root@DD-WRT:/tmp# host zzz.clickbank.net
zzz.clickbank.net has address 74.63.153.62
zzz.clickbank.net has address 74.63.153.63
root@DD-WRT:/tmp# killall -HUP dnsmasq
root@DD-WRT:/tmp# host zzz.clickbank.net
zzz.clickbank.net has address 74.63.153.63
zzz.clickbank.net has address 74.63.153.62
root@DD-WRT:/tmp# killall dnsmasq
root@DD-WRT:/tmp# dnsmasq --conf-file=/tmp/dnsmasq.conf
root@DD-WRT:/tmp# host zzz.clickbank.net
zzz.clickbank.net has address 0.0.0.0
blaser
DD-WRT Guru


Joined: 16 Jul 2006
Posts: 525

PostPosted: Thu Dec 16, 2010 4:23    Post subject: Reply with quote
Below is my script, I added the functionality of removing lines from the original hosts.txt file.
I found that some sites that are disabled in the hosts.txt I need to uses.
I have a webserver at home, I created a file the contains this list and I can add more if I need.

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\n" >/tmp/wh
echo -e "grep \"^127.0.0.1\" /tmp/hsts | grep \"^127.0.0.1\" | grep -v localhost | awk '{print \"$_rogue\\\t\"\$2}' | tr -d '\\\015' >/tmp/dlhosts.tmp\nrm /tmp/hsts\n" >>/tmp/wh
echo -e "wget -q -O /tmp/rfbl.tmp http://192.168.1.17/remove/remove_from_blacklist.txt\ncat /tmp/rfbl.tmp | tr -d '\\\015' >/tmp/rfbl\nrm /tmp/rfbl.tmp" >>/tmp/wh
echo -e "grep -v -f /tmp/rfbl /tmp/dlhosts.tmp > /tmp/dlhosts\nrm /tmp/dlhosts.tmp\nkillall -HUP dnsmasq" >>/tmp/wh
sh /tmp/wh &

_________________
Netgear R9000 main router
RAX80 as AP
frater
DD-WRT Guru


Joined: 07 Jun 2006
Posts: 2777

PostPosted: Thu Dec 16, 2010 7:29    Post subject: Reply with quote
lamelogin wrote:
I have tested it several times. Your output dosen't show if you tested the script after a fresh reboot, have you?

You have an appropriate sig...
Don't share your code.. it will keep damage limited.

_________________
Asus RT16N + OTRW
Kingston 4GB USB-disk 128 MB swap + 1.4GB ext3 on /opt + 2 GB ext3 on /mnt
Copperjet 1616 modem in ZipB-config
Asterisk, pixelserv & Pound running on router
Another Asus RT16N as WDS-bridge

DD-WRT v24-sp2 vpn (c) 2010 NewMedia-NET GmbH
Release: 12/16/10 (SVN revision: 15758M)
heaycekz
DD-WRT Novice


Joined: 23 Dec 2010
Posts: 2

PostPosted: Thu Dec 23, 2010 11:47    Post subject: hi! Reply with quote
Can somebody help me with this script?
I'm really noob at this but I wanted to download the pixelserv binary at startup then execute it afterwards. But this one is not downloading anything in the /tmp folder.

Thanks.

Code:

logger WAN UP scripts

#!/bin/sh

cd /tmp
wget http://www.mywebsite.org/pixelserv
wait
cd /tmp
chmod +x pixelserv
./pixelserv &



_rogue=192.168.7.1
echo -e "#!/bin/sh\nn=1\nwhile sleep 60\ndo\n\twget -q -O - http://www.mvps.org/winhelp2002/hosts.txt | grep \"^127.0.0.1\" | grep -v localhost | awk '{print \"$_rogue\\\t\"\$2}' | tr -d '\\\015' >/tmp/dlhosts\n" >/tmp/write_dlhosts
echo -e "\t[ \`grep -il doubleclick /tmp/dlhosts\` ] && break\n\t[ \$n -gt 5 ] && break\n\tlet n+=1\ndone\nkillall -HUP dnsmasq" >>/tmp/write_dlhosts
chmod +x /tmp/write_dlhosts
/tmp/write_dlhosts &
frater
DD-WRT Guru


Joined: 07 Jun 2006
Posts: 2777

PostPosted: Thu Dec 23, 2010 18:28    Post subject: Re: hi! Reply with quote
heaycekz wrote:

wget http://www.mywebsite.org/pixelserv

It's a bogus domain.
He has his own webserver at his disposal and he gave this example assuming people would know....

_________________
Asus RT16N + OTRW
Kingston 4GB USB-disk 128 MB swap + 1.4GB ext3 on /opt + 2 GB ext3 on /mnt
Copperjet 1616 modem in ZipB-config
Asterisk, pixelserv & Pound running on router
Another Asus RT16N as WDS-bridge

DD-WRT v24-sp2 vpn (c) 2010 NewMedia-NET GmbH
Release: 12/16/10 (SVN revision: 15758M)
heaycekz
DD-WRT Novice


Joined: 23 Dec 2010
Posts: 2

PostPosted: Thu Dec 23, 2010 19:22    Post subject: Reply with quote
Code:
logger WAN UP scripts

sleep 5

_rogue=192.168.1.1
echo -e "#!/bin/sh\nn=1\nwhile sleep 60\ndo\n\twget -q -O - http://www.mvps.org/winhelp2002/hosts.txt | grep \"^127.0.0.1\" | grep -v localhost | awk '{print \"$_rogue\\\t\"\$2}' | tr -d '\\\015' >/tmp/dlhosts\n" >/tmp/write_dlhosts
echo -e "\t[ \`grep -il doubleclick /tmp/dlhosts\` ] && break\n\t[ \$n -gt 5 ] && break\n\tlet n+=1\ndone\nkillall -HUP dnsmasq" >>/tmp/write_dlhosts
chmod +x /tmp/write_dlhosts
/tmp/write_dlhosts

sleep 30
wget -O /tmp/pixelserv http://www.idiotbox.ws/pixelserv
wait
chmod +x /tmp/pixelserv
/tmp/pixelserv &


Actually, I did that to hide my site, anyway since this is only 8kb file, feel free to use my bandwidth.

This is the working script. I think the previous one didn't work because WAN wasn't available yet.
o0110o
DD-WRT Novice


Joined: 10 Jan 2011
Posts: 3

PostPosted: Tue Jan 11, 2011 1:59    Post subject: Ad-block without PixelServ or JFFS Reply with quote
This thread may help some of you: http://www.dd-wrt.com/phpBB2/viewtopic.php?p=524030#524030.
ndewan
DD-WRT Guru


Joined: 14 Jan 2010
Posts: 553

PostPosted: Tue Mar 29, 2011 6:01    Post subject: Reply with quote
Just found this thread and would like to implent Frater (the great)'s proposed script.

Wanted to check to see if the scripts have changed from what is posted on the first page of this topic.

Any way to sticky a link to the latest version of the scripts?

_________________
===================================
1 * DIR-866L - 29193 Mega (Main Gateway)
1 * EA4200 - 29193 Mega (Main Gateway)
1 * EA6500 - 29193 Mega (Repeater Bridge)
1 * EA6500v2 - 29193 Mega (Repeater Bridge)
1 * WRT610N - 29193 Mega (Repeater Bridge)
===================================
frater
DD-WRT Guru


Joined: 07 Jun 2006
Posts: 2777

PostPosted: Tue Mar 29, 2011 9:22    Post subject: Reply with quote
Upon reques I recently took another look at the scipt again in this thread:
http://www.dd-wrt.com/phpBB2/viewtopic.php?t=83268

I posted this code:
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 &


It is more streamlined than the one in this thread although the one in this thread should do just fine.

If you have OTRW anyhow I would advice you to enable the script 'S45pixelserv' as it runs a small pseudo-httpserver that will answer these redirected requests.

_________________
Asus RT16N + OTRW
Kingston 4GB USB-disk 128 MB swap + 1.4GB ext3 on /opt + 2 GB ext3 on /mnt
Copperjet 1616 modem in ZipB-config
Asterisk, pixelserv & Pound running on router
Another Asus RT16N as WDS-bridge

DD-WRT v24-sp2 vpn (c) 2010 NewMedia-NET GmbH
Release: 12/16/10 (SVN revision: 15758M)
ndewan
DD-WRT Guru


Joined: 14 Jan 2010
Posts: 553

PostPosted: Thu Mar 31, 2011 0:16    Post subject: Reply with quote
Frater,

I went ahead and installed the code above, added the dnsmasq entry and enables the pixelserv service.

I am noticing a performance issue and pages take ages to load. Even the dd-wrt forum page hangs. Other sites include my.yahoo.com, cnn.com, bbc.com.uk etc.

On a whim, while pages were waiting to load, I stopped the pixelserv service, and the pages loaded immediately.

By no means is this a conclusive test, but I wanted to check with the group to see if others are seeing similar issues.

If my case is isoloated, any clues as to what might be going on.

Router: e3000
Firmware: DD-WRT v24-sp2 (12/24/10) mega
(SVN revision 15962)

_________________
===================================
1 * DIR-866L - 29193 Mega (Main Gateway)
1 * EA4200 - 29193 Mega (Main Gateway)
1 * EA6500 - 29193 Mega (Repeater Bridge)
1 * EA6500v2 - 29193 Mega (Repeater Bridge)
1 * WRT610N - 29193 Mega (Repeater Bridge)
===================================
Goto page Previous  1, 2, 3 ... 7, 8, 9 ... 12, 13, 14  Next Display posts from previous:    Page 8 of 14
Post new topic   Reply to topic    DD-WRT Forum Index -> Broadcom SoC 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 can attach files in this forum
You can download files in this forum