Use it as the entry point for name resolution problems on a Linux host.
DNS (Domain Name System)
DNS on Linux: applications resolve names through glibc, which follows /etc/nsswitch.conf (usually files, then dns); DNS queries go to the servers in /etc/resolv.conf — often the systemd-resolved stub 127.0.0.53, which forwards to the real servers.
1. getent hosts <name> — what applications get.
2. resolvectl status — upstream servers per link.
3. dig <name> @<server> — does the server answer?
4. /etc/hosts overriding?
5. Search domain correct for short names?
application → glibc → nsswitch (files, dns) → resolv.conf / stub → upstream DNS → answer
For DNS, continue with the first unproven Topic check: Capture the exact hostname/FQDN, record type, address family, process context and failure time before changing resolver state. If that boundary is healthy, advance to the adjacent check: Identify effective NSS/resolver path, /etc/resolv.conf ownership, active nameservers/search domains and any systemd-resolved per-link routing domains or cache. 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
Operational reference
Fast context before you go deeper.
resolvectlPrimary Commands
Configuration and operational commands for this Topic.
resolvectlReferenceInspect or change systemd-resolved DNS servers, search domains and per-link resolver state.
Use when: Primary lookup intent: configure. Use resolvectl when the lookup goal is to inspect or change systemd-resolved DNS servers, search domains and per-link resolver state. Tie the result to the same host, namespace, user identity and time window as the symptom.
Quick note: Post-change verification for resolvectl: Read back effective DNS routing/servers and rerun the original hostname-to-application test. Output review: healthy and suspicious cues are command-specific interpretation boundaries, not fixed literal output samples. Intent class: configure. Safety class: changes_state. Intent describes the primary lookup role; safety remains command-family capability and can be higher than a read-only invocation. resolvectl is documented as an operational lookup primitive under DNS. The canonical leaf intentionally represents the command family; options remain distribution/tool-version specific.
hostnameReferenceDisplay or change the current system hostname depending on invocation and privilege.
Use when: Primary lookup intent: configure. Use hostname when the lookup goal is to display or change the current system hostname depending on invocation and privilege. Tie the result to the same host, namespace, user identity and time window as the symptom.
Quick note: Post-change verification for hostname: Verify hostname readback, name resolution and every identity-sensitive service/workload. Output review: healthy and suspicious cues are command-specific interpretation boundaries, not fixed literal output samples. Intent class: configure. Safety class: changes_state. Intent describes the primary lookup role; safety remains command-family capability and can be higher than a read-only invocation. hostname is documented as an operational lookup primitive under DNS. The canonical leaf intentionally represents the command family; options remain distribution/tool-version specific.
digTroubleshootIssue DNS queries and display response sections, flags, timing and selected resolver behavior.
Use when: Primary lookup intent: troubleshoot. Use dig when the lookup goal is to issue DNS queries and display response sections, flags, timing and selected resolver behavior. Tie the result to the same host, namespace, user identity and time window as the symptom.
Quick note: Output review: healthy and suspicious cues are command-specific interpretation boundaries, not fixed literal output samples. Intent class: troubleshoot. Safety class: read_only. Intent describes the primary lookup role; safety remains command-family capability and can be higher than a read-only invocation. dig is documented as an operational lookup primitive under DNS. The canonical leaf intentionally represents the command family; options remain distribution/tool-version specific.
nslookupTroubleshootPerform interactive or one-shot DNS lookups against the configured or selected resolver.
Use when: Primary lookup intent: troubleshoot. Use nslookup when the lookup goal is to perform interactive or one-shot DNS lookups against the configured or selected resolver. Tie the result to the same host, namespace, user identity and time window as the symptom.
Quick note: Output review: healthy and suspicious cues are command-specific interpretation boundaries, not fixed literal output samples. Intent class: troubleshoot. Safety class: read_only. Intent describes the primary lookup role; safety remains command-family capability and can be higher than a read-only invocation. nslookup is documented as an operational lookup primitive under DNS. The canonical leaf intentionally represents the command family; options remain distribution/tool-version specific.
hostReferencePerform concise DNS name and address lookups and common record-type queries.
Use when: Primary lookup intent: troubleshoot. Use host when the lookup goal is to perform concise DNS name and address lookups and common record-type queries. Tie the result to the same host, namespace, user identity and time window as the symptom.
Quick note: Output review: healthy and suspicious cues are command-specific interpretation boundaries, not fixed literal output samples. Intent class: troubleshoot. Safety class: read_only. Intent describes the primary lookup role; safety remains command-family capability and can be higher than a read-only invocation. host is documented as an operational lookup primitive under DNS. The canonical leaf intentionally represents the command family; options remain distribution/tool-version specific.
Verification & 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
application name/query → NSS policy + local hosts data → resolver library/stub → systemd-resolved/cache if used → configured DNS server/view → DNS response + TTL → selected address family/address → route/socket/application verification
Healthy evidence: the original resolver path returns the expected record from the intended view with plausible TTL/source context, and the application selects the intended address without resolver errors.
Step 2 Commands Verify boundary
resolvectl status
cat /etc/resolv.conf
dig example.com
getent hosts example.com
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. A capture should be tied to interface, direction, namespace, timestamp and filter. Verify both request and response and account for offload where packet presentation differs.
Existing fast checks for this Topic. - Capture the exact hostname/FQDN, record type, address family, process context and failure time before changing resolver state.
- Identify effective NSS/resolver path, /etc/resolv.conf ownership, active nameservers/search domains and any systemd-resolved per-link routing domains or cache.
- Compare application-path resolution with direct server queries and distinguish NXDOMAIN, NODATA, timeout, SERVFAIL, truncation, DNSSEC or wrong-view responses.
- After the smallest justified change, flush/age cache only when relevant, repeat the original application lookup and then verify connection to the intended returned endpoint.
Verification chain. application name/query → NSS policy + local hosts data → resolver library/stub → systemd-resolved/cache if used → configured DNS server/view → DNS response + TTL → selected address family/address → route/socket/application verification
Step 4 Failure modes and next checks Narrow the fault
Suspicious evidence: application and direct queries disagree, resolv.conf points at the wrong or dead resolver, per-link routing domains select an unexpected server, answers are stale/wrong-view, or DNS succeeds while the original connection still fails.
It does not show behavior outside the captured host/network namespace, resolver path or DNS view, interface/source, destination/protocol/port, capture point, time or workload scope. DNS verification ends when the original process resolves the intended name through its effective resolver path to the expected data and the answer can be correlated to the intended DNS view; connectivity and application acceptance remain separate things to check.
Next 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.
Step 5 Common mistakes Narrow the fault
- Testing with
dig(bypasses NSS/hosts) and expecting application behaviour. - Editing
/etc/resolv.confwhen it is managed by systemd-resolved or NetworkManager.
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.
Subtopics
Go one level deeper into this subject.
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.
Subtopic /etc/resolv.conf/etc/resolv.conf defines traditional resolver inputs such as nameserver, search/domain and resolver options, but on modern Linux it may be generated or symlinked by NetworkManager, systemd-resolved, DHCP or another manager rather than being the authoritative configuration source.
Subtopic systemd-resolvedsystemd-resolved is a Linux name-resolution service that can provide a local stub resolver, caching, LLMNR/mDNS integration and per-link DNS routing domains while receiving DNS configuration from network managers and link setup.
Subtopic /etc/hosts/etc/hosts is a local static hostname-to-address source consulted according to NSS policy and can intentionally override DNS for selected names, but its presence, ordering and exact name forms determine whether an application actually receives the entry.
Subtopic DNS TroubleshootingDNS Troubleshooting isolates Linux name-resolution failures by separating application resolver behavior, local static/NSS policy, generated resolver configuration, stub/cache state, upstream server reachability, DNS response semantics and the final application endpoint.
dig and nslookup bypass nsswitch and /etc/hosts — use getent hosts to test what applications see. With systemd-resolved, check real upstream servers with resolvectl status, not resolv.conf.
resolvectl status— DNS servers per link (systemd-resolved)cat /etc/resolv.conf— configured nameserversgetent hosts <name>— resolution through the system path (nsswitch)dig <name> @<server>— query a specific server
ReferenceWhat it is1 section · depth on demand
Core model
Start with the exact application name, record family and time. Show which resolver path the process actually uses, including NSS ordering and any systemd-resolved stub/cache layer, then identify the effective nameserver/search-domain policy, query the authoritative path directly when needed, and finally verify that the returned address is usable by the original application. A correct DNS answer does not show transport, TLS or service health.
ReferenceWhy it matters1 section · depth on demand
Overview
Name resolution on Linux follows /etc/nsswitch.conf (hosts: files dns myhostname or with resolve for systemd-resolved). glibc's resolver reads /etc/resolv.conf; systemd-resolved adds per-link DNS, caching, DNSSEC and DNS-over-TLS.
grep ^hosts /etc/nsswitch.conf
getent ahosts app.example.com
resolvectl query app.example.com
dig +short app.example.com
Compare getent (what applications see) with dig (direct DNS query) — differences point at the hosts file, NSS order, search domains or resolved routing.
ReferenceImportant terms & boundaries5 sections · depth on demand
What this shows and what it does not
DNS verification ends when the original process resolves the intended name through its effective resolver path to the expected data and the answer can be correlated to the intended DNS view; connectivity and application acceptance remain separate things to check.
In depth
How Linux resolves a host name
When a program looks up a name, it doesn't ask DNS directly. It calls the C library, which follows /etc/nsswitch.conf. The nsswitch.conf(5) manual page explains:
- The services on a database line are queried in order until one finds a result.
- Action items such as
[NOTFOUND=return]can stop the chain early. By default, "not found" means "continue with the next service". - For hosts, the classic services are
files(/etc/hosts) anddns(the servers in/etc/resolv.conf).
Modern systems often add resolve (systemd-resolved), myhostname and mdns4_minimal.
The resolution chain
| Step | Component | Configuration |
|---|---|---|
| 1 | The program calls getaddrinfo() | — |
| 2 | glibc reads the hosts line | /etc/nsswitch.conf |
| 3 | files | /etc/hosts |
| 4 | resolve / dns | systemd-resolved, or the servers in /etc/resolv.conf |
| 5 | The DNS servers | Recursive resolvers (internal DNS, ISP, public) |
Tools test different parts of the chain
| Tool | Uses nsswitch and /etc/hosts | Queries DNS directly |
|---|---|---|
getent hosts name | Yes | — |
ping, curl, applications | Yes | — |
resolvectl query name | Through systemd-resolved | — |
dig, nslookup, host | No | Yes |
This explains a classic mismatch: dig returns the right address, while the application connects somewhere else because of an /etc/hosts entry. Or the reverse.
host$ grep '^hosts' /etc/nsswitch.conf
hosts: files mdns4_minimal [NOTFOUND=return] dns myhostname
host$ getent hosts db1.example.net
10.30.0.40 db1.example.net
host$ dig +short db1.example.net
10.30.0.41
host$ grep db1 /etc/hosts
10.30.0.40 db1.example.net db1
host$ getent ahosts www.example.net | head -3
host$ resolvectl query db1.example.net
Reading the example
getent and the applications use /etc/hosts first, and get 10.30.0.40. DNS says 10.30.0.41. The old hosts entry wins and hides the DNS change. Removing the stale line makes both agree.
About [NOTFOUND=return]
[NOTFOUND=return] after mdns4_minimal stops the lookup for .local names when mDNS answers "not found", instead of passing them on to DNS.
Documented example, not captured output.
How it works at runtime
Runtime state ownership and mechanics. Linux networking spans netdevice/link state, addresses, neighbor cache, routing policy/tables, namespaces/VRFs, bridges/bonds/VLANs, socket state and user-space managers such as NetworkManager, netplan or systemd-networkd. The kernel forwarding path and the manager’s persistent intent are distinct. DNS adds NSS/resolver selection, per-link/global server policy, caches and upstream recursion/authority. Packet capture observes traffic at a chosen hook/interface and must be interpreted in that context.
Topic-specific state model. DNS is the Linux reference for translating application names through the host resolver stack into address data while keeping local NSS policy, resolver configuration, caches, DNS server responses and the final application connection as separate evidence boundaries.
Technical metadata. Host/VM and network namespace, distribution/kernel/libc/systemd-resolved/network-manager versions, interface/source address, resolver API/NSS order, /etc/resolv.conf ownership, per-link DNS servers/domains, query name/type/RCODE/TTL/view, destination address/protocol/port, route/rule/neighbor, firewall/MTU, socket state, capture interface/filter/time, packet direction/flags/errors and original application result.
Interpretation rule. - Name resolution succeeds ≠ the target service is reachable; DNS only shows the name-to-data result within the queried scope.
- /etc/resolv.conf content ≠ effective resolver behavior when it is generated, symlinked or bypassed by another resolver implementation.
- A successful dig query ≠ the application uses the same resolver path, search rules, address family or cache.
- One cached answer ≠ current authoritative truth; TTL, split DNS and per-link routing domains can make answers context-dependent.
Mechanics
Follow the path in order: link/interface → address/namespace → route/neighbor → firewall/policy → socket/daemon → DNS/TLS/SSH/application peer path.
Limits and how it fails
Primary failure point. DNS verification ends when the original process resolves the intended name through its effective resolver path to the expected data and the answer can be correlated to the intended DNS view; connectivity and application acceptance remain separate things to check.
Model. Interface UP does not show carrier, addressing, routing, neighbor resolution, firewall passage, DNS or application service. A default route can exist in the wrong namespace/table or with unusable next-hop reachability. A successful dig/resolvectl query can bypass the resolver path used by an application. Packet absence at one capture point does not show it was never generated. Keep configuration-manager state, kernel network state and remote service outcome separate.
ReferenceConfiguration & state1 section · depth on demand
Configuration, persistence and lifecycle
Configuration intent and lifecycle. Identify the authoritative network manager before editing files or issuing persistent commands. Generated configurations such as netplan output should be changed at their source. Keep interface identity, VLAN/bond/bridge membership, MTU, addresses, routes/rules and DNS policy explicit. Changes inside one network namespace do not automatically affect another. Treat transient ip commands as runtime state unless persistence is intentionally provided by the responsible manager.
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. 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 operational reference
Topic-specific lookup boundaries, proof limits and next-step Evidence for DNS.
| Lookup boundary | Topic-specific reference | Operational use |
|---|---|---|
| Scope / effective state | DNS is the Linux reference for translating application names through the host resolver stack into address data while keeping local NSS policy, resolver configuration, caches, DNS server responses and the final application connection as separate evidence boundaries. | 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 | application name/query → NSS policy + local hosts data → resolver library/stub → systemd-resolved/cache if used → configured DNS server/view → DNS response + TTL → selected address family/address → route/socket/application verification | Trace requested/configured state through effective state to the observed workload result. |
| Failure boundary | DNS verification ends when the original process resolves the intended name through its effective resolver path to the expected data and the answer can be correlated to the intended DNS view; connectivity and application acceptance remain separate boundaries. | 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: application name/query → NSS policy + local hosts data → resolver library/stub → systemd-resolved/cache if used → configured DNS server/view → DNS response + TTL → selected address family/address → route/socket/application verification | 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. DNS verification ends when the original process resolves the intended name through its effective resolver path to the expected data and the answer can be correlated to the intended DNS view; connectivity and application acceptance remain separate boundaries. | 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 · operational reference
Compact Linux state, persistence, verification and boundary reference for fast lookup.
| Reference boundary | DNS |
|---|---|
| Topic path | DNS |
| Runtime state | DNS is the Linux reference for translating application names through the host resolver stack into address data while keeping local NSS policy, resolver configuration, caches, DNS server responses and the final application connection as separate evidence boundaries. |
| Fast checks | - Capture the exact hostname/FQDN, record type, address family, process context and failure time before changing resolver state. - Identify effective NSS/resolver path, /etc/resolv.conf ownership, active nameservers/search domains and any systemd-resolved per-link routing domains or cache. - Compare application-path resolution with direct server queries and distinguish NXDOMAIN, NODATA, timeout, SERVFAIL, truncation, DNSSEC or wrong-view responses. - After the smallest justified change, flush/age cache only when relevant, repeat the original application lookup and then verify connection to the intended returned endpoint. |
| Verification chain | application name/query → NSS policy + local hosts data → resolver library/stub → systemd-resolved/cache if used → configured DNS server/view → DNS response + TTL → selected address family/address → route/socket/application verification Boundary chain: local authoritative state → adjacent dependency → effective/programmed state → original workload/request → return/regression → explicit Evidence boundary. Boundary chain: local authoritative state → adjacent dependency → effective/programmed state → original workload/request → return path or regression → explicit Evidence boundary. |
| Failure boundary | DNS verification ends when the original process resolves the intended name through its effective resolver path to the expected data and the answer can be correlated to the intended DNS view; connectivity and application acceptance remain separate boundaries. |
| Persistence rule | Prove which configuration source owns the state, then prove that the running consumer loaded or generated the intended state. |