Pcornel
Linux · DNS

DNS Troubleshooting

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

Back to the Topic

Answer

DNS troubleshooting on Linux separates where resolution fails: the application, nsswitch and /etc/hosts, the local stub, the upstream server, or the authoritative data.

Remember

Compare getent hosts (system path) with dig @<server> (direct). Timeouts point to network/firewall (UDP and TCP 53); NXDOMAIN to the name or search domain; wrong address to /etc/hosts, cache or stale records.

First checks

  • dig +trace <name> — follow delegation from the root
  • resolvectl status — DNS servers per link (systemd-resolved)
  • cat /etc/resolv.conf — configured nameservers
  • getent hosts <name> — resolution through the system path (nsswitch)
  • dig <name> @<server> — query a specific server

Commands

resolvectl
resolvectl domain wg0 '~vpn.example.com'
getent hosts name
resolvectl query name
dig @10.0.0.53 name
getent
dig

Verify in this order

application → nsswitch → hosts file → stub cache → upstream → authoritative answer

Where it usually breaks

First mismatch in link/interface → address/namespace → route/neighbor → firewall/policy → socket/daemon → DNS/TLS/SSH/application peer path; preserve identity/native diagnostic/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=2792

Confirmation

Confirm action

Continue?