Nerdrium Home

Macintosh

Linux

Web Design

Case Mods

Gardening

Photography

Recipes

 

My Blog

 

Facebook

Twitter

Block Web Site Ads

by Michael Greifenkamp (February 6th, 2006)

For the most part I don't mind ads on web sites--it's part of doing business (if I don't want to see them I can always just not go to a particular web site, right?). Well, this morning a particularly irritating ad on cnn.com was practically giving me a headache--zooming in and out and bouncing stuff around. Ick.

So I decided to make it go away. It's pretty simple, really.

First, I had to find the name of the server that was serving up the advertisements. By viewing the source in Safari I was able to determine that the server was ads.cnn.com. Now I just needed to make it look somewhere else.

That's where the "hosts" file comes in handy. Open a terminal window, log in as root, and navigate to the /etc directory. I like to use the vi editor, so to edit the hosts file I typed vi hosts. At the bottom of the file I inserted "127.0.0.1 ads.cnn.com." This tells the network daemon that the ad server lives on my local machine, so it doesn't have to look up its real IP address using DNS.

I restarted Safari, emptied the cache, and lo and behold--my next visit to cnn.com was ad free!

--Michael