Pcornel
Browse topics
Options
Recent
Favorites
Linux · Technical reference

DNS (Domain Name System)

Direct answer

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.

When to use this

Use it as the entry point for name resolution problems on a Linux host.

First 30 seconds

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?

Operational verification

application → glibc → nsswitch (files, dns) → resolv.conf / stub → upstream DNS → answer

Evidence · next step

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
Platform / version applicability
linux
applies
Structured applicability is explicit Topic metadata; it does not infer compatibility beyond the stored rows.
At a glance

Operational reference

Fast context before you go deeper.

Platformlinux
Key commandresolvectl
Scope / prerequisiteUse it as the entry point for name resolution problems on a Linux host.
Troubleshoot · 2Reference · 3
What next?3 suggested next steps
Child topics (this level)5
Catalog command links5
Evidence1
On this pageJump to a specific section
Linux command reference

Primary Commands

Configuration and operational commands for this Topic.

resolvectlReference
resolvectl

Inspect 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.

Linux · control plane
hostnameReference
hostname

Display 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.

Linux · state
digTroubleshoot
dig

Issue 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.

Linux · control plane
nslookupTroubleshoot
nslookup

Perform 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.

Linux · control plane
hostReference
host

Perform 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.

Linux · control plane
Operational workflow

Verification & Troubleshooting

Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.

6 steps Observe → verify → isolate → change minimally → repeat the original test.
ObservedRecord what the original test actually shows

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.conf when it is managed by systemd-resolved or NetworkManager.
Step 6 Where it fails Narrow the fault

Walk link/interface → address/namespace → route/neighbor → firewall/policy → socket/daemon → DNS/TLS/SSH/application peer path and stop where observed state diverges.

Evidence references

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.

observation · 1
Drill down

Subtopics

Go one level deeper into this subject.

Key points

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.

Key checks
  • 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
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) and dns (the servers in /etc/resolv.conf).

Modern systems often add resolve (systemd-resolved), myhostname and mdns4_minimal.

The resolution chain

StepComponentConfiguration
1The program calls getaddrinfo()—
2glibc reads the hosts line/etc/nsswitch.conf
3files/etc/hosts
4resolve / dnssystemd-resolved, or the servers in /etc/resolv.conf
5The DNS serversRecursive resolvers (internal DNS, ISP, public)

Tools test different parts of the chain

ToolUses nsswitch and /etc/hostsQueries DNS directly
getent hosts nameYes—
ping, curl, applicationsYes—
resolvectl query nameThrough systemd-resolved—
dig, nslookup, hostNoYes

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.

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.

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.

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
Technical verification history

Verification history & basis

When and against what this Topic was checked. Later text edits do not count as a new check.

2026-09-14 · vendor doclinux current

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%
Technical changelog & impact

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.

Related reference impactReview these references after material technical changes when their shared boundary is affected.
Terminology layer

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.

Aliases that resolve here
linux dnslinux name resolutionresolver linuxdns troubleshooting linux
Embedded reference data

Quick lookup tables

DNS operational reference

Topic-specific lookup boundaries, proof limits and next-step Evidence for DNS.

Lookup boundaryTopic-specific referenceOperational use
Scope / effective stateDNS 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 verificationPin 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 chainapplication 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 verificationTrace requested/configured state through effective state to the observed workload result.
Failure boundaryDNS 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 evidenceCorrelated 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 verificationUse this observation only for the specific claim it actually supports.
Evidence limitIt 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 checkContinue 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 boundaryDNS
Topic pathDNS
Runtime stateDNS 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 chainapplication 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 boundaryDNS 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 ruleProve which configuration source owns the state, then prove that the running consumer loaded or generated the intended state.
Confirmation

Confirm action

Continue?