A magic file exists in virtually all Operating Systems (OSs) that allows you to control how network addresses are handled. As all networking geeks know, this file is the hosts file. This magic file offers you the ability to get rid of unsightly, annoying ads and banners. You can even use it to protect yourself from most major parasites, hijackers and unwanted Adware/Spyware programs. All of this without the additional overhead of a browser extension or computer program. Plus, your web pages should load faster since your not wasting precious bandwidth downloading ads!

Think of the hosts file as the first place your computer looks to determine what IP Address a domain name (i.e., website address) should take you to. If a domain name is not assigned to an address in your hosts file, then your computer uses the Domain Name System (DNS) on the Internet to determine what IP address is assigned to the domain. If the first DNS your computer asks doesn’t know, it will keep moving to higher level DNSs until it finds a name server that knows the address or determines the domain address is invalid.

The details of DNS are a bit complicated and not necessary to reap the benefits of this tutorial. One of the best short explanations I’ve read came from Wikipedia which compared to the domain name system to a phone book.

I know you’re saying “So what, how does this help me get rid of annoying web ads?” Well, you can use the hosts file to trick your system routing the website addresses (i.e., domain names) of the big advertising provider sites to a blank page. This works because your computer doesn’t go to the web DNSs if it first finds a match on your computer in the hosts file. All you need to do is add entries to your hosts file pointing sites like doubleclick.com to 127.0.0.1.

Why 127.0.0.1? Well, as all of you web gurus know 127.0.0.1 is the IP Address of your local machine (i.e., the one you’re sitting at). It is used by all computers to point back to itself. You may have heard it referred to as localhost. Now you know what all of those t-shirts that say “There’s no place like 127.0.0.1″ mean.

I can’t expect you to know all of the advertising sites to put in the hosts file. Even if you did, it would take ages to type them all in. Lucky for us, the guys over at MVPS.org from compiling and constantly updating a host file with the addresses of most advertisers. You simply need to download their host file and replace your existing one with it. I find it just as easy view their host file in your browser as a text document and then copy and paste the info into your own host file (open it with notepad or a similar program if your computer asks).

So now you know what you need to do, I should probably tell you where to find this elusive hosts file.

  • Windows XP: C:\WINDOWS\system32\drivers\etc\
  • Mac OS X: /private/etc/
  • Ubuntu (and most Linux/Unix distros): /etc/

Before replacing it or messing with any kind of system setting file on your computer, I recommend creating a backup of the original. One other word of warning, you could have potential conflicts if you’re running a web server on your home computer. If that is the case, I recommend you substitute 127.0.0.1 with 0.0.0.0 for all the advertising sites.

The only downside to this method is you see the ugly broken link page in place of the ads.

For other useful tricks related to the hosts file, I recommend starting at the Wikipedia Hosts article. For an entertaining and information look at the hosts file listen to or read Episode 45 of Security Now, the ‘Hosts’ File which was the original inspiration for this post. Good luck and happy surfing…


5 Responses to “Browse the Web Ad Free…no plugins required!!!”  

  1. 1 Yannick

    While I was reading through I was going to ask what about those who are running a web server since 127.0.0.1 is localhost, but then you answered that question near the end. hehe. Very interesting tip Matt. I’ve never fooled around with the ‘Hosts’ file before. While I’m not that bothered by adverts, I’m sure others will find this useful. At least I can say I learnt something new today. :P

  2. 2 JoAnne

    Monday, July 30 2007, @ 9:41 AM (-0800 GMT)

    Hi!

    For everything in the world you EVER wanted to know about Hosts Files AND “freebies,” visit my web at http://www.hostsfile.info

    Also, there is a Message Board where you can ask questions or leave notes to help others.

  3. 3 Matt

    Yannick, I’m glad you were able to learn something new today. The Hosts file is a neat trick that I didn’t think too many people knew about. Knowing that I had a lot of web development gurus such as yourself, I had to make sure I addressed what to do if you happened to be running your own web server.

    One other neat thing the Hosts file allows you to do is assign domain names to other machines on your local network. Just add the name you want for each IP.

    JoAnne, thanks for sharing the link.

  4. 4 JoAnne

    Tuesday, July 31 2007, @ 9:59 AM (-0800 GMT)

    Hi Matt,

    You’re welcome! I put the site up a year ago because I could find not one really “thorough source,” at that time. I put many different things, except maybe a few, like what you mention about “assigning names to local machines,” on the site, to help people.

    I also think, that after a year of searching, I now have listed “all active Hosts Files in the known world, from the Pillars of Hercules, to the far side of the world.”

  5. 5 Matt

    JoAnne its definetly a good idea to fill in the need for a “thorough source.” One thing I was surprised about on your site is the low rating given to the MVPS host file which is the one I happened to select for my tutorial. Could you please share some insight about what makes one hosts file better than another?

Leave a Reply




Subscribe


Categories

Social Bookmarking

Keeping the Lights On