Use your hosts file to block annoying ads
Unless you have been living under a rock for the last couple of years, you have probably run into ads while browsing the Internet. While some of these ads are non-obstructive, some are downright annoying.
Wouldn’t it be nice if you could easily turn off all those nagging ads? Yeah, yeah — I know that some of you are thinking that these ads are a nice way of supporting websites that publish cool stuff for free. It’s a noble thought, but sometimes the ads just get too annoying. Not to mention creepy.
Re the creepy bit, do you know that ad servers will now follow you from site to site in order to customize the ads they serve you? In real-life, this would be like having an advertising agent follow you from store to store to record what you buy. I don’t know about you, but I find that a bit on the creepy side.
Anyway, if you decide you are tired of seeing these ads, there is a very simple way to get rid of them. Also, you don’t have to shell out a single penny of your hard-earned cash to do this. I will show you how to get rid of these ads permanently on any Windows PC.
First, you need to know how your computer finds websites on the Internet. All websites on the Internet have a unique number associated with them. This number is referred to as the IP address of the website. When you enter a URL — e.g., www.facebook.com — in your browser, the first thing the browser does is try to resolve the URL to an IP address.
Resolving a URL to an IP address on a Windows machine is a two step process. First, the browser checks a “hosts” file to see if you have an IP address associated with the entered URL. The hosts file is a local file that stores a mapping between IP addresses and URLs. This file is loaded into memory at startup.
If the URL cannot be found in the hosts file, the browser attempts to contact a DNS server. The DNS server then does its thing and returns the IP address associated with the URL.
Thus, if we know the URLs of ad servers, we can intercept calls to these URLs by modifying our hosts file to redirect them to dummy IP addresses. If you have been around computers for a while, you probably know that 127.0.0.1 is the IP address of the local host — i.e., it is the IP address of the machine you are currently using.
Therefore, an easy way to get rid of ads, and prevent ad servers from tracking you, is to edit your hosts file to have all known ad server URLs resolve to 127.0.0.1. That way, all of these URLs end up calling your own PC instead of the ad servers.
The two missing pieces are now; where is this hosts file located? and, where would you get a list of known ad server URLs? On Windows, the hosts file is stored in a different location depending on the version of Windows you have. Here is the typical location of this file for the most popular versions of Windows:
Windows 95 – C:windows
Windows 98 – C:\windows
Windows Me – C:\windows
Windows 2000 – C:windows\system32\drivers\etc
Windows XP – C:\windows\system32\drivers\etc
Windows NT – C:\winnt\system32\drivers\etc
Windows Vista – C:\windows\system32\drivers\etc
Windows 7 – C:\windows\system32\drivers\etc
Now to the second piece of the puzzle; where can we get a list of known ad server URLs? Fortunately, there are many sites that provide a list of these URLs. My favorite is the MVPS Hosts file hosted here. This file, in addition to listing known ad servers, also lists known sources of malware. So not only does it stop all those nagging ads, but it also protects you from known malware sites.
Download the MVPS Hosts file, replace your old hosts file with the downloaded file and you are good to go. Don’t forget to backup your old hosts file in case you want to revert to the old configuration for any reason. Give this a try, it will make your browsing experience much more enjoyable.
Unless you have been living under a rock for the last couple of years, you have probably run into ads while browsing the Internet. While some of these ads are non-obstructive, some are downright annoying. Wouldn’t it be nice if you could easily turn off all those nagging ads? Yeah, yeah — I know that some…