You can use the HOSTS file to block ads and banners, but you can also block many of the parasites and malware that get onto our machines by surfing websites. Here is a link to a MONSTER HOSTS:
http://www.mvps.org/winhelp2002/hosts.zip
Banner ads are not all evil and many respectable sites make a living with them. But even a respectable site can unknowingly display an ad that will get you get hijacked by a script or download that can render your machine unusable or worst begin gleaning your passwords by logging your key strokes. After your download the above HOST file you will need to put that in a specific folder:
Where’s my hosts file?
- Windows 95 / 98 / ME: C:\Windows (I think)
- Windows NT: C:\WinNT\hosts
- Windows 2000: C:\WinNT\system32\drivers\etc
- Windows XP: C:\Windows\System32\drivers\etc
- Windows Vista: C:\Windows\System32\drivers\etc
- Windows 7: C:\Windows\System32\drivers\etc
- FreeBSD / Linux / Mac OS X / Unixish operating systems: /etc/hosts
- Classic Mac OS: please read this helpful information submitted by David “iNerd” B
- Mac OS 9: Marcia Skidmore sent in details that hopefully explain what you need to know
- Mac OS 10+: Tina Kent sent in details for later versions of Mac OS
What Does it Do?
The HOST file redirects the browser to look for banner content at 127.0.0.1 instead of the actual banner host on the interwebs. 127.0.0.1 is a special IP address which, to a computer, always means that computer. Any time a machine sends a network request to 127.0.0.1, it is talking to itself. This is very useful when it comes to blocking ads, because all we have to do is specify the IP address of any ad server to be 127.0.0.1. And to do that, all we have to do is edit the hosts file. What will happen then is something like this:
- you visit a web page
- the web page contains a banner ad stored on the server “ads.example.com”
- your computer says “ads.example.com? never heard of it. wait a second, let’s see if I’ve got the number on me…”
- your computer finds its hosts file and checks to see if ads.example.com is listed
- it finds the hostname, which points to 127.0.0.1
- “great”, says the computer, and sends off a request to 127.0.0.1 for the banner ad that’s supposed to be on the page
- “oh”, says the computer, and fails to show anything because it just sent a request to itself for a banner ad
Once that is done then close your browsers and reopen and viola you should no longer see any banners.