LinuxXIX · Networking FoundationsDNS/DHCP
DNS and DHCP concepts
What you'll learn
- Describe the DNS hierarchy and query flow
- Distinguish recursive and authoritative resolvers
- Explain how DHCP leases an address
- Recognise when a failure is DNS vs DHCP
Prerequisites
Verified against Ubuntu 24.04 LTS · Debian 12 (Bookworm) · RHEL 9.x · Rocky Linux 9.x · AlmaLinux 9.x · Linux kernel 6.1 LTS / 6.6 LTS · systemd 255+ · OpenSSH 8.7p1 (RHEL 9) / 9.6p1 (Ubuntu 24.04) · nftables 1.0.x · chrony 4.x · Pacemaker 2.1.x · Corosync 3.1.x · 2026-08-09
DNS and DHCP are the two services every Linux host depends on without thinking. When they break, everything looks like a network problem but no network tool works.
DNS hierarchy
DNS is a hierarchical, distributed database. Names are read right to left:
host.example.com.
. - the root
com - top-level domain (TLD)
example - second-level domain
host - the host name
The root is served by 13 logical name servers (a.root-servers.net through m.root-servers.net), each with many physical instances.
How a name is resolved
When a client asks its resolver for www.example.com:
- The resolver checks its cache. If fresh, done.
- If stale, the resolver queries a root server. The root refers to the .com TLD servers.
- The resolver queries a .com server. It refers to the example.com authoritative servers.
- The resolver queries the example.com server. It returns the A (IPv4) or AAAA (IPv6) record for www.example.com.
The resolver does the recursion (hence “recursive resolver”). The authoritative server returns the answer without recursing.
dig www.example.com
dig +short www.example.com
dig @8.8.8.8 www.example.com # use a specific resolver
dig +trace www.example.com # show the full chain
dig -x 10.0.0.5 # reverse lookup
dig is the sysadmin’s primary DNS tool. The +trace option
shows every step of the resolution; this is how you diagnose
“the resolver is wrong”.
Resource records
| Type | Purpose | Example |
|---|---|---|
| A | IPv4 address | www.example.com. 3600 IN A 93.184.216.34 |
| AAAA | IPv6 address | www.example.com. 3600 IN AAAA 2606:2800:220:1::1 |
| CNAME | Alias | www.example.com. IN CNAME example.com. |
| MX | Mail server | example.com. IN MX 10 mail.example.com. |
| NS | Authoritative name server | example.com. IN NS ns1.example.com. |
| TXT | Free-form text | SPF, DKIM, verification records |
| PTR | Reverse mapping (IP to name) | 34.216.184.93.in-addr.arpa. IN PTR example.com. |
| SOA | Zone of authority | start-of-authority record |
TTL (time to live) tells resolvers how long to cache. A low TTL allows faster changes at the cost of more queries.
Recursive vs authoritative resolvers
A recursive resolver accepts queries from clients and performs the full lookup. Examples: 8.8.8.8 (Google), 1.1.1.1 (Cloudflare), your ISP’s resolver, systemd-resolved on your Linux host.
An authoritative resolver (or authoritative server) holds the zone’s records and returns answers without recursing.
A host’s /etc/resolv.conf (or systemd-resolved configuration)
typically points to a recursive resolver. Authoritative servers
do not appear here.
DNS over HTTPS (DoH) and DNS over TLS (DoT)
Plain DNS queries are sent over UDP/TCP port 53 in cleartext. DoH (RFC 8484) and DoT wrap the queries in TLS. systemd-resolved supports both, as do Firefox and most modern browsers.
For a sysadmin, the operational impact is small - the DNS results are the same - but the privacy properties differ. In production, plain DNS is still the default.
DHCP
DHCP dynamically assigns IP addresses, default gateway, and DNS servers. The flow:
Client -> Server: DISCOVER (broadcast)
Server -> Client: OFFER (your address would be X)
Client -> Server: REQUEST (I would like X)
Server -> Client: ACK (X is yours, valid for N seconds)
The lease has a lifetime. When 50% of the lifetime is up, the client tries to renew with the same server. If that fails, it tries again at 87.5%. If renewal fails entirely, the address is given up.
DHCP failure modes
A host that cannot get a DHCP lease will often fall back to link-local addressing (169.254.0.0/16 for IPv4). This is the “APIPA” range in Windows terminology.
ip -4 addr show # look for 169.254.x.x
journalctl -u systemd-networkd # DHCP logs
systemctl restart systemd-networkd
If a host has 169.254.x.x, it has no usable IPv4 address. The DHCP server is unreachable, the lease is exhausted, or the link is broken.
Recognising DNS vs DHCP failures
| Symptom | Likely cause |
|---|---|
| IP address works, hostname does not | DNS |
| No IP at all, 169.254.x.x | DHCP |
ping 8.8.8.8 works, ping google.com does not | DNS |
ping works, ssh user@host does not | DNS or hosts file |
The diagnostic discipline: always test by IP first, then by hostname. If IP works and hostname does not, the problem is DNS. If neither works, the problem is lower in the stack.
Knowledge check
Knowledge check · 3 questions
Q1. What is the difference between a recursive resolver and an authoritative resolver?
Q2. A Linux host has the address 169.254.10.42 on its interface. What does this mean?
Q3. Which of the following are DNS resource record types? Select all that apply.
Passing score: 75%. Answers are checked in this browser.