Windows 10

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.

Sponsored Content

What is “Inside Microsoft Teams”?

“Inside Microsoft Teams” is a webcast series, now in Season 4 for IT pros hosted by Microsoft Product Manager, Stephen Rose. Stephen & his guests comprised of customers, partners, and real-world experts share best practices of planning, deploying, adopting, managing, and securing Teams. You can watch any episode at your convenience, find resources, blogs, reviews of accessories certified for Teams, bonus clips, and information regarding upcoming live broadcasts. Our next episode, “Polaris Inc., and Microsoft Teams- Reinventing how we work and play” will be airing on Oct. 28th from 10-11am PST.

Location of the Hosts File

In Microsoft operating systems, the HOSTS file is located in the following location:

C:\Windows\System32\Drivers\etc

Note: We also have tutorial articles on how to edit a hosts file in Windows 8edit a hosts file in Windows 7 and on a mobile device running Windows RT.

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:

192.168.0.1 printserver

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:

Edit the HOSTS File in Windows 10

 

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 8.8.8.8 (this is just an example, actually 8.8.8.8 is the IP address used by Google’s DNS servers), you would add this line:

8.8.8.8 webserver.domain.com

When you ping it, your computer will resolve the name to the correct IP address:

edit-hosts-file-win10-3

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:

edit-hosts-file-win10-1

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:

C:\Windows\System32\Drivers\etc

1. To do so, copy the HOSTS file to your Desktop.

edit-hosts-file-win10-4

2. Open the copy from your Desktop in Notepad.

edit-hosts-file-win10-5

edit-hosts-file-win10-6

3. Make all necessary changes. For example, adding a line that translates 192.168.1.1 to “kuku”. Save the copy.

edit-hosts-file-win10-7

4. Next, copy and paste the file to its original location.

edit-hosts-file-win10-8

5. You will be asked if you want to overwrite the file. Choose Replace the file in the destination.

edit-hosts-file-win10-9

6. Windows will ask for Administrator permissions. Click Continue.

edit-hosts-file-win10-10

7. The changed HOSTS file will replace successfully the original, and now, if you ping “kuku” you will get the corresponding IP address.

edit-hosts-file-win10-11

 

 

 

Related Topics:

BECOME A PETRI MEMBER:

Don't have a login but want to join the conversation? Sign up for a Petri Account

Register
Comments (3)

3 responses to “Easily Edit the Hosts File in Windows 10”

  1. Or you can run Notepad as an administrator and edit the file directly, like we’ve been doing for several years in Windows 7 and Server 2008 R2.

  2. I wish Microsoft would wise up and will display UAC prompt for file access to restricted locations. Copying files back and forth between desktop and destination directory PIA.

Leave a Reply

External Sharing and Guest User Access in Microsoft 365 and Teams

This eBook will dive into policy considerations you need to make when creating and managing guest user access to your Teams network, as well as the different layers of guest access and the common challenges that accompany a more complicated Microsoft 365 infrastructure.

You will learn:

  • Who should be allowed to be invited as a guest?
  • What type of guests should be able to access files in SharePoint and OneDrive?
  • How should guests be offboarded?
  • How should you determine who has access to sensitive information in your environment?

Sponsored by: