For people to reach your Web site, you must have a unique IP address that identifies your computer on the network. This address is a long string of numbers separated by dots, for example, 172.16.255.255. Because a numeric address is difficult for people to remember, text names or friendly names, are used to provide visitors with an easy-to-remember address, such as \\MyStoredFiles. Name resolution involves interpreting the correct numerical address from the friendly name a user types into a client browser. This section describes different name resolution systems.
The use of an LMHOSTS file is optional. If an LMHOSTS file is not used, however, you cannot use friendly text names. Instead, you must use IP addresses. This can be a disadvantage because Web sites on the Internet usually use the DNS. If you register a domain name for your Web site, users can contact your Web site by typing its domain name in a browser.
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 replication service and does not use WINS, LMHOSTS file entries are required on import and export servers for any computers on different subnetworks participating in the replication.
You can use Microsoft Notepad or any text editor to edit the sample LMHOSTS.sam file that is automatically installed in the Windows directory. The following rules apply for entries in the LMHOSTS file:
The keywords listed in the following table can be used in the LMHOSTS file. Notice, however, that LAN Manager 2.x treats these keywords as comments.
|#PRE||Causes an entry to be preloaded into the name cache. This keyword is added after an entry. The #PRE keywords in the LMHOSTS file are looked up and cached prior to WINS lookup. #PRE must be appended for entries that also appear in #INCLUDE statements; otherwise, the entry in #INCLUDE is ignored.|
|#DOM:domain||Associates an entry with the domain specified by domain. This keyword is added after an entry, and it affects how the browser and logon services behave in routed TCP/IP environments. To preload a #DOM entry, you must also add the #PRE keyword to the line.|
|#INCLUDE filename||Forces the system to seek the specified filename and parse it as if it were local. Specifying a universal naming convention (UNC) filename allows you to use a centralized LMHOSTS file on a server. You must map the server before its entry in the #INCLUDE section, and also append #PRE to ensure that it is preloaded (otherwise the #INCLUDE will be ignored).|
|#BEGIN_ALTERNATE||Groups multiple #INCLUDE statements. Any single successful #INCLUDE statement causes the group to succeed.|
|#END_ALTERNATE||Marks the end of an #INCLUDE grouping.|
|\0xnn||Supports nonprinting characters in NetBIOS names. Enclose the NetBIOS name in quotation marks and use \0xnn hexadecimal notation to specify a hexadecimal value for the character. This allows custom applications that use special names to function properly in routed topologies. However, LAN Manager TCP/IP does not recognize the hexadecimal format, so you surrender backward compatibility if you use this feature.
Notice that the hexadecimal notation applies only to one character in the name. The name should be padded with blanks so the special character is placed as the last, or 16th, character in the string).
The following example shows how all of these keywords are used.
126.96.36.199 localsrv #PRE 188.8.131.52 trey #PRE #DOM:networking #net group's PDC 184.108.40.206 "appname \0x14" #special app server 220.127.116.11 popular #PRE #source server #BEGIN_ALTERNATE #INCLUDE \\localsrv\public\LMHOSTS #adds LMHOSTS files from this server #INCLUDE \\trey\public\LMHOSTS #adds LMHOSTS files from this server #END_ALTERNATE
Note the following points from the preceding example:
treyare preloaded so they can be used later in an
#INCLUDEstatement in a centrally maintained LMHOSTS file.
"appname \0x14"contains a special character after the 15th character, including blanks, in its name, so its name is enclosed in quotation marks.
popularis preloaded, based on the
Guidelines for LMHOSTS Files
When you use a host table file, be sure to keep it up-to-date and organized. Use the following guidelines:
#PREstatements to preload popular entries into the local computer's name cache. Also use
#PREstatements to preload servers that are included with
#INCLUDEstatements. Type the
#PREentries at the end of the file because these statements are preloaded into the cache at system startup time and are not accessed later. Remember that comment lines add to parsing time because each line is processed individually.
To edit the LMHOSTS file
By default, the box below the check box contains the current LMHOSTS file configuration; however, if there are no entries to be seen, the box will be empty.