Skip to contentGo to the directory tree
FileRisk: Safe

lmhosts.sam C:\Windows\System32\drivers\etc\lmhosts.sam

Sample (.sam) file for LMHOSTS, which maps NetBIOS names to IP addresses; it has no effect until copied to a file named 'lmhosts'.

Updated on By AltF4 Formation

What it’s for

lmhosts.sam is the commented sample of the lmhosts file, which resolves NetBIOS names to IP addresses when NetBIOS over TCP/IP is in use, alongside WINS and broadcast. Only a file named lmhosts, with no extension, is read: until you copy the sample under that name, lmhosts.sam has no effect.

What it contains

  • Comment lines explaining the address name [#PRE] [#DOM:domain] syntax.
  • Directives: #PRE (preload into the cache), #DOM (domain controller) and #INCLUDE (include another file).
  • No active entry.

Risks and best practices

  • The sample can stay or go with no consequence.
  • An lmhosts file created later can redirect NetBIOS names, much as hosts does for DNS, so an unexpected entry deserves investigation.
  • NetBIOS over TCP/IP is a legacy protocol. If your environment allows it, disabling it reduces exposure.

Useful commands

Fenêtre de terminal
# Read the sample
Get-Content "$env:windir\System32\drivers\etc\lmhosts.sam"
# Is there an active lmhosts file?
Test-Path "$env:windir\System32\drivers\etc\lmhosts"
# Current NetBIOS name cache
nbtstat -c

Report a mistake