How to Edit Hosts File?

What is Hosts file?

The HOSTS file is a basic text file that holds the IP addresses parted by at least one space and then a domain name, with each entry on its particular line. The hosts file is used by an operating system to map hostnames to IP addresses.

The hosts file is a common fragment of an operating system’s Internet Protocol (IP) application, and aids the task of interpreting human-friendly hostnames into numeric protocol addresses, called IP addresses, that classifies and pinpoint a host in an IP network.

How to Edit?

In the hosts file, you have to enter the domain name and its IP address. Once you enter the domain name in your browser and press enter, your browser will first examine the domain name in the hosts file and after it discoveries the appropriate entry, it will unnervingly map your browser to that specific host name.

For instance, let’s suppose that we want to alter it in such a way that if we typed in “www.facebook.com”, instead of going to Facebook we would go to “www.google.com”. In order to do this we need to treasure out one of the IP addresses of Google and map www.facebook.com to that IP address.

Let’s say that one of the IP addresses for Google is 218.107.113.69. If we wanted to map Facebook to that IP address we would add an entry into our HOSTS file as follows:

218.107.113.69 www.facebook.com

It is also essential to note that when we enhance records on our HOSTS file they spontaneously become operational. There is no need to reboot or enter additional command to start using the records in the HOSTS file.

Where to Find?

Every operating system has a different host file location. Here are the locations for some popular operating systems:

  • For Windows OS users- C/Windows/System32/drivers/etc/hosts
  • For LINUX/UNIX OS users- /etc/hosts
  • For Apple- System Folder: Preferences and in the System Folder itself.

The Ping Command

Well, you must be pondering how to discover the IP address of a specific domain name. By means of the Ping command, you can catch the IP address of any domain name you require. But for doing this you need to be connected to the Internet. First, you have to open a command prompt (Open Run, Type “cmd” and press Enter). Now type “ping {domain-name}” and press enter and it will display the IP address.

For example, let’s assume that we have to find the IP address of “www.whatever.com”. Then open command prompt, it would be displaying something like this:

C:\Users\User Name>

Now type the ping command along with the domain name.

C:\Users\User Name>ping www.whatever.com

Press Enter and the IP address of the desired domain name will pop out on the screen i.e. something like 189.162.143.98

How can we have Fun? 

Find the IP address of the desired domain name. Then get access to the system’s Hosts file and all you need to do is add an entry into the file.

Suppose the IP address of com is 198.67.45.23. Then the record you need to enter in the Hosts file is:

198.67.45.23 www.kidding.com

Now every time someone will try to open www.whatever.com from that system, spontaneously www.kidding.com will be loaded.

Real Life Application

As you can perceive the HOSTS file is a potent tool if you recognize how to use it. There are a various purposes as to why we would want to customize a HOSTS file and some of them are:

  • Network Testing
  • Possible Escalation of Browsing Speed
  • Block Spyware/Advertisement Networks