(first instructable - let me know what you think... but be nice!)
If you are like me, while browsing the net, you've come across thousands of banner ads. Generally, I am the type of person, that if I want to buy something, I'll google it, find it, and purchase it. I rarely if ever actually pay attention to those annoying bandwidth wasting banners that appear on almost every site.
I don't care that I'm the 1,000,000th visitor to a particular domain, especially since I was the 1,000,000th visitor to the same domain, just yesterday! I don't want to buy generic Viughra, and I don't need to enlarge my hoohah.
Come on, there has got to be an easy way to prevent this garbage from hitting my computer.
There is! And it is surprisingly simple to do - and it's free!
Step 1: The HOSTS File.
This is accomplished by using the HOSTS file. The HOSTS file contains the mappings of IP Addresses to host names. The file is loaded at Windows Startup, and Windows checks the HOSTS file BEFORE it looks to your ISP to find the site. Editing the HOSTS file prevents access to the outside sites by redirecting traffic back to your own computer.
* It can block applications (viruses, trojans, downloaders) from accessing specific sites, by redirecting any (would be) outgoing communication back to your own computer, preventing it from accessing whatever material it was trying to get.
* It also blocks the ad servers from tracking your movements - in many cases the banner ad would open a separate connection to your computer, which is active even after you leave the banner's page. This connection reports all the cookies you send, even to other unrelated sites. Yikes!
* It can speed the loading of pages, by skipping the animated GIF files, hit counters, annoying ads, and can block data miners from ever seeing your IP address, and tracking you on the net.
Please note: While this is a simple treatment, this is NOT the final cure. Think of this as another level of protection, but not an independent cure.
Also note: If you have a virus, this will NOT fix your problem. Get an antivirus program, and keep it updated. I use Kaspersky Antivirus, they have a 30 day trial before you buy. I'm not here to sell anything for anyone, but find a reputable antivirus company, and keep your virus definitions UPDATED. New malware comes out hourly... literally.
However, if you HAVE a virus, like a trojan, it will keep connecting to the trojan's site and downloading copies of itself (or other malware programs) to your computer, like the www.WINANTIVIRUSPRO.com trojan downloader (or www.DRIVECLEANER.com) that pops up and falsely states that your computer is infected (it is, but it is the actual virus that is causing the pop-ups), and tries to get you to buy their software to remove it (it won't), you can use the HOSTS file to block the website that the trojan downloads from. Adding this address to the HOSTS file can help keep the trojan from reinstalling after your REAL antivirus removes it. The HOSTS file will cut it's communications, and the antivirus will kill it off. So even though this won't FIX the virus, it can stop its spread, and help avoid the next one!
Step 2: So How Do You Edit This File?
First off, the HOSTS file can be edited in Notepad, a simple text editor. If you have WinXP versions, to open the file, go to your Start Menu, select Run and enter (copy and paste this, without quotes)
" %windir%\NOTEPAD.EXE C:\WINDOWS\SYSTEM32\DRIVERS\etc\HOSTS "
This will cause the HOSTS file to be opened in Notepad.
Depending on your OS, you will need to edit the directories to find the file. Note: the HOSTS file does not have an extension. It is just labeled HOSTS.
Windows Vista = C:\WINDOWS\SYSTEM32\DRIVERS\ETC\HOSTS
Windows XP = C:\WINDOWS\SYSTEM32\DRIVERS\ETC\HOSTS
Windows 2K = C:\WINNT\SYSTEM32\DRIVERS\ETC\HOSTS
Win 98/ME = C:\WINDOWS\HOSTS
Note: If you want to make this easier for the next time, make a shortcut that points towards the right file. To do this, right click on the desktop, select NEW, then Shortcut. copy and paste the entire " %windir%\NOTEPAD.EXE C:\WINDOWS\SYSTEM32\DRIVERS\etc\HOSTS " into the field for Location of the item. This will give you very easy access for the future.
Before you do any editing, it is a good idea to backup what is in the file. Try saving it as HOSTS.bak or similar. Remember, the HOSTS file itself HAS NO FILE EXTENSION. Saving the HOSTS file with any .TXT, .DOC, etc will not let it work.
Additionally, if your antivirus software is worth it's salt, you should get a security prompt any time you save the HOSTS file. If you were editing it, then go ahead and allow the change. HOWEVER, IF YOU SEE THIS PROMPT ANY OTHER TIME, INVESTIGATE WHY IT OCCURS. SOME VIRUSES ALTER YOUR HOSTS FILE TO STEER TRAFFIC TO THEIR SITES.
Step 3: Ok, So You Have the HOSTS File Open, Now What Should Go in It?
Chances are, it will be empty, or only have one entry. It will likely appear like this: (see pic)
The entry 127.0.0.1 is what is known as a local IP address. It tells your computer that the resource is available on your own computer, and it doesn't need to connect to the internet to access it.
Essentially, the HOSTS file is a simple list of web sites, and where to find them. For example, when you type in the website "www.Yahoo.com", your ISP actually connects you to the domain 22.214.171.124.
www.Google.com = 126.96.36.199
www.ebay.com = 188.8.131.52, etc. etc.
Generally, you don't need to know any of these actual addresses, since your ISP's DNS server will translate them for you, but if you wanted to prevent access to a specific site, you could edit the HOSTS file to redirect that traffic elsewhere.
If, for some reason, you wanted to block access to a site, you make an entry like this:
This forces the computer to connect back to itself, and you cannot access any of these sites (after a reboot).
So how do we block ads? See the next step.
Step 4: So How Does This Block Ads? See This for an Example.
This Yahoo page shows how it would look originally. By right clicking on the ad, and selecting Properties, I can see the domain from which the ad came. See pic.
Copy the domain name (not the entire ad address), and enter it into your HOSTS file like this.
127.0.0.1 ads.yimg.com # This is the actual ad server
Now, once you restart, that particular ad server will be blocked, and you will see a page that looks like the page below.
Now, as a quick note, there are thousands of ad servers, the numbers of which are added daily. You will never be able to redirect ALL of them, but see the next step for a quick way to add thousands of sites at once.
Note: Flash ads! - If you right click and see this:
(insert flash ad pic)
You are dealing with a flash ad site. Currently, this method doesn't block them (yet). If you happen to know a way to kill them too, let me know, and I'll add it here. Thanks!
Step 5: Bulk Additions
No one wants to have to right click on each ad and select the ad server, but now that you have a basic grasp on how the HOSTS file works, lets do some bulk importing. There are a plethora of sites where you can download HOSTS file entries, I'll link to them on the last page.
There are some sites that allow you to download a Batch or Zip file, that will install the entries for you, but I am personally a bit leery of running anything I dredge up on the internet. I imagine a lot are as advertised, but I prefer taking the barely longer step of copy and pasting into the file.
Some will just have the entry and domain name, some include comments on WHY it is blocked. When I add my own entries, I try to follow this same idea, so that if I need to remove a site later, I can see why I added it to begin with.
--- Hosts file excerpt from http://www.mvps.org/winhelp2002/
127.0.0.1 www.aaa-livedoor.net #[Trojan-PSW.Win32.Maran.ei]
127.0.0.1 www.abcsearcher.com #[Spamdexing][Microsoft.Strider]
127.0.0.1 abc-search.info 127.0.0.1 abloga.info #[Spamdexing]
127.0.0.1 www.abx4.com #[Adware.ABXToolbar]
127.0.0.1 acezip.net #[SiteAdvisor.acezip.net]
127.0.0.1 www.acezip.net #[Win32/Adware.180Solutions]
127.0.0.1 host1.adhese.be #[Adhese Datamine Tag]
127.0.0.1 serv.ad-rotator.com #[SpySweeper.Spy.Cookie]
Step 6: Links to Bulk Lists.
That is just about it! Once you add the entries, save the HOSTS file, and reboot. You should see a difference right away!
I have been doing this for years, and love it. I see very few ads, and it greatly improves page download times. It also greatly improves my mood, as I no longer have to guess which ugly girl is Britney Spears, or what Jessica Simpson uses to avoid zits.
One part I'm still working on, is disabling JAVA or FLASH ads. These ads have a different loading method, and I haven't seen a great method for blocking them - Yet. (Anyone out there who knows how, drop me a line, and I'll add it to the instructable - Thanks!)
Below are some links to HOSTS related sites, where you can read more about the Hosts file and download the actual entries. I am not associated with ANY of them, but they all appear benign. Use your best judgement. If you can't, then it's time you turn off the computer anyways.
Mike's Ad Blocking Hosts File
WinHelp's Hosts Page
Direct Link to WinHelp's Hosts TEXT file
Digg.Com - One Host File to Rule Them All
Wikipedia - Hosts Files
As an afterthought, if you run into trouble trying to access a specific site after you add entries, go to the HOSTS file, and press CTRL-F to search for that particular domain. Some sites (www.mlive.com, Michigan newspaper site) requires a cookie to browse it, and may deny entry to the site if it couldn't "see" the cookie. If you find this to be the case, then try putting a # sign in front of the address, like this
This will disable this entry. Reboot, try again, and see if that doesn't fix the problem.
That's it for the official Instructable!
For an extra step, to have some fun with your family or friends, see the next page...
Step 7: HOSTS Related Prank - Redirect and Block a WANTED Site.
As a second afterthought, you can also create a lot of mayhem with this file. I don't recommend this on a work computer, but if you have a family member who adores a particular site, and spends way to much time there, you can redirect that site to another spot.
Simply entering the 127.0.0.1 www.detroitlions.com
will cause the "THIS PAGE CAN NOT BE DISPLAYED" error. Wouldn't it be more fun to change it to something off the wall? How do we do this?
Let's say that your spouse is a dedicated Detroit Lions fan. Ok, not many of them left, but we'll roll with it anyways (hah). Find the site that they would view the most, for example:
www.detroitlions.com and switch it out for www.dallascowboys.com
So we know the DNS name, let's find out the IP address of the Dallas site.
Visit ZoneEdit's DNS lookip site
Enter the website you wish to redirect TO, and find it's IP address. The results should look like the pic below.
So, if you wanted to re-route all DetroitLions.com traffic to www.DallasCowboys.com, enter the following in the HOSTS file.
After a reboot, the next time they attempt to enter the Lion's site, it will redirect them to the Cowboy's. They'll check their spelling, but it will continue to redirect them. It should prevent them from accessing it, even if they go through Google to get the right site. And of course, to fix it, just remove the line (or add a # sign prefix to stop it) and reboot. Voila, instant repair.
I am not liable for broken fingers if you try this stunt. :P Have fun, but don't be a jerk!
Thanks for reading this Instructable! Let me know what you think! But be nice!