Saturday, August 07, 2004

Making It Never Exist

Part two of that Slashdot article I mentioned before:

For some reason, this happens most frequently when I go to washingtonpost.com, but it happens on other sites, too. I click on an article, and get the message

Waiting for doubleclick.net

and then the web page hangs for awhile.

What's happening is that the Post is going to doubleclick.net and waiting for advertisements to load up. Of course, the net doesn't just go to doubleclick, it goes elsewhere as well. And many of those ``elsewheres'' are nothing but annoying ads.

Wouldn't it be great to get rid of those ads? OK, we can use something like Adblock, and I recommend that, but wouldn't it be wonderful to make your computer believe that places like doubleclick never existed? (And, incidentally, decrease worries about your privacy.) There is a way.

Let's go back to the early days of the Internet. There was nothing like the current Domain Name Service (DNS). Oh, each web site had an IP address, but there were no central directories to tell you which IP address belonged to Google (not that Google existed back then).

So how would you have found Google? In order to find things on the Internet, each computer had a file called /etc/hosts. (OK, each Unix-like computer had such a file. I have no idea what other OS called it.) In the /etc/hosts file was a line like:

216.239.41.104 www.google.com

which told your computer the IP address of Google. Of course, this file had to be upgraded periodically by downloading a new file from somewhere, and eventually it got so big that the whole thing had to be scrapped and DNS was adopted. But, the /etc/hosts file still exists, and it's read before your computer goes out to your chosen name server!

This is really quite useful. If you use Google a lot, for example, adding the line

216.239.41.104 www.google.com

to /etc/hosts saves you from having go to the DNS every time you want to do a search. And there's another use:

Near the top of /etc/hosts is a line like

127.0.0.1      localhost.localdomain localhost

This tells your computer where your local computer lives on your local network (even if you don't have a local network). If you try to go to localhost from your web browser, you'll get a message like

The connection was refused when attempting to contact localhost

(Unless you are running your own web server, in which case you'll get your home page.) In this case, localhost and localhost.localdomain function as aliases for the address 127.0.0.1. Any request to go to localhost takes you to 127.0.0.1, and does whatever you tell it to.

Now suppose the webpages you visit regularly connect you to a scuzzy site we'll call reallystupidads.com. You're tired of these ads and never want to see them again. What to do? Remember that /etc/hosts is read first, before the request goes out to the DNS. So add a line

127.0.0.1  reallystupidads.com

to /etc/hosts. Now, when that page you are interested in asks reallystupidads.com send some advertisements, your computer looks up the address, finds that it is 127.0.0.1, and does whatever you've set it up to do. If you don't run your own web server, it does nothing. It's as if that site never existed.

So, what you need is a list of really annoying sites that should be banned from your computer. Of course, this being the Internet, there are many such lists. The one I'm using is Mike Skallas' Ad Blocking Hosts file. Basically, you add it to /etc/hosts. And, frabjous day, there are instructions for doing the same thing in Windows 2000 and XP.

And, of course, once you know the trick, you can add your own annoying sites to the list. Parents can add sites that they want to keep their children out of, e.g.

Hopefully no one will add

127.0.0.1 hawknotes.blogspot.com

0 comments: