![]() |
HowTo.CatchRequestsToAdServers HistoryHide minor edits - Show changes to markup June 07, 2008, at 08:43 AM
by --
Changed lines 192-193 from:
echo "Include /etc/cherokee/catch-all.conf">>cherokee.conf to:
echo "Include /etc/cherokee/catch-all.conf">>/etc/cherokee/cherokee.conf November 10, 2007, at 04:09 AM
by --
Changed line 72 from:
Dnsmasq runs under a different user/group by default and will fail to read those files if read permissions are not set properly. It will not give any warning either and will ignore the whole nice setup.\\ to:
Dnsmasq runs under a different user/group by default and will fail to read those files if read permissions are not set properly. It will not give any warning either and will ignore the whole nice setup. Changed line 76 from:
to:
\\ November 10, 2007, at 04:08 AM
by --
Changed lines 74-76 from:
to:
November 10, 2007, at 04:07 AM
by -- Added note about setting proper permissions on banner_add_hosts files
Added lines 67-69:
Create an empty file in which you can add some adservers yourself if you want to:\\ Added lines 72-76:
Dnsmasq runs under a different user/group by default and will fail to read those files if read permissions are not set properly. It will not give any warning either and will ignore the whole nice setup. January 01, 2007, at 02:44 PM
by -- restart of dnsmasq in updatebannerhosts
Changed lines 115-118 from:
to:
reloadcmd='/etc/init.d/dnsmasq restart' Changed lines 150-151 from:
to:
$reloadcmd December 27, 2006, at 08:20 AM
by --
Changed line 59 from:
'>/etc/dnsmasq to:
'>/etc/dnsmasq.conf Added lines 63-64:
There are a lot more flags that can be defined in dnsmasq.conf, but I ignore them all for my simple DNS server. December 27, 2006, at 08:05 AM
by -- cosmetic
Changed lines 164-165 from:
It should point to the new slug now. to:
The first and last one should point to the new slug now. Changed line 204 from:
Now add the (empty) image in the right place. You can either create it yourself, or download it like I did:\\ to:
Now add the (empty) image in the right place. You can either create it yourself, or download it like I did: December 27, 2006, at 08:01 AM
by --
Changed lines 68-69 from:
to:
Changed lines 128-131 from:
echo "" echo "fetch: $fetchcmd" echo "" to:
December 27, 2006, at 07:20 AM
by --
Changed lines 17-18 from:
Since openslug appears to use DHCP to get its ip address, I had to check my DHCP table (or ping to 192.168.1.255) to see where it went. It got 192.168.1.103 in my case, you might get a different address. I believe that if you start up your slug without a DNCP server in your network (or without the network cable attached) it will get 192.168.1.77. to:
Since openslug appears to use DHCP to get its ip address, I had to check my DHCP table (or ping to 192.168.1.255) to see where it went. It got 192.168.1.103 in my case, you might get a different address. I believe that if you start up your slug without a DHCP server in your network (or without the network cable attached) it will get 192.168.1.77. December 27, 2006, at 07:16 AM
by -- typo
Changed lines 15-16 from:
From there I hit the Administration/Upgrade tqb and uploaded new firmware, openslug-3.10-beta.bin this time. After that just wait.... beep! and it is alive. to:
From there I hit the Administration/Upgrade tab and uploaded new firmware, openslug-3.10-beta.bin this time. After that just wait.... beep! and it is alive. December 24, 2006, at 12:08 PM
by -- typo
Changed lines 17-18 from:
Since openslug appears to use DHCP to get its ip address, I had to check my DHCP table (or ping to 192.168.1.255) to see where it went. It got 192.168.1.103 in my case, you might get a different address. I believe that if you start up your slug without a DNCP server in your network (or without the networkcable attached) it will get 192.168.1.77. to:
Since openslug appears to use DHCP to get its ip address, I had to check my DHCP table (or ping to 192.168.1.255) to see where it went. It got 192.168.1.103 in my case, you might get a different address. I believe that if you start up your slug without a DNCP server in your network (or without the network cable attached) it will get 192.168.1.77. December 24, 2006, at 12:06 PM
by -- added a line about default ip .77
Changed lines 17-18 from:
Since openslug appears to use DHCP to get its ip address, I had to check my DHCP table (or ping to 192.168.1.255) to see where it went. It got 192.168.1.103 in my case, you might get a different address. to:
Since openslug appears to use DHCP to get its ip address, I had to check my DHCP table (or ping to 192.168.1.255) to see where it went. It got 192.168.1.103 in my case, you might get a different address. I believe that if you start up your slug without a DNCP server in your network (or without the networkcable attached) it will get 192.168.1.77. December 23, 2006, at 09:06 PM
by -- corrected the startup argument for cherokee
Changed line 230 from:
ARGS="-C /etc/cherokee/cherokee-/etc/cherokee/cherokee-catch-all.conf" to:
ARGS="-b" December 23, 2006, at 06:21 PM
by -- Added a note about startupscriptw
Added lines 239-240:
Note: I had some trouble getting both dns and cherokee to start up automatically. It might have to do something with both getting S20/K20 scripts in the rc?.d directories. I changed one to become S21/K21 links. Seems to work now. December 23, 2006, at 12:35 PM
by --
Changed lines 237-238 from:
Now reboot the slug and see it catch the ads! to:
Now reboot the slug and see it catch the ads! December 23, 2006, at 12:32 PM
by --
Changed lines 44-45 from:
[=ipkg update to:
[= ipkg update Added line 73:
Here is the script (don't start with empty line): Changed lines 76-77 from:
[=#!/bin/sh to:
[=
Changed lines 182-183 from:
[=ipkg install cherokee to:
[= ipkg install cherokee Changed lines 210-211 from:
[=mkdir -p /var/www/images to:
[= mkdir -p /var/www/images Changed line 222 from:
Replace the first 5 lines with: to:
Replace the first 5 lines with (don't start with empty line): Changed lines 225-226 from:
[=#!/bin/sh to:
[=
December 23, 2006, at 12:30 PM
by --
Changed line 22 from:
[= to:
[= December 23, 2006, at 12:30 PM
by -- splitting lines
Changed lines 22-23 from:
[=turnup init to:
[= turnup init December 23, 2006, at 10:32 AM
by --
Changed lines 22-24 from:
[= turnup init to:
[=turnup init Changed lines 43-44 from:
[= ipkg update to:
[=ipkg update Changed lines 73-74 from:
[=#!/bin/sh to:
[=#!/bin/sh Changed lines 178-180 from:
[= ipkg install cherokee to:
[=ipkg install cherokee Changed lines 205-206 from:
[= mkdir -p /var/www/images to:
[=mkdir -p /var/www/images Changed lines 219-220 from:
[=
to:
[=#!/bin/sh December 23, 2006, at 10:30 AM
by --
Changed lines 75-77 from:
[=
to:
[=#!/bin/sh December 23, 2006, at 10:24 AM
by --
Changed lines 13-14 from:
First I unwrapped a new box, to get my new NSLU2 out of it. I just received my new Slug today, the third one. Of course, setting up OpenSlug was easy from the webinterface: turn slug on, attach my notebook and browse to http://192.168.1.77. to:
First I unwrapped a new box, to get my new NSLU2 out of it. I just received my new Slug today, the third one. Added line 16:
Changed lines 207-209 from:
to:
(:table border=0 width=100% bgcolor=#eeeeff:) (:cell:) mkdir -p /var/www/images wget -O /var/www/images/pixel.gif http://www.loremipsum.net/pixelgif/pics/pixel.gif (:tableend:) December 23, 2006, at 10:22 AM
by --
Changed line 154 from:
Of course, this script needs to be executable: to:
Of course, this script needs to be executable:\\ Changed lines 159-162 from:
test it by using
to:
test it by using December 23, 2006, at 10:19 AM
by -- Wrapping up
Deleted lines 0-1:
under constructionAdded line 37:
Set up DNSAdded line 62:
Retrieve the list of ad serversDeleted lines 71-72:
Deleted lines 74-142:
=] (:tableend:) Of course, this script needs to be executable:
Now run the script and see if it works. You have to adjust the DHCP server to send DNS requests to this new DNS server. You might need to renew your IP or reconnect your client to
setup dhcp to point dns to this host.
test it by using
It should point to the new slug now. Now we have the script run automatically every 4 hours, using cron: Edit the cront tab using and add the line (:table border=0 width=100% bgcolor=#eeeeff:) (:cell:)
ipkg install cherokee
echo "Include /etc/cherokee/catch-all.conf">>cherokee.conf
echo '
# rewrite all requests to serve /images/pixel.gif
# with the original request as argument behind a "?"
Request ".*" {
Handler redir {
Show Rewrite "/images/pixel.gif?"
}
}
# this request will only return a file
# since it is lower than the request above, it will be handled first
Request "/images/pixel.gif.*" {
Handler file
}
' > /etc/cherokee/catch-all.conf
(:tableend:) Now add the (empty) image in the right place. You can either create it yourself, or download it like I did: You can start Cherokee by entering But you probably want to autostart Cherokee at boot time. To do so, borrow the start up script from dnsmasq: [= Changed lines 76-79 from:
DAEMON=/usr/sbin/cherokee NAME=cherokee DESC="Cherokee webserver" ARGS="-C /etc/cherokee/cherokee-/etc/cherokee/cherokee-catch-all.conf" to:
addcatcherip='172.16.16.60'
listurlargs="hostformat=hosts&showintro=1&mimetype=plaintext&useip=$addcatcherip"
listurl="http://pgl.yoyo.org/adservers/serverlist.php?$listurlargs"
targetfile='/etc/banner_add_hosts'
extrasfile='/etc/banner_add_hosts.manual'
tmpfile="/tmp/.adlist.$$"
fetchcmd="/usr/bin/wget -q -O $tmpfile $listurl"
echo "" echo "fetch: $fetchcmd" echo ""
$fetchcmd
[ -f "$extrasfile" ] && cat $extrasfile >> $tmpfile
if [ ! -s $tmpfile ] then echo "temp file '$tmpfile' either doesn't exist or is empty; quitting" exit fi
sort $tmpfile > $targetfile
rm $tmpfile
Added lines 154-227:
Of course, this script needs to be executable:
Now run the script and see if it works. You have to adjust the DHCP server to send DNS requests to this new DNS server. You might need to renew your IP or reconnect your client to
setup dhcp to point dns to this host.
test it by using
It should point to the new slug now. Auto-update the listNow we have the script run automatically every 4 hours, using cron: Edit the cront tab using and add the line Install Cherokee webserver(:table border=0 width=100% bgcolor=#eeeeff:) (:cell:)
ipkg install cherokee
echo "Include /etc/cherokee/catch-all.conf">>cherokee.conf
echo '
# rewrite all requests to serve /images/pixel.gif
# with the original request as argument behind a "?"
Request ".*" {
Handler redir {
Show Rewrite "/images/pixel.gif?"
}
}
# this request will only return a file
# since it is lower than the request above, it will be handled
# with higer priority
Request "/images/pixel.gif.*" {
Handler file
}
' > /etc/cherokee/catch-all.conf
(:tableend:) Now add the (empty) image in the right place. You can either create it yourself, or download it like I did: You can start Cherokee by entering But you probably want to autostart Cherokee at boot time. To do so, borrow the start up script from dnsmasq: #!/bin/sh DAEMON=/usr/sbin/cherokee NAME=cherokee DESC="Cherokee webserver" ARGS="-C /etc/cherokee/cherokee-/etc/cherokee/cherokee-catch-all.conf" (:tableend:) Changed line 231 from:
Now reboot the slug and see it catch the ads! to:
Now reboot the slug and see it catch the ads! December 23, 2006, at 10:01 AM
by --
Changed lines 8-11 from:
to:
Changed lines 20-21 from:
To get OpenSlug going, I used: to:
To get OpenSlug going, I went into the server using ssh: Changed lines 24-46 from:
ssh root@192.168.1.103
Host name [LKG7118F6?]: catcher Domain name [workgroup]: mydomain.local Boot protocol (dhcp|static) [dhcp]: static IP address [192.168.1.77]: 172.16.16.60 IP netmask [255.255.255.0]: IP gateway []: 172.16.16.44 First DNS server []: 195.121.1.34 Second DNS server []: 194.109.6.66 Third DNS server []: 194.109.9.99 to:
turnup init umount /dev/sda1 mkfs.ext3 /dev/sda1 turnup memstick -i /dev/sda1 reboot Changed lines 37-40 from:
As you can see, I use 172.16.16.60 for this server. All things after this will use this ip address as dns server and for the catch-all webserver. scratch:: Set up DNS serverto:
I used 172.16.16.60 for this server, you can pick your own address. All directions below use this ip address for dns server and for the catch-all webserver. Added line 40:
Deleted line 41:
Deleted lines 59-60:
Deleted lines 62-67:
uncomment strict-order uncomment addn-hosts=/etc/banner_add_hosts uncomment expand-hosts set the domainname: mydomain.local comment dhcp-range (don't want to do dhcp, just dns) Changed line 66 from:
Also create the to:
Also create the Changed lines 69-70 from:
Now create a script that will fetch the list of adservers: to:
Now create a script that will fetch the list of adservers:\\ Changed lines 95-96 from:
Now we have the script run automatically every 4 hours, using cron: to:
Now we have the script run automatically every 4 hours, using cron:\\ Changed lines 97-98 from:
Edit the cront tab using to:
Edit the cront tab using\\ Changed line 101 from:
and add the line to:
and add the line \\ December 23, 2006, at 09:51 AM
by --
Deleted lines 152-154:
Changed lines 156-174 from:
cherokee -C /etc/cherokee/cherokee-catch-all.conf TODO: autostart cherokee add images/dummy.jpg mkdir -p /var/www/images update-rc.d scriptnaam start 4 stop 6 cp /etc/init.d/dnsmasq /etc/init.d/cherokee vi /etc/init.d/cherokee replace the first 5 lines with: to:
Now add the (empty) image in the right place. You can either create it yourself, or download it like I did: You can start Cherokee by entering But you probably want to autostart Cherokee at boot time. To do so, borrow the start up script from dnsmasq: [= Changed lines 176-181 from:
update-rc.d cherokee defaults to:
=] (:tableend:) To install the autostart script, do: Now reboot the slug and see it catch the ads! December 23, 2006, at 09:36 AM
by --
Changed line 87 from:
Create an empty file in which you can add some adservers yourself if you want to: to:
Create an empty file in which you can add some adservers yourself if you want to:\\ Changed line 90 from:
Also create the to:
Also create the December 23, 2006, at 09:34 AM
by --
Changed lines 97-99 from:
TODO: add the script here to:
December 22, 2006, at 10:53 PM
by --
Deleted line 47:
Changed lines 51-52 from:
to:
As you can see, I use 172.16.16.60 for this server. All things after this will use this ip address as dns server and for the catch-all webserver. Changed lines 54-55 from:
to:
Set up DNS serverI use dnsmasq as DNS server, but I don't care about it's DHCP capabilities, because I already have a DHCP server built in my router. The DHCP server will send the clients the specs of DNS servers to use, starting with this new one. Here is how I setup the DNS server: Added line 64:
Changed lines 67-69 from:
/etc/dnsmasq: to:
Changed lines 97-99 from:
to:
TODO: add the script here Changed lines 108-115 from:
chmod 700 /usr/local/bin/update_bannerhosts to:
Of course, this script needs to be executable:
Now run the script and see if it works. You have to adjust the DHCP server to send DNS requests to this new DNS server. You might need to renew your IP or reconnect your client to Changed lines 114-126 from:
dig doubleclick.com dig cnn.com nslookup cnn.com nslookup doubleclick.com ipkg install cron crontab -e 0 0,4,8,12,16,18,20 * * * /usr/local/bin/update_bannerhosts to:
It should point to the new slug now. Now we have the script run automatically every 4 hours, using cron:
and add the line
(:table border=0 width=100% bgcolor=#eeeeff:) (:cell:) [= Changed lines 135-137 from:
cp /etc/cherokee/cherokee.conf /etc/cherokee/cherokee-catch-all.conf to:
Deleted lines 137-138:
Added lines 157-160:
=] (:tableend:) December 22, 2006, at 09:02 PM
by --
Added lines 1-2:
under constructionDecember 22, 2006, at 09:02 PM
by --
Changed lines 23-24 from:
to:
ssh root@192.168.1.103 Changed lines 45-47 from:
to:
Changed lines 54-56 from:
to:
(:table border=0 width=100% bgcolor=#eeeeff:) (:cell:) [= Deleted line 57:
Changed lines 60-64 from:
echo "172.31.101.11 elaine" >> /etc/hosts echo "172.31.101.10 cosmo" >> /etc/hosts to:
echo "172.16.16.123 myfileserver" >> /etc/hosts Changed lines 68-69 from:
strict-order to:
strict-order domain=mydomain.local Added lines 74-76:
=] (:tableend:) Changed line 80 from:
set the domainname: domain=lotenjelle.local to:
set the domainname: mydomain.local Changed lines 83-90 from:
echo "">/etc/banner_add_hosts.manual mkdir -p /usr/local/bin cd /usr/local/bin wget -O update_bannerhosts http://172.16.16.48/update_bannerhosts.txt to:
Create an empty file in which you can add some adservers yourself if you want to:
Also create the Now create a script that will fetch the list of adservers:
(:table border=0 width=100% bgcolor=#eeeeff:) (:cell:) (:tableend:) December 22, 2006, at 08:50 PM
by --
Added lines 20-22:
(:table border=0 width=100% bgcolor=#eeeeff:) (:cell:) [= Changed lines 48-51 from:
to:
=] (:tableend:) December 22, 2006, at 08:48 PM
by --
Changed lines 19-21 from:
[= ssh root@192.168.1.103 to:
December 22, 2006, at 08:08 PM
by --
Added lines 18-160:
To get OpenSlug going, I used: [= ssh root@192.168.1.103
Host name [LKG7118F6?]: catcher Domain name [workgroup]: mydomain.local Boot protocol (dhcp|static) [dhcp]: static IP address [192.168.1.77]: 172.16.16.60 IP netmask [255.255.255.0]: IP gateway []: 172.16.16.44 First DNS server []: 195.121.1.34 Second DNS server []: 194.109.6.66 Third DNS server []: 194.109.9.99
scratch:: ipkg update ipkg install dnsmasq echo "172.31.101.11 elaine" >> /etc/hosts echo "172.31.101.10 cosmo" >> /etc/hosts /etc/dnsmasq: echo ' domain-needed bogus-priv strict-order addn-hosts=/etc/banner_add_hosts '>/etc/dnsmasq uncomment strict-order uncomment addn-hosts=/etc/banner_add_hosts uncomment expand-hosts set the domainname: domain=lotenjelle.local comment dhcp-range (don't want to do dhcp, just dns) echo "">/etc/banner_add_hosts.manual mkdir -p /usr/local/bin cd /usr/local/bin wget -O update_bannerhosts http://172.16.16.48/update_bannerhosts.txt
chmod 700 /usr/local/bin/update_bannerhosts setup dhcp to point dns to this host. test it by using dig doubleclick.com dig cnn.com nslookup cnn.com nslookup doubleclick.com ipkg install cron crontab -e 0 0,4,8,12,16,18,20 * * * /usr/local/bin/update_bannerhosts ipkg install cherokee cp /etc/cherokee/cherokee.conf /etc/cherokee/cherokee-catch-all.conf echo "Include /etc/cherokee/catch-all.conf">>cherokee.conf echo '
Request ".*" { Handler redir {
Show Rewrite "/images/pixel.gif?"
}
}
Request "/images/pixel.gif.*" { Handler file } ' > /etc/cherokee/catch-all.conf cherokee -C /etc/cherokee/cherokee-catch-all.conf TODO: autostart cherokee add images/dummy.jpg mkdir -p /var/www/images update-rc.d scriptnaam start 4 stop 6 cp /etc/init.d/dnsmasq /etc/init.d/cherokee vi /etc/init.d/cherokee replace the first 5 lines with:
DAEMON=/usr/sbin/cherokee NAME=cherokee DESC="Cherokee webserver" ARGS="-C /etc/cherokee/cherokee-/etc/cherokee/cherokee-catch-all.conf" update-rc.d cherokee defaults December 22, 2006, at 05:58 PM
by --
Added lines 11-17:
Fire up OpenSlugFirst I unwrapped a new box, to get my new NSLU2 out of it. I just received my new Slug today, the third one. Of course, setting up OpenSlug was easy from the webinterface: turn slug on, attach my notebook and browse to http://192.168.1.77. From there I hit the Administration/Upgrade tqb and uploaded new firmware, openslug-3.10-beta.bin this time. After that just wait.... beep! and it is alive. Since openslug appears to use DHCP to get its ip address, I had to check my DHCP table (or ping to 192.168.1.255) to see where it went. It got 192.168.1.103 in my case, you might get a different address. December 22, 2006, at 05:51 PM
by -- Setup dns server and web server to catch and handle requests to ad servers
Added lines 1-10:
PurposeI wanted to not see those annoying flashing ad images on webpages, and also reduce internet bandwidth by not downloading those images. Not for me or others in my network. OverviewWhat I did was the following:
Details
view ·
edit ·
print ·
history ·
Last edited by mbellrao.
Based on work by Andrei Volkov and Jelle Alten. Originally by Jelle Alten. Page last modified on June 07, 2008, at 08:43 AM
|