Using the HOSTS file for local name resolution

Posted: (EET/GMT+2)

 

Resolving IP addresses often uses the DNS system, but if you need to resolve host names without using a DNS server, Windows supports local name resolution through the HOSTS file.

The HOSTS file contains mappings between host names and IP addresses. It is a simple text file with space/tab delimited syntax.

On Windows NT, the file is typically located in:

C:\WinNT\System32\Drivers\Etc\HOSTS

Note that there is no file extension, such as .txt. A simple HOSTS file might look like this:

192.168.0.10    intranet
192.168.0.20    dbserver
192.168.0.30    filesrv

After saving the file, applications can use the host names directly:

ping intranet
ping dbserver

The TCP/IP stack checks the HOSTS file before querying DNS servers. This makes it useful for testing, small networks, or temporary overrides during troubleshooting, because the file takes precedence.

But, be careful to keep entries up to date, especially if IP addresses change. And don't forget you added one in the first place!