Sub topic 7
Recursive resolvers
This chapter assumes you know what a stub resolver is, how the namespace splits into root, TLD and authoritative zones, and that you can run dig in a terminal. It covers what a recursive resolver does for its clients and the errors that most often come from it.
What a recursive resolver does
A recursive resolver is a server that accepts a question from a client and takes on the job of finding the final answer. Your stub resolver sends one query with the "recursion desired" (RD) flag set. The recursive resolver then does the work of asking the root, TLD and authoritative servers. It returns either the answer or an error.
The resolver has three jobs:
- It walks the delegation chain on behalf of clients.
- It caches every answer for the record's TTL, so later clients get a fast reply.
- It serves many clients at once, such as a home network, a company, or the whole public internet.
Authoritative servers do not do this. They answer only for the zones they host and normally refuse to look anything up for you.
Where resolvers come from
Your machine usually learns its resolver from DHCP, so it is often your ISP's or your router's. Many routers run a small forwarding resolver that passes queries upstream. You can also configure a public resolver such as 8.8.8.8 or 1.1.1.1, or run your own with software like Unbound or BIND.
On Linux with systemd-resolved, resolvectl status shows the servers in use. The file /etc/resolv.conf may only list a local address like 127.0.0.53, which is a local stub that forwards to the real resolver.
Reading the flags
The flags in a dig reply show whether recursion was available and used.
dig @8.8.8.8 example.com AIn the header line, look for these:
| Flag | Meaning |
|---|---|
| `rd` | Recursion desired. The client asked the server to do the full lookup. |
| `ra` | Recursion available. The server is willing to do that for this client. |
| `aa` | Authoritative answer. Set by the zone's own server, not usually by a recursive resolver. |
If you query a recursive resolver and see ra but not aa, the answer came through the resolver, possibly from its cache. If you query an authoritative server directly with rd set, ra is usually missing, because it will not recurse.
Forwarding and shared caches
Not every resolver walks the tree itself. A forwarder passes the query to another recursive resolver and caches the result. Your home router often does this. Large networks use layers: a local resolver forwards to a bigger one, which forwards to another. Each layer has its own cache, so two clients can get different TTLs for the same name depending on which resolver they used.
Common errors
- SERVFAIL. The resolver could not complete the lookup. Typical causes are an unreachable or broken authoritative server, a lame delegation (the NS record points at a server that does not host the zone), or a DNSSEC validation failure.
- REFUSED. The server will not recurse for your address. Many resolvers only serve their own networks, and open resolvers are abused in amplification attacks.
- NXDOMAIN. The name does not exist. The resolver caches this too, using the SOA's negative caching value.
- Stale answers. After you change a record, a resolver can keep serving the old data until the TTL expires. Check with
dig @server nameagainst each resolver.
Exercise
You run dig @ns1.example.com www.example.com A against an authoritative server and the reply shows aa but not ra. Then you run the same query against 8.8.8.8 and see ra but not aa. Why do the flags differ?
Show answer
The authoritative server owns the zone, so it marks its answer authoritative (aa) and does not offer recursion, so ra is missing. The public resolver does not own the zone. It finds the answer by walking the delegation chain or from its cache, so it advertises recursion (ra) and does not set aa.