Back in the day, before Windows, we had DOS, a basic command line interface. We kicked-off our applications from the DOS command line, used tools to manage our computer environment, and became able, if not adept in changing things to make the computer run better.
The came Windows. Simply put, Windows is a graphical interface that sits on top of DOS. DOS is still there, underpinning all the Windows functions. You can still use DOS by invoking PowerShell or the CMD command.
All the old DOS stuff is still there, hidden files defining how your machine starts up, how it runs and how it recovers from internal errors. The Blue Screen of Death doesn’t appear as often as it did.
Before the Internet, there was no such thing as Domain Name Servers (`’DNS`). Network administrators manually maintained a text file, usually called Hosts.txt, that mapped computer names to computer addresses. This was fine while networks were local, and had few nodes on them. As networks grew and began to link to other networks, the job of modifying the host file became an increasing burden on network admins.
A solution to the admin problem was put forward in 1983, and was implemented as the DNS system in 1984. The ability to modify the hosts file is a legacy of those early days. Windows systems, even today, come with a sample hosts file, hosts.sam, included in the file system.
Simply put, what the hosts file does is to hold a list of correspondences between website names and IP addresses. The operating system checks the hosts file before going onto the Internet to obtain the translation from a DNS server. Local matches take precedence over Internet DNS searches.
Why would you want to modify the Hosts file?
The benefits of modifying the host file include:
Speeding up connections to commonly accessed websites:
Listing the name to IP address mappings for commonly accessed websites in the hosts file means that the networking system does not need to go onto the Internet and ask a DNS server for the IP address before linking to the site. Obviously, host file access is quicker, and allows you to reach the website even if your DNS server is down for some reason.
Blocking tracking and adware sites;
Many websites today are almost unusable because of adverts on them. There is a fixed IP address for the local computer, 127.0.0.1. You can block access to known adware and tracking websites by mapping the site name to 127.0.0.1 in your hosts file. When a website tries to contact them, the networking system looks for them on your local computer and of course fails to find them. Use of the website you want will continue, but without the ads and tracking element.
Blocking sites you might not want other users, perhaps children, to see when using your computer; and
By using exactly the same technique you can block inappropriate sites. Not all websites apply parental control guidelines and some can slip through.
Redirecting website calls to a local development environment.
If you have an operational website and you want to update an offline copy, you can redirect calls to the website from your computer to a local development computer by making an appropriate entry in the hosts file.
Before you rush off and modify the hosts file, beware. Make sure that your malware defences are up to scratch. Some viruses attack the hosts file. For example the worm MyDoom.B modified the hosts file to block access to security and antivirus software sites. It also fiddled with access to Windows Update. At the very least make the hosts file read-only.