Azure queries

HASSAN BIN NASIR DAR 391 Reputation points
2025-04-04T02:55:40.9933333+00:00

Hi,

I have a question regarding DNS queries specifically, recursive and iterative queries.

I understand the difference between them:

  • In a recursive query, the DNS server handles the entire resolution process (querying the root server, TLD, etc.) and provides the final domain’s IP address to the user.
  • In an iterative query, the DNS server responds with a referral (e.g., to the root or TLD server), and the user’s device must contact the referral directly.

My question is: How does the DNS server determine whether a query from the user’s device should be processed as recursive or iterative?

Regards

Windows for business Windows Server Networking Network connectivity and file sharing
{count} votes

2 answers

Sort by: Most helpful
  1. TP 124.7K Reputation points Volunteer Moderator
    2025-04-07T04:04:21.94+00:00

    Hi,

    How does the DNS server determine whether a query from the user’s device should be processed as recursive or iterative?

    A: When client sends query to DNS server it sets Recursion Desired (RD) bit to 1 in the header, indicating that it would like recursion. This (setting RD to 1) is the default when you are doing DNS lookups from most applications. For example, if you type address into web browser it will result in DNS query being sent with RD set to 1.

    Please reference document below for more details (scroll down a bit to see RD):

    RFC 1035 4.1.1 Header section format

    https://datatracker.ietf.org/doc/html/rfc1035#section-4.1.1

    Please click Accept Answer and upvote if the above was helpful.

    Thanks.

    -TP


  2. Sai Prasanna Sinde 6,645 Reputation points Microsoft External Staff Moderator
    2025-04-08T06:10:35.7066667+00:00

    @HASSAN BIN NASIR DAR

    Recursive: A recursive query forces a DNS server to respond to a request with either a failure or a success 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 (or servers), 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.

    When a DNS server processes a recursive query and the query can't 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.)

    Iterative: 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 isn't authoritative for the name. If a DNS server doesn't 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 (or domains) (when it isn't configured with a forwarder). It might have to query outside DNS servers in an attempt to resolve the name.

    The following figure shows an example of both types of queries.

    The diagram shows how multiple queries were used to determine the IP address for www.contoso.com.

    The diagram shows how multiple queries were used to determine the IP address for www.contoso.com. The query sequence is described as follows:

    1. Recursive query for www.contoso.com (A resource record).
    2. Iterative query for www.contoso.com (A resource record).
    3. Referral to the .com name server (NS resource records, for .com); for simplicity, iterative A queries by the DNS server to resolve the IP addresses of the Host names of the name server’s returned by other DNS servers have been omitted.
    4. Iterative query for www.contoso.com (A resource record).
    5. Referral to the contoso.com name server (NS resource record, for contoso.com).
    6. Iterative query for www.contoso.com (A resource record).
    7. Answer to the iterative query from contoso.com server (The www.contoso.com IP address).
    8. Answer to the original recursive query from local DNS server to resolver (The www.contoso.com IP address).

    I hope this has been helpful!

    Your feedback is important so please take a moment to Accept answers.

    If you still have questions, please let us know what is needed in the comments so the question can be answered.

    Thank you for helping to improve Microsoft Q&A!


    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.