Lmhosts - Getting it to work

I have some questions...

Can i use lmhosts to have multiple names point to a single ip, i.e       magic    #pre       server   #pre

so if i go \\server  or \\magic, i open up the same computer     50 points

Another question

if i do a         nbtstat -c

why doesnt it show those entries after i have rebooted, is there a log that shows if lmhosts was loaded to the nbt cache?          125 points

how do i know if Lmhosts is working?  40 points


where does the lmhosts file have to reside for it be access and what is its extension?  35

I might throw in 50 extra points if you can provide insight into the workings of lmhosts file

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

"lmhosts" is for NetBIOS name resolution.  On legacy Microsoft networks that don't have a WINS (NBNS) server, this file can help resolve those names.  On Microsoft's more modern operating systems (Windows 2000 and later), if all your applications support DNS, this would be the better way of resolving names.  On these networks, if you don't have a DNS server to resolve your local names, you can use the "hosts" file.  It behaves pretty much the same way but does not use the #PRE and other # options.

Both of these files reside in %SystemRoot%\System32\Drivers\Etc
None of them have an extension but both can be edited using notepad.exe

As far as having two different names for the same IP, yes, I do this on my network and it works fine.

Entries with #PRE are loaded into the cache when you reboot however, maybe the case matters?  Try with uppercase and see if it makes a difference... let us know.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jjk16Author Commented:
if the entries are loaded in my cache, why cant i see them with a nbtstat -c?
its always empty
Here are some links to really good detailed information:

How to Write an LMHOSTS File for Domain Validation and Other Name Resolution Issues

plemieux72 has a point. Everything should be in uppercase in the LMHOSTS file..
Also, be sure to use the <TAB> between columns, not spaces<tab>MAGIC<tab>#PRE<tab>SERVER<tab>#PRE

Make the changes, and you can refresh the cache with "nbtstat -R"  <- that's a capital "R"

ON-DEMAND: 10 Easy Ways to Lose a Password

Learn about the methods that hackers use to lift real, working credentials from even the most security-savvy employees in this on-demand webinar. We cover the importance of multi-factor authentication and how these solutions can better protect your business!

>how do i know if Lmhosts is working?
If the entries show up in the cache with "nbtstat -c"
And if you can ping both magic and server by name.

>if the entries are loaded in my cache, why cant i see them with a nbtstat -c?
Probably because your format is not correct, and/or you have a file extension, or it is in the wrong location.
jjk16Author Commented:
thanks for the info,  the caps on #PRE
are important, that was what was missing

however, my cache is still empty, i can ping the ips by name

they are not in my cache, and i cannot open via unc

\\server or \\magic

im testing this on my computer, so i should be able to open mine as i can do a  \\
and my computer name which is long,

my comp       xp sp2
jjk16Author Commented:
"Keyword entries in the LMHOSTS files of Microsoft Windows NT systems must be entered in uppercase to be recognized. If the keywords #INCLUDE and #PRE are not uppercase, they are considered to be comments"
Is NetBIOS over TCP/IP enabled?  What about "Enable LMHOSTS lookup" in the TCP/IP advanced properties WINS tab?
jjk16Author Commented:
it was setup as default, i changed it to enabled, still no dice, lmhosts lookup is also enabled

i was hoping that using lmhosts file would allow me to have easy names for certain computers, i.e magic, which when i run \\magic would open up the computer as  \\ipaddress even if the other machine name was different i,e    computername = dell0232
the lmhosts entry     dell      #PRE

would open up \\ or \\dell0232

Works just fine with my LMHOSTS file (notice that even the system name is all caps):
#      EMERALD4          #PRE        MAGIC2          #PRE

C:\>nbtstat -R
C:\>nbtstat -c

                  NetBIOS Remote Cache Name Table

        Name              Type       Host Address    Life [sec]
    MAGIC2         <03>  UNIQUE     -1
    MAGIC2         <00>  UNIQUE     -1
    MAGIC2         <20>  UNIQUE     -1
    EMERALD4       <03>  UNIQUE     -1
    EMERALD4       <00>  UNIQUE     -1
    EMERALD4       <20>  UNIQUE     -1

jjk16Author Commented:

lmhosts file...    MAGIC2    #PRE

 Directory of C:\WINDOWS\system32\drivers\etc

11/06/2004  01:32 PM    <DIR>          .
11/06/2004  01:32 PM    <DIR>          ..
03/31/2003  04:00 AM               734 hosts
11/06/2004  01:18 PM                27 lmhosts
03/31/2003  04:00 AM               407 networks
03/31/2003  04:00 AM               799 protocol
06/30/2004  09:32 PM             7,276 services
               5 File(s)          9,243 bytes
               2 Dir(s)  15,713,738,752 bytes free

C:\WINDOWS\system32\drivers\etc>edit lmhosts

C:\WINDOWS\system32\drivers\etc>nbtstat -R
    Successful purge and preload of the NBT Remote Cache Name Table.

C:\WINDOWS\system32\drivers\etc>nbtstat -c

Local Area Connection 3:
Node IpAddress: [] Scope Id: []

    No names in cache

Wireless Network Connection 2:
Node IpAddress: [] Scope Id: []

    No names in cache

C:\WINDOWS\system32\drivers\etc>ping magic2

Pinging magic2 [] with 32 bytes of data:

Reply from bytes=32 time<1ms TTL=128
Reply from bytes=32 time<1ms TTL=128
Reply from bytes=32 time<1ms TTL=128
Reply from bytes=32 time<1ms TTL=128

Ping statistics for
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 0ms, Average = 0ms

jjk16Author Commented:
tried on laptop too.. same thing,   Lrmoore,  you got some soft of magic beans i can plant to make this work? I dont need 24k gold eggs to come of a duck by i would like the lmhosts to work
jjk16Author Commented:
I figured it out,     you cannot load names to point to your ip,

              NetBIOS Remote Cache Name Table

    Name              Type       Host Address    Life [sec]
EMERALD        <03>  UNIQUE      -1
EMERALD        <00>  UNIQUE      -1
EMERALD        <20>  UNIQUE      -1

i just picked some arbitrary ip and name,  i guess the OS doesnt include itself in the cache, any insight is helpfull and i will be applying the points soon, thanks for the info
> i guess the OS doesnt include itself in the cache

Quite correct. I didn't realize you were trying to point to yourself all along...
Are you also trying to map a drive to yourself, too?
Also, make sure the names/ip's don't conflict with your hosts file...
jjk16Author Commented:
i was testing the lmhosts, on a known good, didnt realize that it has to be tested on remote connection. but thanks everyone's input
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.