Name Resolution with Host Files

For computers located on remote subnets where WINS is not used, the HOSTS and LMHOSTS files provide mappings for names to IP addresses. This is the name resolution method used on internetworks before DNS and WINS were developed. The HOSTS file can be used as a local DNS equivalent. The LMHOSTS file can be used as a local WINS equivalent. Each of these files is also known as a host table. Sample versions of LMHOSTS and HOSTS files are added to the \systemroot\SYSTEM32\DRIVERS\ETC directory when you install Microsoft TCP/IP. These files can be edited using any ASCII editor, such as Notepad or Edit, which are part of Windows NT.

Microsoft TCP/IP can be configured to search HOSTS, the local host table file, for mappings of remote host names to IP addresses. The HOSTS file format is the same as the format for host tables in the 4.3 Berkeley Software Distribution (BSD) UNIX /etc/hosts file. For example, the entry for a computer with an address of 192.102.73.6 and a host name of trey-research.com looks like this:



192.102.73.6 trey-research.com

If you want a Windows NT Server to join a domain and perform domain operations, such as browsing or acting as a backup domain controller, when the primary domain controller (PDC) is on the other side of a router, you must add the Windows NT computer and domain names to the DNS server or the local HOSTS file, with the IP address of the PDC as the domain address. Here is a sample HOSTS file entry:




11.11.11.45 controller controller.domain controller.domain.company
11.11.11.45 domain

Where controller is the Windows NT computer name of the PDC and domain is the name of the Windows NT domain (not the DNS domain).

Edit the sample HOSTS file that is created when you install TCP/IP to include remote host names and their IP addresses for each computer with which you will communicate. This sample file also explains the syntax of the HOSTS file.

The LMHOSTS file is a local text file that maps IP addresses to NetBIOS computer names for Windows-networking computers that you will communicate with outside of the local subnet. For example, the LMHOSTS table file entry for a computer with an address of 192.45.36.5 and a computer name of Finance1 looks like this:



192.45.36.5 finance1

The LMHOSTS file is read when WINS or broadcast name resolution fails, and resolved entries are stored in a system cache for later access.

When the computer uses the replicator service and does not use WINS, LMHOSTS entries are required on import and export servers for any computers on different subnets participating in the replication. The LMHOSTS file is also used for small-scale networks that do not have servers. For more information about the LMHOSTS file, see Chapter 15, "Setting Up LMHOSTS."