Easily Edit the Hosts File in Windows 10
Most operating systems, including Microsoft Windows versions, use the hosts file to translate computer names. Also known as “host names” to numerical IP addresses, the hosts file is similar to using a phone book to find the matching phone number of a specific person’s name.
Note: This article was written at the time when Windows 10 was at Technical Preview build phase.
While Domain Name System – or DNS – is mostly used for this function (being a centralized and half-automatically managed name resolution system), the HOSTS file can be used as a local name resolution mechanism, and when used in conjunction with other name resolution mechanisms such as DNS, the HOSTS file takes precedence over them.
This is why many users still edit the HOSTS file and add names and IP addresses of servers, websites and other computers they frequently access to it.
Location of the Hosts File
In Microsoft operating systems, the HOSTS file is located in the following location:
How the Hosts File Works
The HOSTS file is a text file, one that does not have a file extension. It contains lines of text that are made of IP addresses followed by one or more host names or fully qualified domain names (FQDNs). Each field is separated by white space (blanks or tabulation characters).
For example, if you wanted to use the HOSTS file to translate a host name of a computer called “printserver” into the IP address of 192.168.0.1, you would add this line:
You can add more than one host name to the same IP address. For example, if the computer called “printserver” also acts as a scanner called “scanserver”, you could use this line:
192.168.0.1 printserver scanserver
If you ping either “printserver” or “scanserver”, you’d get to the same IP address:
The HOSTS file can also translate Fully Qualified Domain Names (or FQDNs) of computers, such as ones used on the Internet.
For example, if you wanted to add a manual line to translate a FQDN of a computer called “webserver.domain.com” into the IP address of 188.8.131.52 (this is just an example, actually 184.108.40.206 is the IP address used by Google’s DNS servers), you would add this line:
When you ping it, your computer will resolve the name to the correct IP address:
You can also include comment lines by placing a hash character (#) at the beginning of the line.
This is how the HOSTS file looks on a Windows 10 Technical Preview build machine:
The HOSTS file may sometimes be used by malicious software such as adware, computer viruses, or trojan horses etc. These applications may use it to redirect traffic from the intended destination to sites hosting malicious or unwanted content. That is why some Anti-Virus programs may monitor changes to the HOSTS file, preventing malicious software from modifying it. So does Windows, and unless you use elevated permissions to edit the file, you will be prevented from saving it.
How to Edit the Windows 10 Hosts File
To edit the HOSTS file we need to use a method that allows us to save the file to it’s original location, which is:
1. To do so, copy the HOSTS file to your Desktop.
2. Open the copy from your Desktop in Notepad.
3. Make all necessary changes. For example, adding a line that translates 192.168.1.1 to “kuku”. Save the copy.
4. Next, copy and paste the file to its original location.
5. You will be asked if you want to overwrite the file. Choose Replace the file in the destination.
6. Windows will ask for Administrator permissions. Click Continue.
7. The changed HOSTS file will replace successfully the original, and now, if you ping “kuku” you will get the corresponding IP address.