You can begin blocking ads and help keep yourself from being tracked by using the Hosts file with Windows and other operating systems.
What is the Hosts file, and how does it stop ads and tracking?
The Short Answer:
The short answer is that the Hosts file is like an address book. When you type an address like www.yahoo.com into your browser, the Hosts file is consulted to see if you have the IP address, or “telephone number,” for that site. If you do, then your computer will “call it” and the site will open. If not, your computer will ask your ISP’s (internet service provider) computer for the phone number before it can “call” that site. Most of the time, you do not have addresses in your “address book,” because you have not put any there. Therefore, most of the time your computer asks for the IP address from your ISP to find sites.
If you put ad server names into your Hosts file with your own computer’s IP address, your computer will never be able to contact the ad server. It will try to, but it will be simply calling itself and get a “busy signal” of sorts. Your computer will then give up calling the ad server and no ads will be loaded, nor will any tracking take place. Your choices for blocking sites are not just limited to blocking ad servers. You may block sites that serve advertisements, sites that serve objectionable content, or any other site that you choose to block.
The Longer, More Technically Oriented Answer:
The “Hosts” file in Windows and other operating systems is used to associate host names with IP addresses. Host names are the www.yahoo.com addresses that you see every day. IP addresses are numbers that mean the same thing as the www words – the computers use the numbers to actually find the sites, but we have words like www.yahoo.com so humans do not need to remember the long strings of numbers when they want to visit a site.
For instance, the host name for Yahoo! is www.yahoo.com, while its IP address is 184.108.40.206 Either address will take you to Yahoo!’s site, but the www address will first have to be translated into the IP address. If you type in the IP address directly, your computer will not have to look it up.
A series of steps are used when searching for IP addresses that go with these host names. The first step, and the one that concerns us here, is the hosts file on your local computer. The Hosts file tells your computer what the name is in numbers so the computer can go find it. If the IP address is found in your Hosts file, the computer will stop looking and go to that site, but if it is not it will ask a DNS computer (domain name server) for the information. Since the search ends once a match is found, that provides us with a mechanism to block sites we have no interest in. You may block sites that serve advertisements, sites that serve objectionable content, or any other site that you choose to block.
We can put names and addresses into the Hosts file so your computer does not have to ask a DNS server to translate the domain name into an IP number. This speeds up access to the host site you want to see because your computer no longer has to query other systems on the Internet for the address translation. When you type in a web address like www.yahoo.com, the host name portion of the web address is translated into an IP address before the site is accessed. If you put Yahoo!’s host and IP settings into your Hosts file, it would load a little quicker because your computer doesn’t have to ask another to translate where to look for Yahoo!
Computers have a host address of their own – it is known as the “localhost” address, with an IP address of 127.0.0.1 which it uses to refer to itself. If you associate another computer’s host name with your localhost IP address, you have effectively blocked that host since all attempts to access it will lead back to you. That is how we will block sites using the Hosts file. We will tell our computer that the IP address of the site we want to block is our own address. That way, our computer will not ever leave and go looking for the site we are blocking – which keeps that site from appearing because the computer thinks it has found the site and displayed it already.
Many web sites have links to other servers for the retrieval of advertisements. In the case of those web servers, the browser will quickly fail to locate the requested data (scripts, images, etc.) from the advertising server because we told our computer to look for the information on itself – of course it won’t find any of it and will quit looking for it – and will continue loading the pertinent portions of the page you want to see. This will keep your computer from even talking to the ad servers, and thus you won’t see the ads, they can’t put cookies on your hard drive, and you can’t be profiled by them.
Benefits of the Hosts File:
- Uses less resources: By using a function built into your computer, you will be able to block advertising sites (or any other site you wish) without the need for any extra programs. This will cut down on memory and processor usage, which will free up your resources for other tasks.
- Works on connections other than HTTP: Most ad-blocking programs will only intercept IP calls going to the HTTP (or web) port on your computer. Other transfers can still get through. The Hosts file, however, will block IP calls on any port, whether it is HTTP, FTP, or whatever else you happen to be doing.
- Eliminate many tracking and privacy concerns: By intercepting the IP calls before they ever leave your computer, the Hosts file can prevent advertising and tracking companies from ever even knowing you are viewing a web page. This will keep them from profiling you and help you keep your privacy. All sites in the Hosts file entered with a 127.0.0.1 address will never be accessed. Sites that are not in the Hosts file may still track you and send you ads.
To find out which advertisers may be tracking you, please visit this excellent web site.
- The Hosts file is configurable: Rather than relying on others to decide what sites to block for you, you may edit the Hosts file entirely on your own. This means you can put any site you wish into the Hosts file and that site will not be able to be accessed. You can use this to block advertisers, trackers, or sites you would not want your small children to see. You get to decide entirely what you wish to block, and you don’t have to depend on someone else’s judgement!
- Increased browsing speed: By placing sites into your Hosts file with their correct addresses, your computer does not need to ask another computer where to find a site. This can significantly speed up your surfing experience because your computer will go straight to that site instead of having to ask directions. Also, by keeping ads from being loaded using the blocking technique in the Hosts file, web pages will be viewable much more quickly since they won’t have to load a lot of fancy graphics.
Some restrictions on the Hosts file:
- It will not work with wildcards, such as *.whateveryouwantgoeshere.com.
- It will not work with URL’s that begin with IP numbers. IP numbers are the numerical equivalent of the www.somesitenamehere.com address, and that is what your computer actually uses to find the web page. The names are there so that humans don’t have to remember long strings of numbers. You would need to find the www.whatever.com address that the IP number represents, and then block that name instead of using the IP number. For example, Yahoo!’s address is www.yahoo.com, and its IP address is 220.127.116.11 We can block www.yahoo.com but not the IP address. The reason for this is that Hosts is used to determine IP addresses. If we already know the IP address, Hosts will not be consulted and so can not block the site. I do not recommend actually blocking Yahoo! though, as it is a great search engine!
- It will not work with ads that are served from the same site you are viewing. The reason for this is that the Hosts file must block an entire site, and can not block subdirectories or pathnames on a site. For example, you could not block www.netscape.com/ads/ because you can’t block subdirectories. You would need to block the entire www.netscape.com server, and that would leave you without access to Netscape’s site. So you will have to use a different method to eliminate ads that come from the site you are viewing, such as an ad-blocking program.
- It may cause some sites to quit working properly. If you put the wrong server into your hosts file, it may mean that certain websites will no longer be viewable as they normally would be. To remedy this, remove the entry of the site you wish to unblock from your hosts file. In particular, you may notice sites that rely on Akamai’s servers will not function properly if Akamai is in your Hosts file.