DNS Resolver
Cheat sheet · https://pcornel.dk/topic.php?topic=366
Answer
Programs on Linux resolve names through the system resolver, which follows /etc/nsswitch.conf — usually /etc/hosts first, then DNS — and sends queries to the system's DNS servers, often through the local cache systemd-resolved.
Remember
dig goes straight to a DNS server and skips /etc/hosts and the lookup order; getent hosts tests what applications use. With systemd-resolved, /etc/resolv.conf shows 127.0.0.53 — the real servers are in resolvectl status. The file is generated; edits do not last.
First checks
getent hosts <name>— the system resolver, as applications see it.resolvectl status— DNS servers and search domains in use, per interface.resolvectl query <name>— a lookup through systemd-resolved.dig <name> @<server>— one specific DNS server.cat /etc/resolv.confandgrep hosts /etc/nsswitch.conf— the configuration.
Commands
ip -brief address- Read current Linux Networking state for a bounded verification step.
resolvectl status | query <name>- Inspect systemd-resolved DNS state/query path.
resolvectl statusdig @server namegetent hosts namedig +search namedig +trace nameresolvectl query namedigresolvectl flush-cachesgetent hosts <name>resolvectl query <name>dig <name>dig <name> @<server>getent hosts
Verify in this order
application asks the resolver library → nsswitch order → /etc/hosts → local cache (systemd-resolved) → configured DNS server reachable → server returns the record → answer cached and returned
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=366