What is the difference between hosts and lmhosts files?


The letters "LM"? >smile<

The "HOSTS" file contains entries that simulate "A" records in DNS (and PTR records, too). Only DNS-legal names are allowed in this file.

The "LMHOSTS" file contains entries that simulate NetBIOS name resolution responses (and they have a baroque little mini-language to let you preload entries into the NetBIOS name resolution cache, specify domain entries, and include other files). Only NetBIOS-legal names are allowed in this file.

Name resolution APIs are a little muddled in Windows. It's possible for an application to make a DNS resolution request only (in which case the HOSTS file would return a result if such an entry existed), or to make a different call that can end up querying both files (via a NetBIOS and DNS name lookup). There are some nasty fiddly bits about resolution provider order that we actually worried about back in the Windows NT 4.0 days but, thankfully, have passed out of my regular use (and thus my memory).

BTW: It's 2009-- don't use either one of them for anything in a production network. It sounds harsh, but it's the truth. When you say "Gee-- I have a problem and I think I'll solve it with a HOSTS file", all you've done is create another problem.

  • 1
    +1 Purely for the "don't use either one..." caveat! – Marko Carter Aug 5 '09 at 15:02
  • I disagree with your last statement. Host files are indeed useful if not necessary sometimes, even in 2009. – Tatas Aug 5 '09 at 15:33
  • 1
    @Tatas: I don't agree w/ using HOSTS files in any kind of production network. It puts name resolution state information on client computers, where it doesn't belong, instead of on server computers, where it does belong. If your DNS server can't do some kind of "trick" that makes you say "Gee, I need a HOSTS file" than it probably means that you need a better DNS server (BIND to do "views" versus Windows DNS, etc). It sounds a bit harsh, I suppose, but making a commitment to using only server-based name resolution is making a commitment to a more maintainable infrastructure, long-term. – Evan Anderson Aug 5 '09 at 15:38
  • 1
    Whilst in theory I agree, in practical terms the HOST file is invaluable. Only last week did we update some laptops hosts files to redirect certain addresses to to stop a problem with one of our systems. This is handled when the users are in the office by the network DNS servers, but when our laptops are out and about using ISP dns servers, the problem exists. So yes, whilst I agree it is not ideal - it definately has its uses, even in these modern times. – Kip Aug 5 '09 at 16:28
  • 1
    @Kara: I agree re: triage and temporary usage. I don't agree with any permanent "solution" using a HOSTS file and I'd wager that I can "win" any argument on using it as a permanent "solution". Kip, for example, needs a managed recursive DNS service for his laptop computers, either through a public DNS server he runs, a contracted provider, or via a VPN tunnel to a DNS server he controls. I suppose somebody could write a Windows service-based "HOSTS file management" system that would make managing a fleet of HOSTS files efficient but, come on, we already have DNS. – Evan Anderson Aug 5 '09 at 17:27

HOSTS is for hostname (DNS) resolution. LMHOSTS is for NetBIOS name resolution.



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.