HOWTO: Ad Blocking


If you're tired of getting bombarded by advertisements when surfing the web, there is a quick and easy way to block a good portion of them. The mechanism for this is your system's hosts file, in which you can override DNS lookups for the advertisement sites to effectively go to nowhere.


STEP 1: Locate the hosts File for Your Operating System

Linux
/etc/hosts
Windows 95/98/ME
<WINDOWS DIR>\hosts
Windows 2000/XP
<WINDOWS DIR>\SYSTEM32\DRIVERS\etc\hosts

If a hosts file does not yet exists, as will probably be the case with Windows 95/98/ME, you must create one.


STEP 2: Redirect Advertisement Hostnames to a Bogus Location

The format of the hosts file is simple. It is a plaintext file in which each line contains an IP address/hostname pair.

Here is a sample hosts file which blocks many adverstisement sites. You can simply append this to your hosts file. The key is to redirect each offending hostname to a machine that does not run a webserver. In this sample files, ad hosts are redirected to the local machine, but if it is running a webserver, you will want to change this to go to a machine that is not.


STEP 3: Mozilla Image Blocking

Step 2 will block all images and flash animations from the advertisement sites listed in the hosts files. However, you may still get those broken image icons in Mozilla where ad images were included in the page. To fix this, simple right-click on the image icon and click "Block Images from this Server" on the menu. When this is done, the broken image icons will be replace with cool, soothing white space on the web page.


STEP 4: More Hosts

As you discover new ad hosts, you can simply add them to the end of the hosts file.

Back
  Copyright (C) 2003  Adam P. Whitney