Pcornel
Windows · DNS Client

hosts File

Cheat sheet · https://pcornel.dk/topic.php?topic=3093

Back to the Topic

Answer

The hosts file (C:\Windows\System32\drivers\etc\hosts) maps names to IP addresses locally and is checked before DNS. It is useful for testing, but forgotten entries are a common cause of odd name resolution.

Remember

  • The hosts file is checked before DNS.
  • Forgotten test entries cause odd resolution later.
  • Malware edits it to redirect sites.

First checks

  • Resolve-DnsName <name> — resolve via the Windows resolver
  • Get-DnsClientServerAddress — DNS servers per interface
  • Get-DnsClientCache — resolver cache
  • Get-DnsClientGlobalSetting — suffix search list
  • Clear-DnsClientCache — flush the cache

Verify in this order

hosts entries loaded into the cache → override DNS

Where it usually breaks

First mismatch in host/interface identity → local config/routing/name state → Windows service/provider → firewall/security/session → remote service → application-visible exchange; preserve identity/native error/pre-state before mutation.

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=3093

Confirmation

Confirm action

Continue?