Host Files – Basic Use


If you have been in the computer game for awhile you know all about host files. It seems like anymore people prefer to have huge resource intensive anti-virus programs and bog down their system with programs that are supposed to protect them from getting their system bogged down. While these programs no doubt do what they are supposed (when kept up to date), there are better and less resource whoring methods to protect yourself.

I stole this form WikiPedia, but it’s basically a chart of where you can find your hostfile for whatever OS you are running.

Operating System Version(s) Location
Unix, Unix-like,POSIX /etc/inet/hosts or /etc/hosts
Microsoft Windows 3.1 %Windir%HOSTS.SAM
95, 98/98SE, Me %WinDir%
NT, 2000, and 32-bit versions of XP2003,Vista, 7 %SystemRoot%system32driversetc
64-bit versions %SystemRoot%system32driversetc (Many sources, including several Microsoft support pages, will incorrectly state that the hosts file is at %SystemRoot%SysWOW64driversetc)
Windows Mobile Registry key underHKEY_LOCAL_MACHINECommTcpipHosts
AppleMacintosh 9 and earlier System Folder: Preferences or System folder
Mac OS X 10.0 – 10.1.5 (Added through NetInfo or niload)
Mac OS X 10.2 and newer, iOS /private/etc/hosts or, since /etc is a symbolic link to /private/etc, /etc/hosts (just like POSIX)
Novell NetWare SYS:etchosts
OS/2 &eComStation "bootdrive":mptnetc
Symbian Symbian OS 6.1–9.0 C:systemdatahosts
Symbian OS 9.1+ C:private10000882hosts
Android /system/etc/hosts
iOS iOS 2.0 and newer /etc/hosts

For the purposes of this article I am going to stick with Windows, since that is what I use.

Try this out, navigate to your c:windowssystem32driversetc and open your hosts file in notepad. It should look something like this:

This is what your hosts file will look like when you first load it up.

In your host file add this line and save it:

127.0.0.1        google.com

You may need to close your web-browser or you may be able to just refresh but go to google.com now and see what happens.

What’s that? You can’t get to google anymore? Yeah, that’s because we just set your computer to point the name google.com to your home IP address so it never actually leaves your PC to try and find it. As long as this is in your host file, and your host file is active, you will never be able to reach google.com.

Why would you ever want to block google.com? Well you probably wouldn’t but if you are a parent you may want to block something like playboy.com or 4chan.org from your kids wandering eyes.

There are several uses for the hosts file that you can take advantage of:

  1. Block porn sites.
  2. Block known spammer sites.
  3. Block websites that waste time (i.e. Facebook, Twitter, this site)

You can also use your hosts file for the reverse. Let’s say you want to allow faster unrestricted access to a website. Or, let’s say your company has blocked YouTube.com from their network. Well, by simply grabbing YouTube.com‘s IP address and putting it into your hosts file and pointing it to YouTube.com you can get around it. You can either try and ping YouTube.com from the command line to get it’s IP Address (but if your company is blocking it you probably can not ping it), or you can google it and find YouTube.com‘s most common IP Addresses.

Depending on the level in which your company/school has blocked YouTube.com, this should now allow you to get to the website (or any other website you wish to use this method on).

Now I don’t promote slacking off at work, but I do promote knowing how to get around any and every obstacle put in your way. I always see any new IT blockage as a challenge to get around it. My work at one point blocked YouTube.com (actually it’s still blocked for most users) and after I received the email it took me less than a minute to use this method (and find 2 others) to get around the block and still get to YouTube.com.

This is just your basic quick guide on how to use a HOSTS file. They are extremely powerful and should not be taken lightly. This little file can literally cripple your internet if you use it wrong. But it can also give you massive amounts of control over what is allowed to be viewed on  your PC.

I see this as a better blocking option than a proxy or firewall for your known bad sites because instead of your PC going out to the URL, getting it’s IP address your proxy or firewall then catching it and blocking it using the HOSTS file your PC get’s the URL and the hosts file immediately sends it to 127.0.0.1, your PC’s home address. Essentially you could also use this to send all those bad sites to google.com or something if you wanted them to point to a search engine. Just put in googles IP for that to happen.

Tomorrow I will go over the way I use my host file on my Laptop and server to keep it clean. It’s a lot easier than you think.

I want to note that I am using Notepad ++ as my default text editor. I will write an article up about how great it is soon.

Leave a comment

Your email address will not be published. Required fields are marked *