NSLU2-Linux
view · edit · print · history

HowTo.CatchRequestsToAdServers History

Hide minor edits - Show changes to markup

June 07, 2008, at 08:43 AM by mbellrao --
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 Andrei Volkov --
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 Andrei Volkov --
Changed lines 74-76 from:

chmod 644 /etc/banner_add_hosts chmod 644 /etc/banner_add_hosts.manual

to:

chmod 644 /etc/banner_add_hosts
chmod 644 /etc/banner_add_hosts.manual

November 10, 2007, at 04:07 AM by Andrei Volkov -- Added note about setting proper permissions on banner_add_hosts files
Added lines 67-69:

echo "">/etc/banner_add_hosts

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.
Set the permissions to allow dnsmasq to read those files:
chmod 644 /etc/banner_add_hosts chmod 644 /etc/banner_add_hosts.manual

January 01, 2007, at 02:44 PM by Jelle Alten -- restart of dnsmasq in updatebannerhosts
Changed lines 115-118 from:
  1. not used for dnsmasq
  1. reloadcmd='/etc/init.d/squid reload'
to:
  1. not sure if we need this for dnsmasq

reloadcmd='/etc/init.d/dnsmasq restart'

Changed lines 150-151 from:
  1. restart dnsmasq? (probably not needed)
  2. $reloadcmd
to:
  1. restart dnsmasq (probably not needed)

$reloadcmd

December 27, 2006, at 08:20 AM by Jelle Alten --
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 Jelle Alten -- 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 Jelle Alten --
Changed lines 68-69 from:

mkdir -p /usr/local/bin'

to:

mkdir -p /usr/local/bin

Changed lines 128-131 from:

echo "" echo "fetch: $fetchcmd" echo ""

to:
December 27, 2006, at 07:20 AM by Jelle Alten --
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 Jelle Alten -- 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 Jelle Alten -- 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 Jelle Alten -- 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 Jelle Alten -- 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 Jelle Alten -- 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 Jelle Alten --
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!
Check to see if all wanted processes are running using ps.

