Mike's Pic

Mike's Pic
Mike McCarthy

Thursday, September 13, 2007

Mike, What is a "Hosts" file and what is it for?

Consider you move from 123 Main Street to 456 Elm Ave. To ensure you get your forwarding mail you notify the U.S. Post Office of your change of address. The Hosts file acts in a similar manner. It is a file found on every Windows operating system that checks incoming and outgoing traffic for forwarding addresses. The Hosts file contains two entries: A From entry and a To entry separated by a tab, so if traffic comes into 123 Main Street the Hosts file forwards it to 456 Elm Ave. But to better understand the Hosts file function you first need to understand that the World Wide Web is not based on www URL addresses as we’re all used to using.

Every web site in the world is identified by a unique set of four numbers containing three characters (zeros are truncated) separated by a period. These addresses are often referred to as IP Addresses, Internet Addresses, or Network Addresses. For instance, Yahoo’s Internet Address is 209.131.36.158. Try it out; type 209.131.36.158 into the URL address bar on your web browser. Yahoo.com opened didn’t it? Here’s another one, my Internet Address is 216.185.128.200. Now this doesn’t work with all addresses as many are hidden behind layers of security, but you get the idea.

If you never setup your Hosts file this is what you’d typically see if you viewed it:

# Copyright (c) 1993-1999 Microsoft Corp.
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host

127.0.0.1 localhost

The entry for localhost is the computer you are on. The address 127.0.0.1 points to itself and we call this a “black hole” or a “loop back”. Anything referring to localhost or 127.0.0.1 is flushed from the computer. Knowing this, we can block (or filter) access to specific web sites, so let’s consider blocking www.myspace.com:

# Copyright (c) 1993-1999 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host

127.0.0.1 localhost

127.0.0.1
www.myspace.com

127.0.0.1 myspace.com


The reason I have two entries here for myspace is to ensure the above formats are both blocked (www. is unnecessary to type in today as it is assumed).

Does this mean you or I have to enter every possible combination of every potentially unsafe web site? No, there are many ways of populating your Hosts file with templates already out on the web.

If you use SpyBot S&D you can download SpyBot’s Hosts file or you can search the web for any number of free Hosts file sources. But probably the most popular Hosts file source comes from www.mvps.org. You can download this using a zip/unzip program (such as WinZip) at http://www.mvps.org/winhelp2002/hosts.zip. If you don’t have a zip/unzip program you can open the MVPS Hosts file in plain text here: http://www.mvps.org/winhelp2002/hosts.txt. For more information and instructions on how to download and install this file, go to: http://www.mvps.org/winhelp2002/hosts.htm.

ITC Computer Services of Arizona
Office/Fax: 602-375-7934
Mobile: 602-684-7501
Web Site:
www.itcaz.com
Email: mike@itcaz.com

1 comment: