Introduction: Block Thousands of Ads With HOSTS

Picture of Block Thousands of Ads With HOSTS

In this instructable, I will show you an easy way to block nearly thousands of advertisements, in one simple, easy method.

Step 1: About Window's HOSTS File

Picture of About Window's HOSTS File

Before we start, it is important to understand exactly what the HOSTS file is.

The HOSTS file is a file with IP addresses, corresponding to a domain name, that windows references and bypasses DNS with.

For a more in-depth explanation, please visit Wikipedia's definition:
http://en.wikipedia.org/wiki/Hosts_file

Step 2: Download Replacement HOSTS File

Picture of Download Replacement HOSTS File

There are many replacement HOSTS file out there, so experiment and determine which one you like best. I personally use the MVPS malware prevention HOSTS file. It does fine for me.

The MVPS HOSTS file I've used is located here:
http://www.mvps.org/winhelp2002/hosts.txt

Simply save this file to your desktop, temporarily.
(Right-Click, Save Target/Link As..)

Step 3: Navigate to and Backup Default HOSTS File

Picture of Navigate to and Backup Default HOSTS File
Our next step is to find the HOSTS file on your computer.

Here are some of the default locations for the Windows HOSTS file from Wikipedia.

  • Linux and other Unix-like operating systems: /etc
  • Windows 95/98/Me: %windir%\
  • Windows NT/2000/XP/Vista: %SystemRoot%\system32\drivers\etc\ is the default location, which may be changed. The actual directory is determined by the Registry key \HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\DataBasePath .
  • Mac OS: System Folder:Preferences or System folder (format of the file may vary from Windows and Linux counterparts)
  • Mac OS X: /private/etc (uses BSD-style hosts file)
  • OS/2 and eComStation: "bootdrive":\mptn\etc\
  • Novell Netware: SYS:\ETC

If you can't find it, Start -> Search is always a good tool to use :).

Once you successfully navigate to the HOSTS file, rename is from "HOSTS" to "HOSTS.backup".
Doing this, you will always have a backup of your default HOSTS file if for some reason you want to revert to it.

Step 4: Copy New HOSTS File

Picture of Copy New HOSTS File

Next, copy and paste the "HOSTS.txt" file from you desktop to where your default HOSTS file was.
After the file is copied, rename it from "HOSTS.txt" to just "HOSTS".

NOTE: You maybe have to edit your folder settings to not "Hide extensions for known file types" by going to Tools -> Folder Options -> View -> Uncheck "Hide extensions for known file types".

Step 5: Finish!

Picture of Finish!

You have now replaced your HOSTS file!
Congratulations.

It may take a few minutes for the changes to become active. You may also have to close all internet browser windows.

Enjoy internet browsing with minimal ads!

Comments

purgedsoul (author)2006-08-18

If you are using firefox, get the Adblock extension. If you are using IE, get Firefox, then get Adblock.

Arbitror (author)purgedsoul2008-12-06

But the good thing about this, is that It works for ANY browser.
Not saying that firefox is bad...

zeero360 (author)purgedsoul2008-01-01

If you are using IE, get Firefox, then get Adblockhahahahaha, 1 problem i cant hahahahahahahahalol

zeero360 (author)zeero3602008-01-01

fyi im retarted not really but in a sence

Erik Andersen (author)purgedsoul2007-12-20

I can't agree more with Purgedsoul. I have Firefox (w/ Adblock Plus of course!) and it works like a charm. You might get the noscript extension too so you can visit sites that block Firefox (they don't like the ads bypassed!).

JWALLIS (author)2007-09-04

I am not an expert, so do correct me if I"m wrong.

Having a large host file can slow a PC down to a crawl.
Use Peerguardian instead ( without logging)


I do keep <10 entries in the host file for an absolute deny policy.

Sometimes, I'll be attacked: My DNS will be changed and Peerguardian (PG) blocks all connections. I examine the address PG is block and put it in my hosts file. If possible, try to remember the site that started everything and block that too.

So - my opinion: keep the hosts file small (unless maybe its on another (*nix ) machine)[proxy?]

Brett (author)JWALLIS2007-09-04

I agree 100% Back when I did this, i meant for it to be a quick & easy fix.

binnie (author)2007-02-09

should of known how to do that. it looks for .... and replaces it with 127.0.0.1 but, if you set apache up to broadcast on 127.0.0.1, does that mean your site will become the ad? yes think so

Brett (author)binnie2007-02-10

Yes. If you didn't want this to happen, you could always use spinach_dip 's suggestion: "try using 0.0.0.0 instead of 127.0.0.1"

RyanPotter (author)2006-08-16

Yeah, I learned how to do this a year or two ago, and it's nice that there's no ads, but the "This page can not be displayed" things all over can still be a bit annoying. This method is also great for pranking people! Just redirect one site to another... It'll really confuse people!

binnie (author)RyanPotter2007-02-09

set up a local server to display what ever you want!

zachninme (author)2006-09-24

I just block media.fastclick.com (and fastclick.com). Those are the only "intelligent" popups I run into. (The "intelligent" popups popup when you click on something, bypassing most popup blockers.)

JP (author)2006-08-23

You can do this easily with http://www.dnsredirector.com

Brett (author)2006-08-16

Also, if you have a DNS server that you have access to, you can add entries there instead of your hosts file, making the changes noticeable for your whole network, or whatever is connecting to your DNS server. Brett

rotor (author)2006-08-16

This will work, but has problems people should be aware of, as detailed here:

http://www.windowsdevcenter.com/pub/a/windows/2004/03/30/hosts.html

In particular, if you use firefox or opera, you'll be waiting a long time for all those connections to localhost to time out.

spinach_dip (author)rotor2006-08-16

try using 0.0.0.0 instead of 127.0.0.1

spinach_dip (author)2006-08-16

This is a good deal. I've actually switch to using Adblock + Filterset G updater + my own custom block list. I've done this because it's more flexible, and I can disable it instantly without a reboot or restart of my browser. However, I've started using the Hosts file again because of my stand alone Aggregator was, with all the ads, turning into an aggravator. It's just targeted a bit better.