December 23, 2006, at 12:32 PM by Jelle Alten --
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:
 [=
  1. !/bin/sh
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:
 [=
  1. !/bin/sh
December 23, 2006, at 12:30 PM by Jelle Alten --
Changed line 22 from:

[=

to:
 [=
December 23, 2006, at 12:30 PM by Jelle Alten -- splitting lines
Changed lines 22-23 from:

[=turnup init

to:

[= turnup init

December 23, 2006, at 10:32 AM by Jelle Alten --
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:
 [=
  1. !/bin/sh
to:

[=#!/bin/sh

December 23, 2006, at 10:30 AM by Jelle Alten --
Changed lines 75-77 from:
 [=
  1. !/bin/sh
to:
 [=#!/bin/sh
December 23, 2006, at 10:24 AM by Jelle Alten --
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.
Of course, setting up OpenSlug was easy from the webinterface: turn slug on, attach my notebook and browse to http://192.168.1.77. \\

Added line 16:
Changed lines 207-209 from:

mkdir -p /var/www/images wget -O /var/www/images/pixel.gif http://www.loremipsum.net/pixelgif/pics/pixel.gif

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 Jelle Alten --
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 dig doubleclick.com dig cnn.com nslookup cnn.com

to:

test it by using
dig doubleclick.com
dig cnn.com
nslookup cnn.com\\

December 23, 2006, at 10:19 AM by Jelle Alten -- Wrapping up
Deleted lines 0-1:

under construction

Added line 37:

Set up DNS

Added line 62:

Retrieve the list of ad servers

Deleted lines 71-72:
Deleted lines 74-142:

=] (:tableend:)

Of course, this script needs to be executable: chmod 700 /usr/local/bin/update_bannerhosts

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 dig doubleclick.com dig cnn.com nslookup cnn.com nslookup doubleclick.com

It should point to the new slug now.

Now we have the script run automatically every 4 hours, using cron:
ipkg install cron

Edit the cront tab using
crontab -e

and add the line
0 0,4,8,12,16,18,20 * * * /usr/local/bin/update_bannerhosts

(: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:
mkdir -p /var/www/images wget -O /var/www/images/pixel.gif http://www.loremipsum.net/pixelgif/pics/pixel.gif

You can start Cherokee by entering
cherokee

But you probably want to autostart Cherokee at boot time. To do so, borrow the start up script from dnsmasq:
cp /etc/init.d/dnsmasq /etc/init.d/cherokee
vi /etc/init.d/cherokee
Replace the first 5 lines with: (:table border=0 width=100% bgcolor=#eeeeff:) (:cell:)

 [=
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:
  1. short script that downloads a list of ad servers for use with
  2. squid to block ads.
  3. details on configuring squid itself can be found here:
  4. http://pgl.yoyo.org/adservers/#withsquid
  5. - originally by Stephen Patterson <steve@lexx.uklinux.net>
  6. - butchered by Peter Lowe <pgl@yoyo.org>
  7. - altered by Jelle Alten (hotmailaddres:jpalten) to suit his needs on OpenSlug
  1. set things
  1. the ipaddress where we want to send the requests to, instead of the bannerservers

addcatcherip='172.16.16.60'

  1. the args to add to the request to the yoyo server, to tell it that we want
  2. a hosts file and that we want to redirect to the addcatcher

listurlargs="hostformat=hosts&showintro=1&mimetype=plaintext&useip=$addcatcherip"

  1. URL of the ad server list to download

listurl="http://pgl.yoyo.org/adservers/serverlist.php?$listurlargs"

  1. location of the list of ad servers used by dnsmasq

targetfile='/etc/banner_add_hosts'

  1. location of a file where hostnames not listed can be added

extrasfile='/etc/banner_add_hosts.manual'

  1. command to reload squid - change according to your system
  2. not used for dnsmasq
  1. reloadcmd='/etc/init.d/squid reload'
  2. temp file to use

tmpfile="/tmp/.adlist.$$"

  1. command to fetch the list (alternatives commented out)

fetchcmd="/usr/bin/wget -q -O $tmpfile $listurl"

  1. do things

echo "" echo "fetch: $fetchcmd" echo ""

  1. get a fresh list of ad server addresses for dnsmasq to refuse

$fetchcmd

  1. add the extras

[ -f "$extrasfile" ] && cat $extrasfile >> $tmpfile

  1. check the temp file exists OK before overwriting the existing list

if [ ! -s $tmpfile ] then

	echo "temp file '$tmpfile' either doesn't exist or is empty; quitting"
	exit

fi

  1. sort and filter out duplicates

sort $tmpfile > $targetfile

  1. clean up

rm $tmpfile

  1. restart dnsmasq? (probably not needed)
  2. $reloadcmd
Added lines 154-227:

Of course, this script needs to be executable: chmod 700 /usr/local/bin/update_bannerhosts

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 dig doubleclick.com dig cnn.com nslookup cnn.com nslookup doubleclick.com

It should point to the new slug now.

Auto-update the list

Now we have the script run automatically every 4 hours, using cron:
ipkg install cron

Edit the cront tab using
crontab -e

and add the line
0 0,4,8,12,16,18,20 * * * /usr/local/bin/update_bannerhosts

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:
mkdir -p /var/www/images wget -O /var/www/images/pixel.gif http://www.loremipsum.net/pixelgif/pics/pixel.gif

You can start Cherokee by entering
cherokee

But you probably want to autostart Cherokee at boot time. To do so, borrow the start up script from dnsmasq:
cp /etc/init.d/dnsmasq /etc/init.d/cherokee
vi /etc/init.d/cherokee
Replace the first 5 lines with: (:table border=0 width=100% bgcolor=#eeeeff:) (:cell:)

 
#!/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 Jelle Alten --
Changed lines 8-11 from:
  1. I set up a dns server, using dnsmasq, to redirect all request to ad servers (like doubleclick) to a local webserver
  2. I set up a cron script to update the list of ad servers
  3. I set up a cherokee webserver to handle all requests and return an one by one transparent gif pixel
to:
  1. I set up a dns server, using dnsmasq, to redirect all requests to ad servers (like doubleclick) to a local server
  2. I set up a cron script to update the list of ad servers every four hours
  3. I set up a Cherokee webserver to handle all requests and return a one by one transparent gif pixel
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

  1. turnup init

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

  1. umount /dev/sda1
  2. mkfs.ext3 /dev/sda1
  3. turnup memstick -i /dev/sda1
  4. reboot
  5. date [MMDDhhmm?[[CC]YY]
to:

turnup init

umount /dev/sda1 mkfs.ext3 /dev/sda1

turnup memstick -i /dev/sda1

reboot

date [MMDDhhmm?[[CC]YY]

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 server

to:

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 usr/local/bin directory to put our local scripts:\\

to:

Also create the usr/local/bin directory to put our local scripts in:\\

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 Jelle Alten --
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:
mkdir -p /var/www/images wget -O /var/www/images/pixel.gif http://www.loremipsum.net/pixelgif/pics/pixel.gif

You can start Cherokee by entering
cherokee

But you probably want to autostart Cherokee at boot time. To do so, borrow the start up script from dnsmasq:
cp /etc/init.d/dnsmasq /etc/init.d/cherokee
vi /etc/init.d/cherokee
Replace the first 5 lines with: (:table border=0 width=100% bgcolor=#eeeeff:) (:cell:)

 [=
Changed lines 176-181 from:

update-rc.d cherokee defaults

to:

=] (:tableend:)

To install the autostart script, do:
update-rc.d cherokee defaults

Now reboot the slug and see it catch the ads!

December 23, 2006, at 09:36 AM by Jelle Alten --
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 usr/local/bin directory to put our local scripts:

to:

Also create the usr/local/bin directory to put our local scripts:\\

December 23, 2006, at 09:34 AM by Jelle Alten --
Changed lines 97-99 from:

TODO: add the script here

to:
December 22, 2006, at 10:53 PM by Jelle Alten --
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 server

I 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:
  1. add my own servers to the hosts file
Changed lines 67-69 from:

/etc/dnsmasq:

to:
  1. make a very simple /etc/dnsmasq:
Changed lines 97-99 from:
to:

TODO: add the script here

Changed lines 108-115 from:
  1. echo "/usr/bin/wget -O /etc/banner_add_hosts 'http://pgl.yoyo.org/adservers/serverlist.php?hostformat=hosts&showintro=1&startdate%5Bday%5D=&startdate%5Bmonth%5D=&startdate%5Byear%5D=&mimetype=plaintext&useip=172.31.101.11'" >> /usr/local/bin/update_bannerhosts
  2. echo "cat /etc/banner_add_hosts.manual >> /etc/banner_add_hosts" >> /usr/local/bin/update_bannerhosts

chmod 700 /usr/local/bin/update_bannerhosts

to:

Of course, this script needs to be executable: chmod 700 /usr/local/bin/update_bannerhosts

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:

dig doubleclick.com dig cnn.com nslookup cnn.com nslookup doubleclick.com

It should point to the new slug now.

Now we have the script run automatically every 4 hours, using cron:

ipkg install cron Edit the cront tab using crontab -e

and add the line 0 0,4,8,12,16,18,20 * * * /usr/local/bin/update_bannerhosts

(: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 Jelle Alten --
Added lines 1-2:

under construction

December 22, 2006, at 09:02 PM by Jelle Alten --
Changed lines 23-24 from:

ssh root@192.168.1.103

to:

ssh root@192.168.1.103

Changed lines 45-47 from:

date [MMDDhhmm?[[CC]YY]

to:
  1. date [MMDDhhmm?[[CC]YY]
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: echo "">/etc/banner_add_hosts.manual

Also create the usr/local/bin directory to put our local scripts: mkdir -p /usr/local/bin'

Now create a script that will fetch the list of adservers:

/usr/local/bin/update_bannerhosts

(:table border=0 width=100% bgcolor=#eeeeff:) (:cell:)

 



(:tableend:)

December 22, 2006, at 08:50 PM by Jelle Alten --
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 Jelle Alten --
Changed lines 19-21 from:
 [=

ssh root@192.168.1.103

to:

ssh root@192.168.1.103

December 22, 2006, at 08:08 PM by Jelle Alten --
Added lines 18-160:

To get OpenSlug going, I used:

 [=

ssh root@192.168.1.103

  1. turnup init

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

  1. umount /dev/sda1
  2. mkfs.ext3 /dev/sda1
  3. turnup memstick -i /dev/sda1
  4. reboot

date [MMDDhhmm?[[CC]YY]

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

  1. echo "/usr/bin/wget -O /etc/banner_add_hosts 'http://pgl.yoyo.org/adservers/serverlist.php?hostformat=hosts&showintro=1&startdate%5Bday%5D=&startdate%5Bmonth%5D=&startdate%5Byear%5D=&mimetype=plaintext&useip=172.31.101.11'" >> /usr/local/bin/update_bannerhosts
  2. echo "cat /etc/banner_add_hosts.manual >> /etc/banner_add_hosts" >> /usr/local/bin/update_bannerhosts

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 '

  1. rewrite all requests to serve /images/pixel.gif
  2. with the original request as argument behind a "?"

Request ".*" {

    Handler redir {                                                                          
        Show Rewrite "/images/pixel.gif?"                                                         
    }                                                                                        

}

  1. this request will only return a file
  2. since it is lower than the request above, it will be handled first

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:

  1. !/bin/sh

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 Jelle Alten --
Added lines 11-17:

Fire up OpenSlug

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. 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 Jelle Alten -- Setup dns server and web server to catch and handle requests to ad servers
Added lines 1-10:

Purpose

I 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.

Overview

What I did was the following:

  1. I set up a dns server, using dnsmasq, to redirect all request to ad servers (like doubleclick) to a local webserver
  2. I set up a cron script to update the list of ad servers
  3. I set up a cherokee webserver to handle all requests and return an one by one transparent gif pixel

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