Windows Hosts File

The Windows Hosts file allows you to map IP addresses to host names, it is another method used in domain name resolution! For instance, the hosts file may become handy when your DNS servers are unavailable or data within these servers is incorrect. Also, it can help when new DNS records have not yet replicated to all DNS servers or when you need to test a copy of your website on a backup host. Although, you can use an IP address to directly contact a host, there are instances such as when connecting to web sites sharing a single IP address, where this is not possible.

The file is located in the %WinDir%\System32\drivers\etc\ folder and it is called Hosts. It contains the mappings of IP addresses to host names. Although, the file has no extension you can still open it using a text editor such as, Notepad and add new entries or edit existing ones. However, to edit this file you need administrative rights. To enable name resolution without using DNS, add a new line to Hosts file as shown in the example below:

184.168.176.1 www.windows7library.com

Each entry should be kept on an individual line. The IP address should be placed in the first column followed by the corresponding host name. The IP address and the host name should be separated by at least one space.

After adding your new entries, save the file and you are ready to go that is, contacting these servers using their host name. Windows will use the entries in the Hosts file first, before contacting a DNS server and this is always the case with the exception of the command line tool Nslookup. Nslookup is the only application that bypasses the Hosts file and contacts DNS servers directly.

Although, Hosts files can help you troubleshoot certain specific issues with name resolution, it is important to remember to remove any new entries after you finish troubleshooting. Hosts files can become unmanageable if they contain multiple entries and you will encounter name resolution problems if you forget to update the file when servers’ IP addresses change. For the same reason, it is not recommended to use Hosts files to replace DNS services in corporate environments.

Share