Using a Hosts file for name resolution in Windows Server 2008



A Hosts file maintains a host table that maps host names to IP addresses. Windows can look up entries in the Hosts file to resolve names without requiring to query a DNS server for resolution. Windows Server 2008 creates a file named Hosts in the \%systemroot%\system32\drivers\etc folder. Hosts is an ASCII file which you can modify in Notepad or any other word processor. The file uses the same format as the Hosts file on 4.3 BSD Unix (stored in /etc/hosts) and by default contains an entry that maps localhost to 127.0.0.1 (which is used for loopback testing and troubleshooting).

Entries in the Hosts file take the format IP Address <tab> host name. You can specify more than one host name for a given IP address, but you must use multiple entries for hosts in different domains, each entry on its own line. Entries in Hosts are case-sensitive, so in the following example, the first two entries enable a correct resolution if the user specifies the host name in either uppercase or lowercase:

Code:
192.160.0.124		joe.mcity.us
192.160.0.124		JOE.MCITY.US
192.168.0.203		jane.west.mcity.us
You can include a single host name for each entry or specify multiple host names for a single IP address if they fall in the same domain. The following examples are valid entries:

Code:
192.168.0.224		me	tarzan		jim.west.mcity.us
192.168.0.198		you	jane		jane.east.mcity.us
Each of the entries in this example specifies three host names for each IP address. Windows Server 2008 parses the entries in the Hosts file in sequential order until it finds a match. You can speed up lookup time by placing the most frequently used host-name entries at the top of the file.