Stub resolver

On this page 7

A stub resolver is the minimal DNS client built into an operating system or application that sends recursive queries to a full resolver and hands the final answer back to the program that asked. In DNS, it is the first link in every name lookup: it does not walk the hierarchy from the root itself, but delegates that work to a recursive resolver and trusts the response it receives.

The term comes from RFC 1123 and the DNS specifications in RFC 1034 and RFC 1035, which distinguish full-service resolvers from stub resolvers that depend on them. Almost every device on the Internet uses one, whether it is the resolver library inside an operating system, a local caching service, or a component embedded in a web browser.

How a stub resolver handles a name lookup

A stub resolver turns an application request such as “resolve example.org” into a DNS query message with the recursion desired flag set. It sends this message, usually over UDP port 53, to one of the configured recursive resolvers and waits for a response. The recursive resolver performs the iterative work of contacting root, top-level domain and authoritative servers, then returns a complete answer.

The stub resolver itself performs only a few local steps. It first consults local sources such as the hosts file, then an optional local cache, then the network. If the answer is truncated, it retries over TCP, and if a server does not respond within its timeout, it moves to the next configured server.

The table below shows the order of steps in a typical lookup on a desktop operating system.

StepActionResult
1Check the hosts file and local name policyStatic answer or continue
2Check the local DNS cache, if presentCached answer within its TTL or continue
3Send query with recursion desired to a configured serverRecursive resolver begins its work
4Receive the response and validate its formatAnswer, NXDOMAIN or SERVFAIL
5Retry with the next server or over TCP when neededRecovery from timeouts or truncation
6Return addresses to the applicationConnection can start
Steps in a typical stub resolver lookup

Stub resolver compared with other DNS resolvers

The defining difference is who performs the iteration. A stub resolver asks one question and expects a final answer, while a recursive resolver follows referrals across the hierarchy and an authoritative server answers only for its own zones. A forwarder sits in between: it accepts recursive queries but passes them on to another resolver instead of iterating.

ComponentMain taskCaches answersTypical location
Stub resolverSends recursive queries and returns answersSometimes, brieflyOperating system or application
Recursive resolverIterates from root to authoritative serversYes, per TTLISP, enterprise or public service
ForwarderRelays queries to an upstream resolverUsually yesHome router or local network
Authoritative serverAnswers for zones it hostsNot for other zonesDomain operator or DNS provider
Roles of DNS components in name resolution

In practice the boundaries blur. A home router often acts as a forwarder, and a local caching stub such as systemd-resolved or a validating resolver like Unbound on localhost can sit between applications and the upstream server. The device still contains a stub in the strict sense, because some component delegates recursion elsewhere.

Common stub resolver implementations and configuration

Stub resolvers are configured mostly through the list of upstream servers and a few behavioral options. On Unix-like systems the classic configuration file is /etc/resolv.conf, which lists nameservers, search domains and options such as timeout and attempts. Other platforms store equivalent settings in network profiles or receive them through DHCP or IPv6 router advertisements.

PlatformComponentNotable behavior
Linux with glibcResolver library and resolv.confNo cache by default, up to three nameservers
Linux with systemdsystemd-resolvedLocal cache, per-link servers, optional encryption
WindowsDNS Client serviceSystem-wide cache, per-adapter servers
macOS and iOSmDNSResponderUnicast DNS plus Multicast DNS, scoped resolvers
Web browsersBuilt-in resolverCan use DNS over HTTPS independently of the system
Typical stub resolver implementations

The search domain list deserves particular care. When a short name such as intranet is entered, the stub appends configured suffixes in turn, which is convenient on corporate networks but can leak queries to unintended domains and slow lookups when many suffixes fail.

Security properties of a stub resolver

A traditional stub resolver is a non-validating client that trusts its upstream server. Classic DNS over UDP is unencrypted and unauthenticated, so anyone on the path between the stub and the recursive resolver can observe queries or attempt to inject forged responses. Randomized query IDs and source ports reduce, but do not remove, the risk of spoofing.

Modern stubs address these weaknesses in several ways, each protecting a different part of the path.

MechanismWhat it protectsWhat it does not cover
DNS over TLSConfidentiality and integrity on port 853Trustworthiness of the resolver itself
DNS over HTTPSSame, carried inside HTTPS on port 443Data authenticity at the source zone
AD flag with trusted resolverSignals DNSSEC validation upstreamTampering on an unencrypted path
Local validating stubFull DNSSEC validation on the devicePrivacy of query contents
Protection options for the stub-to-resolver path

A common misconception holds that the AD bit proves an answer is authentic. It only reports that the upstream resolver validated the data, so a stub should rely on it only over a trusted, protected channel.

Troubleshooting stub resolver problems

Many reported DNS outages are in fact failures at the stub layer, not in authoritative zones. Tools such as dig and nslookup bypass parts of the system stub, so a lookup can succeed in a terminal while applications still fail, which is a strong hint that the local configuration or cache is the problem.

  • Lookups take several seconds: the first nameserver is unreachable, and every query waits for its timeout before trying the next.
  • Old addresses persist after a change: a local cache is serving stale records until their TTL expires or the cache is flushed.
  • Names resolve differently by application: a browser uses its own resolver, often with DNS over HTTPS, instead of the system stub.
  • Internal names fail over VPN: split-horizon DNS settings are not applied to the correct network interface.

Understanding it simply

Every time you open a website, your device needs the address behind its name. The stub resolver is the small helper on your device that asks for it. It does not search the whole Internet by itself.

Instead, it is like asking a well-informed receptionist. The stub passes the question to a bigger resolver, that resolver does the legwork, and the answer comes back. The stub only asks and relays, so its choice of whom to ask matters greatly for speed and privacy.

Applied in practice

An IT administrator at a company with 300 laptops receives complaints that web pages take about five seconds to start loading. Pages load quickly once they begin, and dig queries against the public resolver answer in under 30 milliseconds.

Inspecting the laptops shows that the DHCP server hands out two DNS servers, and the first one, an old internal server that was decommissioned, no longer responds. Each stub resolver waits for the five-second timeout before trying the second server, and most laptops do not cache the failure.

The administrator removes the dead address from the DHCP scope and enables encrypted DNS over TLS to the company resolver at the same time. After the leases renew, page start delays drop below 100 milliseconds, and help desk tickets about slow browsing stop within a day.