Types of DNS Queries
There are two types of DNS queries that may be sent to a DNS server:
- Recursive
- Iterative
A recursivequery forces a DNS server to respond to a request with either a failure or a successful response. DNS clients (resolvers) typically make recursive queries. With a recursive query, the DNS server must contact any other DNS servers it needs to resolve the request. When it receives a successful response from the other DNS server(s), it then sends a response to the DNS client. The recursive query is the typical query type used by a resolver querying a DNS server and by a DNS server querying its forwarder, which is another DNS server configured to handle requests forwarded to it. For more information about forwarders, see “Forwarding” later in this document.
When a DNS server processes a recursive query and the query cannot be resolved from local data (local zone files or cache of previous queries), the recursive query must be escalated to a root DNS server. Each standards-based implementation of DNS includes a cache file (or root server hints) that contains entries for the root DNS servers of the Internet domains. (If the DNS server is configured with a forwarder, the forwarder is used before a root server is used.)
An iterative query is one in which the DNS server is expected to respond with the best local information it has, based on what the DNS server knows from local zone files or from caching. This response is also known as a referral if the DNS server is not authoritative for the name. If a DNS server does not have any local information that can answer the query, it simply sends a negative response. A DNS server makes this type of query as it tries to find names outside of its local domain(s) (when it is not configured with a forwarder). It may have to query a number of outside DNS servers in an attempt to resolve the name.
The following figure shows an example of both types of queries.
DNS Query Types
.gif)
As shown in the graphic above, a number of queries were used to determine the IP address for www.whitehouse.gov. The query sequence is described below:
- Recursive query for www.whitehouse.gov (A resource record)
- Iterative query for www.whitehouse.gov (A resource record)
- Referral to the .gov name server (NS resource records, for .gov); for simplicity, iterative A queries by the DNS server (on the left) to resolve the IP addresses of the Host names of the name server’s returned by other DNS servers have been omitted.
- Iterative query for www.whitehouse.gov (A resource record)
- Referral to the whitehouse.gov name server (NS resource record, for whitehouse.gov)
- Iterative query for www.whitehouse.gov (A resource record)
- Answer to the interative query from whitehouse.gov server (www.whitehouse.gov’s IP address)
- Answer to the original recursive query from local DNS server to Resolver (www.whitehouse.gov’s IP address)
Link: How DNS Works: Domain Name System(DNS) | Microsoft Learn