I use a custom version of the thttpd daemon on my Freesco box to solve an aesthetic problem I have when browsing web pages. I use another GNU/Linux-based machine as my default gateway, and all DNS lookups are served through it. I have a hosts file on this gateway generated by this site and this site which resolves many ad servers to incorrect IP addresses. This saves bandwidth and avoids downloading many adverts - although never 100%. Where adverts are supposed to be embedded in another webpage, the connections time out and the timeout messages are inlaid in the page. This doesn't look very nice, so I have customised a version of thttpd, and inserted it into a Freesco 0.2.7 RAMDISK image, which you can download here.
I then tweaked the hosts file on the gateway machine to use the IP address of my Freesco box, rather than the loopback IP address of 127.0.0.1 or other invalid address. When a page with a “banned” advert is loaded, the default gateway looks to my Freesco box to serve the advert. Through the use of customised error pages, a nice plain colour is inserted into the page instead, like this.

A Ramdisk is (in this case) a compacted image of a root file system, containing files and executables. It is expanded into RAM on boot, hence the name.

This particular Ramdisk contains the files necessary to run the Freesco 0.2.7 router with an additional feature designed to replace adverts in a web page with an html page of your choice. (The suggestion is an empty page of light background colour.)

Format the hard disk with a FAT16 filesystem, and install a MS-DOS-like operating system. I use MS-DOS 6 underneath my Freesco system, so that is the example that this page will use. However, people have reported that PC-DOS and Free-DOS work with Freesco running on top.

Instead of generating a file with 127.0.0.1 or 0.0.0.0 use the dialog box to generate one with the IP address of your Freesco 0.2.7-adblock box. For example:

192.168.0.100 iservelotsofadverts.com

You should use the local IP address of the Freesco box regardless of whether or not it is also being used as the primary DNS relay for the network. This is because the IP addresses listed in the hosts file are passed back to the client machines unchanged following a DNS lookup request. Therefore, if 127.0.0.1 was used, clients would attempt to use their own loopback interfaces rather than the Freesco box.

Check the current hosts file on the primary DNS relay for existing name resolutions. As my primary DNS relay is linux-based, I check the file /etc/hosts.

Copy any existing name resolutions from the existing hosts file into your new file unchanged.

Place the hosts file containing the adserver list in the appropriate place on your primary DNS relay. For example, I copy the new hosts file over the existing /etc/hosts file.

Ensure that the system on which your primary DNS relay resides uses itself as a nameserver, and uses the hosts file before requesting a DNS lookup from a remote server.

In practice this means that /etc/resolv.conf should contain the line:

nameserver 127.0.0.1

before any other nameserver IP addresses and that /etc/host.conf should contain the line:

order hosts,bind

Ensure that your DNS relay daemon is setup to use the host system as its primary DNS server, followed by its “regular” DNS server as its secondary DNS server.

As my primary DNS relay is part of a firewall based GNU/Linux distribution, there is a simple menu to set this up. How you do this on your system will very much depend on the software you are running.

You can test that your setup is correct by using a resolving tool like nslookup under linux or Dreamsys Advanced Net Tools under Windows on a DNS client system.

First attempt to resolve a domain name that isn't listed in the adserver hosts file, eg: www.amazon.com. The example given should resolve to an IP address of 207.171.181.16.

Next attempt to resolve a domain name that is listed in the adserver's hosts file, eg: about.com. It should resolve to the IP address of your Freesco box.