about me





Eradicating doubleclick.net from the planet

crush, kill, destroy, annihilate, overwhelm, bury


January 8th, 2002: mission complete ! (but the war is not over)

November 25th, 2000: page creation


Advertising networks like doubleclick.net are evil. They are spammers, they track private information, and they are a spectacular waste of bandwidth.

This page is my contribution to the crusade against these advertisers the Internet doesn’t need. I will explain what every self-respecting BOFH can do to spare bandwidth and get rid of doubleclick.

Technical overview

The best way to get rid of doubleclick is to ignore them.

The first idea would be to firewall their IPs. The problem is that they have numerous webservers around the world, and that there may add new servers, or change their IPs, or there may be other websites on their servers. So, the idea is to intercept the ad.doubleclick.net DNS by configuring your local nameservers, and make it point to something else. is the first idea, but the problem with this is that it prevents the image to load at all, and some pages may render very badly. My idea is to replace the image with a custom one.

The goal of my method is to be set up on a WAN or LAN with public addressing, in a place where you can’t force users to use a proxy. If you have private addressing, it is likely you have a proxy and you can use stuff like JunkBuster.

Setting up the DNS servers

We will add a new zone for each DNS name we want to block, because it’ll let us use the same zone file. Ugly, but effective.

I added the following lines to named.conf on my primary nameserver (feel free to add new hosts if you find other evil advertisers):

zone "ad.doubleclick.net" { type master; file "pub"; };
zone "ad.fr.doubleclick.net" { type master; file "pub"; };
zone "m.doubleclick.net" { type master; file "pub"; };
zone "pubs.mgn.net" { type master; file "pub"; };
zone "lnads.osdn.com" { type master; file "pub"; };
zone "ads.freshmeat.net" { type master; file "pub"; };
zone "pub.nomade.fr" { type master; file "pub"; };
zone "pub.libertysurf.fr" { type master; file "pub"; };

And this is my custom zone I put in the pub file:

@ IN SOA ns1.mydomain.com. hostmaster.mydomain.com.
    ( 2000102007 21600 3600 3600000 86400)

  IN NS ns1.mydomain.com.
  IN NS ns2.mydomain.com.
  IN A

Replace ns1.mydomain.com and ns2.mydomain.com with your nameservers, and with the IP of the webserver which will serve the requests.

And finally, this is what I put on the secondary nameservers:

zone "ad.doubleclick.net"    { type slave; masters {; }; };
zone "ad.fr.doubleclick.net" { type slave; masters {; }; };
zone "m.doubleclick.net"     { type slave; masters {; }; };
zone "pubs.mgn.net"          { type slave; masters {; }; };
zone "lnads.osdn.com"        { type slave; masters {; }; };
zone "ads.freshmeat.net"     { type slave; masters {; }; };
zone "pub.nomade.fr"         { type slave; masters {; }; };
zone "pub.libertysurf.fr"    { type slave; masters {; }; };

Again, replace with your primary nameserver’s IP address.

All these operations may be easily scripted so that adding a new host becomes trivial. I leave this as an exercise to the reader.

Setting up the web server

I use several Apache features: mod_rewrite, PHP, and the GD library module for PHP.

This is what I put in httpd.conf (the important stuff is the Rewrite rule and the ServerAlias):

<VirtualHost ad.doubleclick.net>
  ServerAdmin admin
  DocumentRoot /opt/www/pub/
  <Directory /opt/www/pub/>
    RewriteEngine on
    RewriteRule !pub.php /pub.php [L]
  ServerName ad.doubleclick.net
  ServerAlias ad.fr.doubleclick.net pubs.mgn.net
      m.doubleclick.net lnads.osdn.com ads.freshmeat.net
      pub.nomade.fr pub.libertysurf.fr
  ErrorLog /var/log/apache/pub/error.log
  CustomLog /var/log/apache/pub/access.log combined

Make sure that mod_rewrite is activated, and that .php files are parsed as PHP. You can then download pub.php (view the coloured source online) and fnt.ttf (or use any other TrueType font) and put them in /opt/www/pub/. Edit pub.php to suit your needs: there are some custom messages at the bottom.


The php program will generate a GIF image of the right size, unless it finds a file called pub[X]x[Y].jpeg in /opt/www/pub/. The most common ad size is 468x60, so you might want to create at least a pub468x60.jpeg to spare some CPU cycles. I made this one, for instance:

Pub zappée


The day after I set up this system, the computers on my network made 7500 hits to it, which spared aprox. 100MB of bandwidth (on a Saturday!). This will probably become a lot more during the week.