Windows – the difference between hosts and lmhosts files

domain-name-systemwindows

What is the difference between hosts and lmhosts files?

Best Answer

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.