All about the Windows HOST file

The host file has been around since the inception of the internet.

A little history

If you ever spontaneously get the urge to flip through the voluminous annals of the internet you’ll quickly discover that host files are so old that they actually antedate the internet.  And when I say old, I mean archaic.

Host files were the product of a few geniuses working on the Advanced Research Projects Agency Network (ARPANET).  In the spring of 1977, ARPANET marked the humble beginnings of what would eventually transform into the world wide web.  The US Department of Defense created it to facilitate communication between a universities and research labs.

As other universities saw the success of ARPANET they wanted to join the project and gradually, year by year, the network began to burgeon.

The nascent computer geeks of the ARPANET days didn’t have the distributed hostname database that we all use today called DNS.  Instead, each networked computer, called a host, had a little file that mapped the computer-friendly name of the host known as the IP address to the human-friendly name so that people didn’t have to remember IP addresses.

Hostname’s are a heck of a lot easier to commit to memory than a string of random numbers; I mean, who can forget this famous one:  Altavista.com? In this example, Altavista is the hostname.

Fast forward to today

Today, the host file is a relic from the past; however,  the past can have an uncanny way of haunting the future. The host file is just a file with lines of text that show the IP address of the computer followed by a space and the matching hostname.

Windows 8 HOSTS file

Here’s the host file on my Windows 8.1 computer.

Every line in my hosts file is proceeded with a hash symbol which means every line is ignored.  The hash is used to make comments and is completely ignored by the operating system.  People often use it to make notes or adjustments and later delete the hash to make the changes effective.

Windows 7 HOSTS file

The hosts file on my Windows 7 computer looks virtually identically to the Windows 8.1 box but notice that the 127.0.0.1 and ::1 parts don’t have a hash prefix.

This tells the operating system to direct any web requests for the hostname named localhost to the 127.0.0.1 and ::1 IP addresses.  Both of these addresses refer to your physical, local machine and not some remote computer across the internet somewhere.

Why care about the the host file?

You should care about the host file because spyware and browser hijackers often modify it so that benign web requests to common web sites (often sites like search engines) redirect to third-party ad-network instead of the site you wanted.

Have you ever gone to google.com or yahoo.com or clicked the home button on your browser only to discover your homepage is completely different?

Or maybe the change wasn’t that drastic but there were minuscule differences such as tiny images or web graphics that weren’t on your homepage before?

The first thing I would do is check your host file.  If you see a line similar to the one in the graphic below then you should comment out the line (or delete it) because it means that your web browser is redirecting requests for google.com to some computer at address 108.162.199.207.

That shouldn’t be there.  In fact, you can cross-reference the IP addresses in your hosts file against the hpHosts database to ascertain whether or not they’re legitimate or not.

Windows 8 hosts file realmichaelkoressaleweb.com

According to the hpHosts site, you can see that IP address 108.162.199.207 belongs to a a server notorious for selling or distributing deceptive software.

Windows 8 FSA host

If you click the yellow highlighted link you’ll get a bunch of useful information about the host.

Windows 8.1 FSA host details

Finding and editing hosts

Open your Computer files (Windows Key + e) and paste the following into the Explorer address bar:

%SystemRoot%\System32\drivers\etc

Now right click the file and choose Open and select Notepad as the application.

Windows 7 open hosts file

Fun with hosts

So what can you do with the hosts file after opening it?

Lots!

First let me show you a really neat trick that will definitely earn you geek points with geeky girls.

Create URL shortcuts

Open hosts and add this line to the bottom of the hosts file:

173.254.28.55 fbv

host file shortcut

173.254.28.55 is the IP address of fixedbyvonnie.com; therefore, typing fbv into your address bar will direct the request to my site.

This is a slick way to both save a few keystrokes and look cool at the same time.

After you save the file, changes are immediate (no rebooting).  Give it a test, just keep in mind you can’t add any spaces to the hostname or it’ll fail.

hosts file shortcut example

Another cool thing you can do with the hosts file is to create a shortcut for your home internet router.

Make a shortcut to your router

Most consumer routers have a default admin page address of 192.168.0.1 so you can add the following line to access it with a single word.

192.168.0.1 router

Block Ad-networks

Finally, you can block spyware and and spyware by mapping the IP addresses of these annoying offenders to your localhost.  This will stop those ad-sites from being contacted because those IP addresses simply map to your personal computer.  It also has the serendipitous effect of giving your browse a slight performance boost because now it no longer has to wait for the hostnames of those ad-sites to resolve.

Personally, I use the Ad-blocker Chrome extension to stop annoying ads; however, this method is virtually equivalent.

The Bottom Line

The hosts file is an artifact with great utility and I really wish more people knew about it.  You can read about the official specifications of the hosts file if you want but the bottom line is that it’s an simple, little known way to block ad-networks and create shortcuts for your favorite websites and home router.

In addition, now you know what to do whenever the homepage of your favorite browser gets hijacked.

Now get out there and share the knowledge!

About

Connect with Vonnie on Twitter

Posted in How To, Windows 7, Windows 8, Windows 8.1, Windows Vista, Windows XP Tagged with:
  • Pingback: Is your system really clean just because your antivirus program says so? | fixedByVonnie()

  • Mia

    This is a great explanation. However, I am running into a problem as I cannot edit and save. Says I need administrative rights. This is my laptop and I have ful administrative permissions.

    • BeaveVillage

      Make sure you start notepad with Administrative rights (press start, type in notepad, right click, choose run as administrator), then you can create, modify or save the hosts file and save it in that folder. I had to do that on a Windows 7 x64 system to get it to save my changes.