These days annoying advertisements, popups, and spyware are still alive and quite well. Firefox, Chrome, and Internet Explorer have some good built-in Pop-up blockers and available plug-ins, but they don’t always catch everything, especially advertisements. There are many software products and plug-ins out there that promise to help keep you safe and block known bad sites. Many of them work, but most of them cost money. In this guide, I’ll show you a simple tweak you can do for FREE to help block known bad and malicious sites.
Do you use playlists on Youtube, Pandora, or Grooveshark and get interrupted between videos or songs for 30 seconds or more with annoying political ads and such? Do you want to protect your kids from adult websites or want to block your kids from www.facebook.com for fun (devious but hilarious)? I can help you do this without any extra plug-ins or paid products.
In this post I’ll be showing you how to utilize your HOSTS file to protect your computer in a simple yet effective way. Using this guide, in combination with Microsoft Security Essentials for your Antivirus (highly recommended AV for Windows users!) and smart web browsing habits, you’ll keep your PC out of trouble .
First, let’s explain what the HOSTS file is. The HOSTS file is the first place that your PC looks to match a hostname with an IP address. “What the heck are you talking about, Gabe?!”
Let’s take the website www.google.com as an example. When you type in www.google.com into your web browser your computer needs to match the words you entered with an IP address to serve you the content. Your computer will check your local HOSTS file first, and then if there is no match to www.google.com, it will then check your configured DNS servers(Domain Name Server). A DNS Server’s job is to catalog matching IP addresses and hostnames.
First you need to open Notepad as an Administrator. It’s very easy, just hold the shift key and right-click Notepad, then select Run As Administrator (Notepad can be found in the “C:\windows” folder) Then click File > Open then enter the below in the File Location:
ProTip – You have to open Notepad as an Administrator then open the HOSTS file because it is protected from non-administrative user changes. This is a good thing.
Anything that starts with “#” is commented out (ignored) for note purposes, so as far my computer is concerned, this file is blank. These notes are very helpful and explain the use of the HOSTS file completely. Notice that localhost is 127.0.0.1. That IP address is a loopback adapter that exists on every computer. Anything we point to 127.0.0.1 in this file will not leave your computer. Further explanation of loopback is beyond the scope of this posting, just trust me it works.
I am going to add an entry for www.google.com to 127.0.0.1, then click File > Save As and make sure it saves as HOSTS and not HOSTS.txt. Then test.
Here I’ve added the entry:
Here I am making sure it is NOT going to be saved as a .txt file, it will ask if you want to replace the existing select YES:
I then went back to my web browser and tried to access www.google.com. It doesn’t work now!
And here is what the ping looks like, notice it replies with 127.0.0.1. Since I am not running www.google.com on my PC, nothing is presented in my web browser.
From this quick example, you can see how useful this could be!
Now here is where I will show you where to get an excellent list of bad, malicious, and spyware ridden domains that you can add to YOUR hosts file. This file is updated every 30-60 days or so, I recommend visiting it every so often to keep your file as up-to-date as possible.
Just visit this site here:
Select all the text on the first link (it will look a lot like your hosts file), copy it, paste it into your HOSTS file, then save it (Remember to do Save As, to make sure Notepad does not save the file as hosts.txt)
Here is a screenshot of just a small portion of the file, notice ads and adult site names in the list:
IMPORTANT – If you ever have an issue loading a website and you suspect that this hosts file is blocking the site for some reason, simply select all the text, delete it, and save it as an empty file. Then test your site again. You can apply and revert changes to your HOSTS file anytime you want and any changes to the file are instant once saved.
Here is a screenshot with the HOSTS file enabled for a video website. Notice instead of an annoying, flashy ad, I have a nice Chrome emblem and a message that says, “sorry this ad couldn’t be loaded” Horray for no ads!
Hopefully you’ll find this useful. Do you use the hosts file on your computer already? Do you use any other utilities or built-in windows functionality to protect yourself online that many people many not be aware of? Let me know in the comments section…