Windows Server 2003 automatically resolves NetBIOS names for computers running TCP/IP on a local network. You can use an LMHOSTS file to resolve IP addresses of computers on other networks to which yours is connected by a gateway when a WINS server isn't available.
LMHOSTS is an ASCII file, with the entry format similar to entries in a Hosts file. In addition, LMHOSTS supports special keywords, explained later in this section. Windows Server 2003 includes a sample LMHOSTS file in \%systemroot%\system32\drivers\etc. As with the Hosts file, you should make a backup copy of LMHOSTS before modifying it.
Windows Server 2003 parses each line in LMHOSTS sequentially at startup, so you should place frequently accessed names at the top of the file for best performance. Following are a few rules for structuring an LMHOSTS file:
♦ Each entry must include the IP address in the first column, with the NetBIOS name in the second column. Additional keywords, if any, appear in subsequent columns. Columns are separated by at least one space or tab character. Some LMHOSTS keywords follow entries, while others appear on their own lines (discussed later in this section).
♦ Each entry must reside on a separate line.
♦ Comments begin with the pound (#) character, and special LMHOSTS keywords also begin with the # character. Keep comments to a minimum to improve parsing performance. Place frequently accessed entries near the top of the file for best performance.
♦ The LMHOSTS file is static. As with the Hosts file, you must manually update the file to create new entries or modify existing ones.
Windows Server 2003 TCP/IP reads the LMHOSTS file at system startup, and entries designated as preloaded by the #PRE keyword are read into the name cache at that time. Other entries are read only after broadcast name-resolution queries fail. Remember to place frequently used names near the top of the file and to keep comments to a minimum to improve performance.
You can include the following special keywords in an LMHOSTS file:
♦ #PRE. Preloads the entry into the name cache at startup. If you want names stored in a remote LMHOSTS file to be added to the name cache at startup, use the #INCLUDE and #PRE statements in combination, as in the following example:
#INCLUDE \\srv1\public\lmhosts #PRE
♦ #DOM:<domain>. Designates remote domain controllers located across one or more routers. Entries that use the #DOM keyword are added to a special Internet workgroup name cache that causes Windows Server 2003 TCP/IP to forward requests for domain controllers to remote domain controllers as well as local domain controllers. The following example identifies a domain controller named server1 in the domain west. mcity.us and preloads the entry into the name cache at startup:
192.168.0.212 server1 #PRE #DOM:west.mcity.us
♦ #INCLUDE<filename>. Includes entries from separate LMHOSTS files. Use #INCLUDE to include entries from a common, shared LMHOSTS file or your own set of entries stored on your own computer. If you reference a remote LMHOSTS file on a server outside of your network in an #INCLUDE statement, you must also include an entry for the IP address of the remote server in the LMHOSTS file before the #INCLUDE statement that references it. Do not use #INCLUDE to reference an LMHOSTS file on a redirected network drive unless your drive mappings remain the same from one session to another. Otherwise, use the UNC path for the file. The following example includes an LMHOSTS file from a network server:
#INCLUDE \\server1\public\Lmhosts #Includes shared Lmhosts file
♦ #BEGIN_ALTERNATE. Signals the beginning of a block inclusion, a block of multiple #INCLUDE statements. The statements within the block designate primary and alternative locations for the included file; the alternative locations are checked if the primary file is unavailable. Successful loading of any entry in the block causes the block to succeed, and subsequent entries in the block are skipped. You can include multiple block inclusions within an LMHOSTS file. Following is an example of a block inclusion:
#INCLUDE \\server1\public\lmhosts #Primary source
#INCLUDE \\server2\public\lmhosts #Alternate source
#INCLUDE \\netserv\shared\lmhosts #Alternate source
Tip Addresses of servers specified in a block inclusion must be preloaded through entries earlier in the file. Entries not preloaded are ignored.
♦ #END_ALTERNATE. This signals the end of a block of multiple #1 INCLUDE statements.
♦ \0xnn. Use this keyword to specify nonprinting characters in NetBIOS names. Enclose the NetBIOS name in quotation marks and use the \0xnn keyword to specify the hexadecimal value of the nonprinting character. The hexadecimal notation applies to only one character in the name. The name must be padded to a total of 16 characters, with the hexadecimal notation as the sixteenth character. The following is an example:
192.168.0.89 "janetrs \0x14" #Uses special character
Was this article helpful?