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:
Create an empty list of matching IP addresses.
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.
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.
Read a line from the LMHOSTS file.
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.
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.
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.