Use it when a name does not resolve on a host — especially when dig works and the application does not.
DNS Resolver
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.
1. getent hosts <name> — does the system path resolve it?
2. Wrong address → look in /etc/hosts first.
3. No answer → resolvectl status: which servers are in use?
4. dig <name> @<server> — does that server answer? No → network or server.
5. Full name works, short name fails → search domain.
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
For DNS → DNS Resolver, continue with the first unproven Topic check: Identify the exact process/API and whether it uses libc/NSS, systemd-resolved, a language runtime or an embedded DNS client. If that boundary is healthy, advance to the adjacent check: Read hosts ordering and resolver options such as search/domain, ndots, attempts, timeout and rotate where applicable. Preserve the same host/time/identity scope and rerun the original workload before accepting recovery.
Continue only after interpreting the current observation.Context & applicabilityCommon mistakes · platform/version boundaries
- "
digresolves it, so name resolution works."digbypasses/etc/hosts, the lookup order and the local cache; usegetent hosts. - "The servers in
/etc/resolv.confare the ones in use." With systemd-resolved the file points at 127.0.0.53; seeresolvectl status. - "I edited
/etc/resolv.conf." It is regenerated by the network manager; the edit will not last. - "The second name server is used if the first has no record." Only if the first does not respond at all.
- "A short name fails, so DNS is broken." The search domain may be missing; try the full name.
- "It is a DNS problem." A stale line in
/etc/hostsanswers before DNS is ever asked. - "The container uses the host's DNS settings." It has its own resolver file.
Operational reference
Fast context before you go deeper.
resolvectl status | query <name>Primary Commands
Configuration and operational commands for this Topic.
resolvectl status | query <name>ReferenceInspect systemd-resolved DNS state/query path.
Linux · mixed · verifiesip -brief addressReferenceRead current Linux Networking state for a bounded verification step.
Use when: Use after confirming the Linux Networking target and before changing state.
Quick note: Linux · distribution/version specific. A successful command or active unit proves only local state; it does not prove dependency health, data integrity or client-visible service.
Linux · distribution/version specific · mixed · verifiesVerification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Capture the concrete output, symptom, packet, log or counter before changing anything.
Step 1 Operational evidence path Verify boundary
process resolver call → NSS hosts ordering → resolver/search options → local stub/cache → selected DNS backend → A/AAAA response → libc address ordering → application-selected endpoint
Healthy evidence: application-path resolution and diagnostic resolution agree on the intended FQDN/data after accounting for NSS, search and address-family policy.
Step 2 Operational verification Verify boundary
Resolver configuration, systemd-resolved or resolv.conf behavior, lookup tools and failure points.
Fast verification
- Check
/etc/resolv.confownership/content andresolvectl statuswhen systemd-resolved is used.
- Query the configured resolver directly with dig @server name to separate resolver reachability from application behavior.
- Compare search domains, split DNS and cache state before changing global DNS.
Step 3 Verification and output interpretation Verify boundary
For DNS, separate direct IP connectivity from name-resolution path and compare the application’s resolver with manual tools.
Existing fast checks for this Topic. - Identify the exact process/API and whether it uses libc/NSS, systemd-resolved, a language runtime or an embedded DNS client.
- Read hosts ordering and resolver options such as search/domain, ndots, attempts, timeout and rotate where applicable.
- Compare getent/application resolution with resolvectl and direct dig queries to the selected server, preserving A/AAAA and FQDN/search behavior.
- Verify the final address choice and original connection rather than stopping at one successful query tool.
Verification chain. process resolver call → NSS hosts ordering → resolver/search options → local stub/cache → selected DNS backend → A/AAAA response → libc address ordering → application-selected endpoint
Step 4 Commands Verify boundary
resolvectl query example.com
getent hosts example.com
cat /etc/nsswitch.conf | grep hosts
Step 5 Failure modes and next checks Narrow the fault
Suspicious evidence: direct dig succeeds while getent/application lookup fails, short names expand unexpectedly, AAAA selection causes delay/failure, or resolver retries/timeouts point to a different backend than expected.
Resolver evidence requires that the same resolution API/path used by the application returns the intended result under the effective NSS/search/address-family policy; a standalone DNS query alone is insufficient.
Step 6 Common mistakes Narrow the fault
- Testing DNS with tools that bypass the system resolver.
Evidence · 1 on this Topic
Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.
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.
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.
ReferenceWhat it is2 sections · depth on demand
Core model
Treat the resolver as a decision path rather than a single server address. Determine whether the application calls getaddrinfo/gethostbyname or implements DNS itself, read effective nsswitch/resolver policy, account for search/ndots and A/AAAA selection, then trace the resulting query to the chosen backend. Direct DNS tools can bypass important parts of this path.
Mental model
When a program on Linux looks up a name, it does not talk to a DNS server directly. It asks the system's resolver library, which follows a configured order — usually the /etc/hosts file first, then DNS — and sends DNS queries to the servers listed for the system, often through a local caching service.
ReferenceWhy it matters2 sections · depth on demand
When to use it
Use this Topic when the problem is in DNS Resolution. Use Linux Networking when the problem concerns Linux runtime, services, networking, identity, packages, storage or shell automation.
Why it matters operationally
"DNS works with dig but the application cannot resolve the name" is a common and confusing report. It happens because dig goes straight to a DNS server while applications go through the system's resolver path, with its own files, search domains and cache. Testing the path the application actually uses is what settles it.
ReferenceHow it works1 section · depth on demand
How it works
The lookup order is set in /etc/nsswitch.conf:
hosts: files dns
files means /etc/hosts; dns means DNS servers. With this line an entry in /etc/hosts wins over DNS. Other sources such as myhostname, resolve or mdns may appear in the list.
Classic DNS configuration is /etc/resolv.conf:
nameserver 10.0.0.53
nameserver 10.0.0.54
search example.com corp.example.com
options ndots:1
Up to three name servers are used, in order: the second is tried only when the first does not answer, not when it answers "no such name". search lists the domains appended to short names.
systemd-resolved. On many current systems /etc/resolv.conf contains only nameserver 127.0.0.53. That address is a local caching service, systemd-resolved, which holds the real server list — possibly a different one per network interface. resolvectl status shows the servers and search domains actually in use, and resolvectl flush-caches empties its cache.
Who writes the file. /etc/resolv.conf is usually generated — by systemd-resolved, NetworkManager or a DHCP client — and manual edits are overwritten. Change the DNS servers in the tool that manages the connection.
Testing the right path.
| Command | Path used |
|---|---|
getent hosts <name> | The system resolver — what applications use |
resolvectl query <name> | systemd-resolved |
dig <name> | Directly to the first server in /etc/resolv.conf, ignoring /etc/hosts and the lookup order |
dig <name> @<server> | One specific server |
Containers get their own /etc/resolv.conf, written by the container runtime, which may differ from the host's.
ReferenceImportant terms & boundaries4 sections · depth on demand
What this shows and what it does not
Resolver evidence requires that the same resolution API/path used by the application returns the intended result under the effective NSS/search/address-family policy; a standalone DNS query alone is insufficient.
In depth
The stub resolver and its options
Linux programs use a stub resolver in the C library. It sends DNS queries to the recursive servers listed in /etc/resolv.conf, and returns the answers. The resolv.conf(5) manual page defines its behaviour:
- Up to three
nameserverlines are used, in order. The next one is tried when a query times out. With no nameserver line, a server on the local machine is assumed. searchlists the domains appended to short names. Names with fewer dots thanndots(default 1) are tried with each search domain first.timeout(default 5 s) andattempts(default 2) control retries.rotatespreads queries across the servers.edns0,single-requestandtrust-adadjust protocol details.
What the defaults mean in practice
| Situation | Effect |
|---|---|
| The first nameserver is down | Every lookup waits 5 s before trying the second |
| Three nameservers, all down | Up to timeout × attempts × servers seconds before failure |
search example.net and the name db1 | Queries db1.example.net first |
ndots:5 (Kubernetes) | Names with fewer than 5 dots try every search domain before the name itself |
Lookup debugging
| Tool | Purpose |
|---|---|
getent hosts name | What applications get (nsswitch, hosts file, resolver) |
dig @server name | Ask one specific server |
dig +search name | Apply the search list like the stub resolver |
dig +trace name | Follow delegation from the root |
resolvectl query name | Through systemd-resolved |
Slow lookups
Slow name resolution is most often caused by a dead first nameserver, or by a long search list combined with a high ndots. Every lookup then waits for timeouts, or generates several useless queries. Remove or replace the dead server, and keep search lists short.
host$ cat /etc/resolv.conf
search example.net corp.example.net
nameserver 10.20.0.53
nameserver 10.20.0.54
options timeout:2 attempts:2 rotate
host$ time getent hosts api.partner.example.org
real 0m4.012s
host$ dig @10.20.0.53 api.partner.example.org +time=1 +tries=1
;; communications error to 10.20.0.53#53: timed out
host$ dig @10.20.0.54 +short api.partner.example.org
198.51.100.80
host$ dig +search +short db1
10.30.0.41
Reading the example
The lookup takes 4 seconds, and querying each server directly shows why: 10.20.0.53 doesn't answer. With timeout:2, every lookup first waits 2 seconds for it. The other server answers immediately.
Documented example, not captured output.
How it works at runtime
DNS Resolver is part of DNS → DNS Resolver. DNS Resolver covers the Linux host resolution path used by applications, including libc resolver behavior, NSS ordering, search-domain expansion, address-family selection, resolver retries and the boundary between local resolution policy and external DNS servers.
DNS adds NSS/resolver selection, per-link/global server policy, caches and upstream recursion/authority.
Topic-specific state model. DNS Resolver covers the Linux host resolution path used by applications, including libc resolver behavior, NSS ordering, search-domain expansion, address-family selection, resolver retries and the boundary between local resolution policy and external DNS servers.
Interpretation rule. - dig works ≠ getaddrinfo works; direct tools can bypass NSS, search expansion, local hosts and application resolver libraries.
- nameserver reachable ≠ resolver policy selects it for the queried name or interface.
- A record correct ≠ application address selection is correct when AAAA, Happy Eyeballs or family restrictions apply.
- Resolver timeout ≠ DNS server failure; routing, firewall, MTU, stub/cache or application policy can fail first.
Limits and how it fails
Primary failure point. Resolver evidence requires that the same resolution API/path used by the application returns the intended result under the effective NSS/search/address-family policy; a standalone DNS query alone is insufficient.
Model. Interface UP does not show carrier, addressing, routing, neighbor resolution, firewall passage, DNS or application service.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Authoritative/upstream documentation reviewed for bounded claims in DNS → DNS Resolver. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://www.freedesktop.org/software/systemd/man/latest/systemd-resolved.service.html · confidence 94%What changed and what may be affected
Recent technical edits are separated from ordinary page timestamps. Relationship impact is advisory: it identifies nearby canonical references to review, not automatic breakage.
Terms & aliases
Hover a linked term for a quick definition; click it to open its glossary entry. Aliases are other names that find this Topic in search.
Quick lookup tables
DNS Resolver operational reference
Topic-specific lookup boundaries, proof limits and next-step Evidence for DNS Resolver.
| Lookup boundary | Topic-specific reference | Operational use |
|---|---|---|
| Scope / effective state | DNS Resolver covers the Linux host resolution path used by applications, including libc resolver behavior, NSS ordering, search-domain expansion, address-family selection, resolver retries and the boundary between local resolution policy and external DNS servers. | Establish exactly what this Topic owns before crossing into another subsystem. |
| Fast verification | Pin exact host/namespace + original name or endpoint → capture link/address/route/resolver state → reproduce original failure → localize first failed resolver/network boundary → collect bounded packet/socket or DNS evidence → change one demonstrated cause → read back effective state → repeat original application transaction and an adjacent regression check. | Use the shortest evidence path first; a fast check is a boundary test, not blanket proof. |
| Verification chain | process resolver call → NSS hosts ordering → resolver/search options → local stub/cache → selected DNS backend → A/AAAA response → libc address ordering → application-selected endpoint | Trace requested/configured state through effective state to the observed workload result. |
| Failure boundary | Resolver proof requires that the same resolution API/path used by the application returns the intended result under the effective NSS/search/address-family policy; a standalone DNS query alone is insufficient. | Stop broad troubleshooting at the first boundary that is not supported by evidence. |
| Positive evidence | Correlated Linux DNS/network evidence can establish this proof path: process resolver call → NSS hosts ordering → resolver/search options → local stub/cache → selected DNS backend → A/AAAA response → libc address ordering → application-selected endpoint | Use this observation only for the specific claim it actually supports. |
| Evidence limit | It does not independently prove behavior outside the captured host/network namespace, resolver path or DNS view, interface/source, destination/protocol/port, capture point, time or workload scope. Resolver proof requires that the same resolution API/path used by the application returns the intended result under the effective NSS/search/address-family policy; a standalone DNS query alone is insufficient. | Do not promote a local success signal into end-to-end or adjacent-dependency proof. |
| Next troubleshooting check | Continue from the first unproven DNS/network boundary: preserve the original source and failure conditions, capture the adjacent resolver/socket/packet state, change only the demonstrated cause, then repeat the original application lookup or transaction and adjacent regression checks. | Continue to the next unresolved boundary while preserving the original test condition. |
DNS Resolver · operational reference
Compact Linux state, persistence, verification and boundary reference for fast lookup.
| Reference boundary | DNS Resolver |
|---|---|
| Topic path | DNS → DNS Resolver |
| Runtime state | DNS Resolver covers the Linux host resolution path used by applications, including libc resolver behavior, NSS ordering, search-domain expansion, address-family selection, resolver retries and the boundary between local resolution policy and external DNS servers. |
| Fast checks | - Identify the exact process/API and whether it uses libc/NSS, systemd-resolved, a language runtime or an embedded DNS client. - Read hosts ordering and resolver options such as search/domain, ndots, attempts, timeout and rotate where applicable. - Compare getent/application resolution with resolvectl and direct dig queries to the selected server, preserving A/AAAA and FQDN/search behavior. - Verify the final address choice and original connection rather than stopping at one successful query tool. |
| Verification chain | process resolver call → NSS hosts ordering → resolver/search options → local stub/cache → selected DNS backend → A/AAAA response → libc address ordering → application-selected endpoint Boundary chain: local authoritative state → adjacent dependency → effective/programmed state → original workload/request → return/regression → explicit Evidence boundary. |
| Failure boundary | Resolver proof requires that the same resolution API/path used by the application returns the intended result under the effective NSS/search/address-family policy; a standalone DNS query alone is insufficient. Boundary chain: process/socket namespace → source/rule/FIB → neighbor → netfilter/eBPF/qdisc → virtual/physical device → peer → return → application. |
| Persistence rule | Prove which configuration source owns the state, then prove that the running consumer loaded or generated the intended state. |