Lmhost File to Solve Some DNS Issues

From FactotumNW Wiki

Jump to: navigation, search

How to write an Lmhosts file for domain validation and other name resolution issues

SUMMARY If you experience name resolution issues on your TCP/IP network, you may have to use Lmhosts files to resolve NetBIOS names. This article discusses the correct method to create an Lmhosts file to help in name resolution and domain validation.

MORE INFORMATION To create a correctly formatted Lmhosts file, follow these steps:

1. Use any text editor, such as Notepad.exe or Edit.com, to create a file named Lmhosts, and save it in the following folder:
Microsoft Windows NT
%SystemRoot%\System32\Drivers\Etc
Microsoft Windows 95
C:\Windows (the folder where Windows is installed)
Microsoft Windows NT and Windows 2000
%SystemRoot%\System32\Drivers\Etc
Note The file name is Lmhosts, without an extension. If you use Notepad.exe, it may automatically append the .txt extension. In this case, at a command prompt, you must rename the file using no extension.
2. Add the following entries to the Lmhosts file:
10.0.0.1 PDCNAME #PRE #DOM:DOMAIN-NAME
10.0.0.1 "DOMAIN-NAME \0x1b" #PRE
Note The domain name in this entry is case sensitive. Make sure that you use uppercase characters for the domain name. If you use lowercase characters for the domain name, NetBT does not recognize the name.
Note Make sure that you space these entries correctly. Replace 10.0.0.1 with the IP address of your primary domain controller (PDC). Replace PDCName with the NetBIOS name of your PDC, and replace domain with your Windows NT domain name. There must be a total of 20 characters within the quotations (the domain name plus the appropriate number of spaces to pad up to 15 characters, plus the backslash, plus the NetBIOS hex representation of the service type).
To help determine where the sixteenth character is, copy the following line to your Lmhosts file:
  1. IP Address "123456789012345*7890"
Line up the double quotation marks (") by adding or removing spaces from the comment line, and put the \ on the sixteenth column (the column marked with the asterisk). You must use spaces after the name and before the \, not a tab.


NetBIOS Suffixes (16th Character of the NetBIOS Name)

1. After you add the lines, save the file, and exit the editor.
2. At a command prompt, type nbtstat -R, and then press ENTER.
Note The -R is case sensitive and must be uppercase. After you type this text, you should receive the following message:
Successful purge and preload of the NBT Remote Cache Name Table.
3. At a command prompt, type nbtstat -c, and then press ENTER.
Note The -c is case sensitive and must be lowercase. After you type this text, you should receive a display that is similar to the following:
Node IpAddress: [10.0.0.5] Scope Id: []
NetBIOS Remote Cache Name Table
Name Type Host Address Life [sec]

PDCName <03> UNIQUE 10.0.0.1 -1
PDCName <00> UNIQUE 10.0.0.1 -1
PDCName <20> UNIQUE 10.0.0.1 -1
Domain <1B> UNIQUE 10.0.0.1 -1


from <http://support.microsoft.com/kb/q180094/>


More Lmhosts info

Domain Browsing with LMHOSTS

Without WINS, you need special LMHOSTS entries that designate who all the domain controllers are. This is done in the following convention:

199.199.199.1 ComputerName #PRE #DOM:DomainName


When a computer is booted, it reads these entries and store them permanently in the NetBIOS name cache until the computer is powered down. (Because of this, it is best that these entries are last in the LMHOSTS file, for subsequent LMHOSTS parsing efficiency.) All computers in the domain needs one of these entries for each domain controller (in the local domain), as well as one for the PDC. Also note the exact order of #PRE #DOM, and that they are capitalized. The other names are not case sensitive.


LMHOSTS Example

Your domain name is "Globe", your PDC NetBIOS name is "Mongo", and you have other various backup domain controllers. Your LMHOSTS file would look like this:

199.199.199.1 "globe \0x1b" #PRE
199.199.199.1 mongo #PRE #DOM:globe
199.199.199.2 otherdc1 #PRE #DOM:globe
199.199.199.3 otherdc2 #PRE #DOM:globe

To verify that you've entered these correctly, open a command window (DOS prompt) and look at your NetBIOS cache:

c:\> nbtstat -c
NetBIOS Remote Cache Name Table
Name Type Host Address Life [sec]
------------------------------------------------------------
globe <1B> UNIQUE 199.199.199.1 -1
MONGO <03> UNIQUE 199.199.199.1 -1
MONGO <00> UNIQUE 199.199.199.1 -1
MONGO <20> UNIQUE 199.199.199.1 -1
OTHERDC1 <03> UNIQUE 199.199.199.2 -1
OTHERDC1 <00> UNIQUE 199.199.199.2 -1
OTHERDC1 <20> UNIQUE 199.199.199.2 -1
OTHERDC2 <03> UNIQUE 199.199.199.3 -1
OTHERDC2 <00> UNIQUE 199.199.199.3 -1
OTHERDC2 <20> UNIQUE 199.199.199.3 -1

TIP: the <1B> entry will not show up if you do not have exactly 15 characters in the name, or if you do not use quotes, or if you enter the forward slash "/0x1b" (as opposed to "\0x1b").

Personal tools