Dela via


3.1.8 Using the LMHOSTS File to Resolve a Name Query

When NetBIOS name resolution, which uses NetBIOS protocols, does not result in successful name resolution, and if ReadLMHostsFile is TRUE and the LMHOSTS file exists, the ComputersQuery MUST read the LMHOSTS file for NetBIOS name resolution to an IPv4 address.

When resolving a name, the LMHOSTS file MUST be opened and read, and a search is made for a matching entry, or entries, so that name resolution can return a list of IP addresses. The LMHOSTS file MUST be read sequentially, matching the name in the query with the name of an entry read from the LMHOSTS file until all matches are found, or no additional entries are in the LMHOSTS file. The matching function works as follows:

  1. Create an empty list of matching IP addresses.

  2. If the 16th byte of the query name is 0x1C, then search the list of domain names (LMHOSTS entries with the #DOM qualifier) that were preloaded in the Local Name Table during NetBIOS initialization. If the query name matches a domain entry, then add that entry's IP address to the list and further processing MUST stop.

  3. Search the Local Name Table for a match of names preloaded during NetBIOS initialization. If the query name matches an entry, then add that entry's IP address to the list and further processing MUST stop.

  4. Read a line from the LMHOSTS file.

  5. If the NetBIOS name from the LMHOSTS file is less than 16 bytes in length, pad the name with spaces, and uppercasing all characters within the ASCII range which results in ComputerName. If the resulting ComputerName and the query name match, then add the entry's IP address to the list of matching IP addresses. If there is no #MH tag on the entry, then further processing of the LMHOSTS file MUST stop.

  6. If the NetBIOS name from the LMHOSTS file is exactly 16 bytes in length, then this results in ComputerName. If the resulting ComputerName and the query name, then add the entry's IP address to the list of matching IP addresses. If there is no #MH tag on the entry, then further processing of the LMHOSTS file MUST stop.

  7. If there are more entries from the LMHOSTS file to be read, loop to step four.

Name resolution returns the list of matching IP addresses.

The #INCLUDE facility in LMHOSTS can result in reading additional files.