What you’ll get
Query an A record from the public resolver 1.1.1.1 to see what comes back in a DNS response:
dig @1.1.1.1 example.org A +noall +answer +comments
# ;; Got answer:
# ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 20121
# ;; flags: qr rd ra ad; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
#
# ;; ANSWER SECTION:
# example.org. 300 IN A 203.0.113.10
A single line in ANSWER packs the name, cache lifetime, class, record type, and address:
status: NOERROR means the query succeeded, and the ad flag confirms DNSSEC validation passed.Query path: from the local host to the authoritative NS
Domain names read right to left: api.example.org. is subdomain api inside zone example, which sits
under top-level domain .org, which sits under the root zone (.).
Before sending a single packet over the network, Linux checks /etc/nsswitch.conf (hosts: files dns): it
looks in /etc/hosts first and only then asks DNS. When /etc/hosts has no match, the lookup follows this chain:
app · example.org
- Stub resolver
127.0.0.53On Ubuntu 24.04,/etc/resolv.confpoints to localsystemd-resolved. On a cache miss, it forwards the query to the configured upstream resolver (9.9.9.9or1.1.1.1). - Root .
root-servers.netThe recursive resolver asks one of the 13 root server clusters: “who handles.org?” The root does not know the site’s IP — it returns the NS servers for.org. - .org zone (TLD)
NS delegationThe.orgserver does not store the IP ofexample.orgeither — it returns the domain’s authoritative NS servers (ns1.example.org). - Authoritative NS
ANSWER + TTLns1.example.orghosts the domain zone itself and returns the finalA 203.0.113.10record with itsTTL. The recursive resolver caches the answer and sends it back to the client.
A 203.0.113.10 (cached for TTL)
Walk that chain yourself from the root, bypassing caches, with +trace:
dig +trace +nodnssec example.org A
# . 518400 IN NS a.root-servers.net.
# ;; Received ... from 127.0.0.53#53
# org. 172800 IN NS a0.org.afilias-nst.info.
# ;; Received ... from a.root-servers.net#53
# example.org. 3600 IN NS ns1.example.org.
# ;; Received ... from a0.org.afilias-nst.info#53
# example.org. 300 IN A 203.0.113.10
# ;; Received ... from ns1.example.org#53
If a transparent DNS interceptor sits on your path (such as a home router or ISP proxy), dig +trace exposes it
immediately: instead of step-by-step delegation, an A record with a short TTL comes back on the first hop.
DNS record types
| Type | Stores | Example | Purpose |
|---|---|---|---|
A |
IPv4 address | 203.0.113.10 |
Primary mapping from hostname to an IPv4 server |
AAAA |
IPv6 address | 2001:db8::10 |
Mapping from hostname to an IPv6 server (IPv6 in practice) |
CNAME |
Alias to another name | www.example.org. -> example.org. |
Points a subdomain to a canonical name; the resolver runs a second lookup |
MX |
Mail server + priority | 10 mail.example.org. |
Where to deliver email for the domain |
TXT |
Arbitrary text | "v=spf1 -all" |
Domain ownership verification, SPF, DKIM, DMARC, ACME DNS-01 |
NS |
Authoritative DNS servers | ns1.example.org. |
Delegates a zone to specific DNS servers |
PTR |
Reverse record (IP to name) | 1.1.1.1 -> one.one.one.one. |
Mail server reputation checks (dig -x 1.1.1.1 +short) |
SOA |
Zone metadata | serial number, timers | NS synchronization timers and negative-response cache lifetime |
By default, DNS runs over UDP :53 (one request, one reply, UDP and QUIC). Clients switch to TCP :53 when
an answer exceeds the UDP packet size (large TXT/DNSSEC responses set the TC — Truncated — flag) or during
zone transfers between DNS servers (AXFR).
Response codes: NOERROR, NXDOMAIN, and SERVFAIL
The status field in dig’s header separates a typo, a missing record type, and broken DNS infrastructure:
- Client✓ dig example.org A
- Resolver 1.1.1.1✓ queried NS
- Authoritative NS✓ A 203.0.113.10
- Cache✓ stored for 300 s
;; ->>HEADER<<- opcode: QUERY, status: NOERROR ;; ANSWER SECTION: example.org. 300 IN A 203.0.113.10
The record exists. If status: NOERROR appears with ANSWER: 0, the name exists but has no record of the requested type (for example AAAA).
dig @1.1.1.1 example.org A and dig @1.1.1.1 example.org AAAA
- Client✓ dig typo.example.org
- Resolver 1.1.1.1✓ asked zone NS
- Authoritative NS✕ name does not exist
- Reply✕ NXDOMAIN + SOA
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN ;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1 ;; AUTHORITY SECTION: example.org. 60 IN SOA ns1.example.org. dns.example.org. ...
The authoritative server confirmed that typo.example.org does not exist (a typo, deleted record, or wrong zone).
Check the name in your DNS panel and run dig @ns1.example.org typo.example.org
- Client✓ dig broken.example
- Resolver 1.1.1.1✕ NS silent / bad DNSSEC
- Reply✕ status: SERVFAIL
;; ->>HEADER<<- opcode: QUERY, status: SERVFAIL ;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0
The resolver could not obtain a valid answer: the authoritative NS servers are down, registrar delegation is broken, or DNSSEC validation failed.
dig +trace broken.example and dig @1.1.1.1 +cd broken.example
How DNS works on Ubuntu (systemd-resolved)
On Ubuntu 24.04, local applications query the 127.0.0.53 stub managed by systemd-resolved:
grep -v '^#' /etc/resolv.conf | grep -v '^$'
# nameserver 127.0.0.53
# options edns0 trust-ad
resolvectl status
# Link 2 (eth0)
# Current Scopes: DNS
# Current DNS Server: 9.9.9.9
# DNS Servers: 9.9.9.9
Clear the local DNS cache after an urgent record change with sudo resolvectl flush-caches.
If it doesn’t work
curl: (6) Could not resolve host or Temporary failure in name resolution, while ping 1.1.1.1 succeeds
- Cause
- Internet routing works, but the system resolver is not answering or
/etc/resolv.confpoints to an unreachable DNS server. - Fix
- Compare the system resolver against a public one:
dig example.orgvsdig @1.1.1.1 example.org. On Ubuntu, check the local DNS status withresolvectl status.
You moved a site to a new server and updated its A record, yet browsers keep hitting the old IP for half an hour
- Cause
- Intermediate resolvers and OS caches keep serving the old answer until its previous
TTLexpires (for example, 3600 seconds). - Fix
- Lower
TTLto 60–300 seconds ahead of a migration (Lower DNS TTL a day before migrating). To verify the live record bypassing caches, query the authoritative NS directly:dig @ns1.example.org example.org A.
dig returns status: NOERROR, but the ANSWER section is empty
- Cause
- The domain exists, but has no record of the requested type — for example, it has
AAAA(IPv6) orTXTrecords, with noA(IPv4) record. - Fix
- Query other types (
dig example.org AAAA,dig example.org CNAME,dig example.org TXT) and inspect your DNS panel.
Other domains resolve fine, while one specific domain suddenly returns status: SERVFAIL
- Cause
- The domain's authoritative NS servers are unreachable, the domain registration expired, or its DNSSEC signature chain is broken.
- Fix
- Trace the chain with
dig +trace example.organd compare answers with and without DNSSEC validation:dig @1.1.1.1 +cd example.org(+cddisables signature checking for diagnosis).
You edited /etc/resolv.conf manually, and the changes vanished after a reboot or network reload
- Cause
- On Ubuntu 24.04,
/etc/resolv.confis a symlink managed bysystemd-resolvedpointing to its127.0.0.53stub. - Fix
- Configure DNS servers in the network config (
netplanunder/etc/netplan/*.yamlor/etc/systemd/resolved.conf.d/) and apply withsudo netplan apply.