An iterative query (also called a non-recursive query) is a DNS request where a nameserver returns either the best answer it has from its own data and cache or a referral to other nameservers closer to the answer, placing responsibility on the asking party to follow referrals. This design forms the foundation of global DNS distribution, allowing root and top-level domain servers to handle enormous query volumes by answering only from their own data rather than performing full resolution for every client. For network operations, understanding iterative queries is critical for proper server configuration, security hardening against DNS amplification attacks, and effective troubleshooting of resolution failures and intermittent DNS faults.
How iterative query works
In an iterative query, the queried server answers only from what it already knows, such as its own zone data or cache. It never sends queries to other servers to complete the answer. The asking party is responsible for following any referral.
- Client sends the query: A resolver sends a DNS query to a nameserver, typically with the recursion desired flag not set, or to a server that will not recurse for it.
- Server checks local data: The nameserver looks in its authoritative zones and its cache for a matching record.
- Server returns an answer or referral: If it has the data, it returns the answer. If not, it returns a referral listing nameservers that are closer to the name, usually as NS records with any available address records.
- Resolver follows the referral: The resolver sends the same question to a server named in the referral and repeats until it reaches an authoritative server that gives the final answer or an error such as a nonexistent domain.
Recursive resolvers commonly use iterative queries when resolving names, starting at the root servers and working down through the top-level domain and the authoritative servers. An authoritative server that does not offer recursion behaves this way for every query it receives. Responses are cached according to record time to live values, which reduces repeat queries.
Common misconceptions about iterative query
Some assume an iterative answer is always built from scratch. A server answering iteratively can answer from its cache as well as from zone data, and a recursive resolver relies on its cache to avoid repeating iterative lookups.
Stub resolvers on endpoints normally send recursive queries to a configured resolver. The iterative queries happen between the recursive resolver and the authoritative servers, so packet captures on a client rarely show referrals.
A response with no answer section but with NS records in the authority section is a normal referral. Engineers new to DNS sometimes read it as a broken server when it is the expected reply from a parent zone.
Enabling recursion on an authoritative server for convenience exposes it to abuse such as use in amplification attacks and mixes two roles. Best practice is to separate authoritative and recursive functions or restrict recursion to trusted clients.
A REFUSED response to a recursive query usually means the server will not recurse for that source, not that it answered iteratively. Checking the recursion available flag and access control lists on the server finds the cause.