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.
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.
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 220.127.116.11.
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.
According to the hpHosts site, you can see that IP address 18.104.22.168 belongs to a a server notorious for selling or distributing deceptive software.
If you click the yellow highlighted link you’ll get a bunch of useful information about the host.
Finding and editing hosts
Open your Computer files (Windows Key + e) and paste the following into the Explorer address bar:
Now right click the file and choose Open and select Notepad as the application.
Fun with hosts
So what can you do with the hosts file after opening it?
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:
22.214.171.124 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.
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.
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!