Recursive DNS

On this page 7

Recursive DNS is the part of the DNS system that takes a query from a client and resolves it completely on the client’s behalf, contacting root, top-level domain and authoritative name servers as needed and returning the final answer or an error. The server performing this work is called a recursive resolver or recursive name server.

In DNS, recursion separates the effort of finding an answer from the client that needs it. A laptop or phone runs only a lightweight stub resolver that sends one query and waits. The recursive service does the multi-step lookup, caches each result for its TTL, and serves later queries for the same name from memory, which makes most lookups fast.

How recursive resolution works step by step

A recursive lookup is a chain of iterative queries sent by the resolver. Each server it contacts either answers or refers the resolver to servers closer to the answer, a response called a referral.

  1. The stub resolver sends a query for www.example.org with the Recursion Desired (RD) flag set.
  2. The recursive resolver checks its cache; if a valid answer exists, it replies immediately.
  3. Otherwise it asks a root server, which refers it to the name servers for .org.
  4. The resolver asks a TLD server, which refers it to the authoritative servers for example.org.
  5. The resolver asks an authoritative server, which returns the final record.
  6. The resolver caches every response and replies to the client with the Recursion Available (RA) flag set.

In practice, the resolver rarely starts at the root. Referrals for popular TLDs stay cached for hours or days, so a typical uncached lookup needs only one or two network round trips to authoritative servers. A cache hit answers in about a millisecond inside the resolver, while a full resolution may take tens to a few hundred milliseconds depending on server locations.

DNS servers play distinct roles that are often confused. A recursive resolver looks up answers it does not own, while an authoritative server publishes answers for the zones it hosts.

RoleWhat it doesHolds original zone data
Stub resolverSends queries from the device to a configured resolverNo
Recursive resolverPerforms full lookups and caches resultsNo
ForwarderPasses queries to another recursive resolverNo
Authoritative serverAnswers for zones it is responsible forYes
Root and TLD serversAuthoritative for the root and top-level zonesYes, for delegations
DNS roles and their responsibilities

The terms recursive query and iterative query also differ. A recursive query asks the server for a complete answer, which is what the client sends. An iterative query accepts a referral, which is what the resolver sends to authoritative servers. Mixing the two roles on one server is discouraged for security reasons, because a combined server exposes its cache to the same traffic that reaches its zones.

Caching and time-to-live in recursive DNS

Caching is what makes recursive DNS scalable. Every record carries a time-to-live (TTL) in seconds, set by the zone owner, and the resolver keeps the record until the TTL expires. Negative answers are cached too, based on values in the zone’s SOA record, so repeated queries for nonexistent names do not reach authoritative servers each time.

TTL rangeTypical useEffect on recursive resolvers
30 to 300 secondsFailover, load balancing, planned migrationsChanges spread quickly, more queries upstream
1 to 4 hoursOrdinary website and mail recordsGood balance of freshness and load
1 day or longerStable delegations and name server recordsVery few upstream queries, slow changes
Typical TTL choices and their effects

Some resolvers apply minimum or maximum TTL limits or serve stale records when authoritative servers are unreachable. These behaviors improve resilience but explain why a DNS change sometimes appears to take longer than its TTL suggests.

Security and privacy of recursive resolvers

Because a recursive resolver sees every name a client looks up and stores answers for many users, it is both a privacy-sensitive and a security-critical component.

ThreatRiskProtective measure
Cache poisoningForged answers redirect usersSource port randomization and DNSSEC validation
Open resolver abuseUsed for reflection and amplification attacksAllow recursion only for known clients
Eavesdropping on queriesBrowsing habits exposed on the networkDNS over TLS on port 853 or DNS over HTTPS
Excess data sent upstreamFull names leak to root and TLD serversQNAME minimization
Resolver outageUsers cannot reach any named serviceRedundant resolvers and anycast
Threats and protective measures

A validating recursive resolver checks DNSSEC signatures from the root down to the answer and returns a failure when validation breaks. Validation protects users only if the resolver performs it, or if the client validates itself; encryption between client and resolver does not authenticate the data it carries.

Choosing and operating a recursive service

Organizations can use the ISP’s resolver, a public resolver or their own recursive servers. The choice affects latency, privacy, filtering options and the accuracy of geographic answers from CDNs.

  • Place resolvers close to clients, because every uncached lookup adds resolver latency to page loads.
  • Run at least two independent resolvers so a single failure does not stop name resolution.
  • Enable DNSSEC validation unless a documented reason prevents it.
  • Restrict recursion to internal networks to avoid running an open resolver.
  • Monitor cache hit rates, SERVFAIL responses and latency to detect upstream problems early.

Stripped to the essentials

Recursive DNS is the helper that finds a website’s address for you. Your device asks one simple question, such as where a site lives, and the recursive service does all the asking around until it gets the answer.

It is like a reference librarian. You ask for one book, and the librarian checks the catalog, goes to the right floor and finds the right shelf. The librarian also remembers recent answers, so the next person asking for the same book gets it almost instantly.

Where it is applied

A university network of about 20,000 users originally forwarded all DNS queries to a distant external resolver. During busy periods, users noticed slow page starts, and logs showed lookup times of 80 to 150 ms for names that should have been cached.

The network team deploys two recursive resolvers on campus with anycast addressing, DNSSEC validation and recursion limited to university address ranges. Because many students visit the same services, the cache hit rate exceeds 80 percent, and most answers now arrive in a few milliseconds. When one resolver is taken down for maintenance, anycast shifts traffic to the other without any visible interruption.