How To: Hosts file adblocker

TheWesDude

Sonny, I Watched the Vault Bein' Built!
How To: Hosts file adblocker

Nowadays there are lots of companies and such trying to sell you a program to stop/block the advertisements, some free, some paid for. Firefox has plugins that do it for you, and Opera has its content blocker. But none of these really work, or else have security risks inherent in using them. Plus some websites are researching technology to check to see if you have these programs/apps/plugins running and then reducing the functionality of their website forcing you to view these advertisements.

That is correct, some of the most popular plugins for Firefox ( Fx ) create security risks. This has been pointed out numerous times and finally the Mozilla team is going to re-write how they handle plugins to not allow them to create security holes like they do currently. Especially some of the most popular plugins for Fx create security holes/issues such as the adblock, noscript, and a few others.

Or you can install a program that monitors your internet access and blocks access to known "advertisement" sites. Usually these cost money or are not updated very well. And involve running another proccess to handle it.

There is a MUCH easier solution, and one that is far more absolute. Its called the hosts file adblocker. Because of what the hosts file is and how it is used, it is very hard to bypass.

What is the hosts file?

The hosts file is a locally stored file that contains local translation for DNS names to IP addresses. When you go to www.microsoft.com, your computer looks at the locally stored cache file for DNS name-ip resolution, and then sends the request to your TCP/IP stack to form the packet to go out your network card. When the TCP/IP stack gets the request ( in windows, linux/unix work a little differently and it is called the LMHosts file ) the stack checks your hosts file for a manually entered translation, if one is not there it formulates a DNS query and sends that query to your default DNS server to get the IP. This means even if a program/virus/trojan manually inserts a translation into your cache ( which is possible ) the stack will ignore that and use the hosts file entry instead. The hosts file is read once when you start/restart the TCP/IP service, and then closed. When you update your hosts file, you need to restart your computer to be sure your new hosts file is loaded into the stack.

This is the reason it is considered absolute. If there is an entry in the hosts file, that will be used. There is only 1 way to bypass the stack's use of the hosts file, and that is to manually create the packet and send the packet bypassing the stack. This is not easy to do, and would require a lot of work and drastic increase in size for any virus/trojan because they would basically have to install their own version of the TCP/IP stack and use that rather than the one your OS uses.

This can cause problems that do not exist in normal adblock/anti-virus/firewall software. Most of those have options to allow/block something and you can change it at run-time ( without requiring a restart ) but that is not true of the hosts file. Not only that but you would have to find the line in the hosts file that is causing problems for your favorite site, change/fix/remove that line, and then restart, or else remove all the changes.

This may cause problems with some sites. Use at your own risk. Yes, this is serious.

Contrary to popular belief, you do NOT have to manually update it every couple weeks or months. Even doing this once or twice a year will block practically every advertisement you will get.

The hosts file I use, I have not updated in 4-5 months and I still only get maybe 1 advertisement every week or 2.

This does require some technical skill, but there are very good instructions on how to do this.

Here is the main site with specific instructions on how to do it.

http://www.mvps.org/winhelp2002/hosts.htm

This is a pretty complete hosts file adblock, and is updated pretty frequently as they also add popular virus/trojan/spyware/datamining information into it. They also tell you where the hosts file is located on your computer, and specific instructions for both vista/win7 on how to access/edit your hosts file.

MAKE SURE TO USE A TEXT EDITER LIKE NOTEPAD NOT MICROSOFT WORD OR SUCH

And here is the actual hosts list.

http://www.mvps.org/winhelp2002/hosts.txt

Make sure to add this at the BOTTOM of your existing hosts file list. This will make it easier in case you have to reverse these changes.

JUST MAKE SURE AFTER YOU UPDATE YOUR HOSTS FILE THAT YOU RESTART YOUR COMPUTER.


Enjoy your advertisement free web browsing.
 
Back
Top