Definition of Iterative Query in Network Encyclopedia. Iterative Query is a DNS query in which a name server contacts a second name server to perform a name lookup. In a typical Internet name lookup (for example, www.alpine.expedia.com), a resolver sends a recursive query to a locally accessible name server such as a name server maintained by your local Internet service provider (ISP). If the local name server cannot resolve the name because it is outside of its zone of authority and it is configured as a forwarder, the server performs an iterative query to a root name server, which responds with the IP address of a name server whose zone of authority includes the desired top-level domain (.com). The local name server then performs an iterative query with this top-level name server, which responds with the IP address of a second-level name server whose zone of authority includes the desired second-level domain (expedia.com). The local name server contacts this second-level name server and resolves the fully qualified domain name (FQDN) into its IP address or returns an error if the query cannot be resolved. A recursive query is a query in which the DNS server, who received your query will do all the job of fetching the answer, and giving it back to you. During this process, the DNS server might also query other DNS server’s on the internet on your behalf, for the answer. In an iterative query, the name server, will not go and fetch the complete answer for your query but will give back a referral to other DNS server’s, which might have the answer. DNS is the most critical infrastructure, that's publicly available for use to everybody out there. You can infact say that, its a single point of failure, that can take down the world wide web. I have tried to explain the working of DNS in one of my post. However, its impossible to conclude the entire topic, in one or even multiple posts for that matter. So i will be posting, different topics related to DNS, separately for giving a better understanding to the reader. Read: How Does DNS Work In this post, we will walk through different types of queries that a client uses to get different types of information from the DNS server. DNS queries can be classified according the manner in which a complete request is processed. Generally queries can be classified as follows.
What is a recursive query?A recursive query is a kind of query, in which the DNS server, who received your query will do all the job of fetching the answer, and giving it back to you. During this process, the DNS server might also query other DNS server's in the internet on your behalf, for the answer. Lets understand the entire process of recursive queries by the following steps. Suppose you want to browse www.example.com, and your resolve.conf file has got the following entry. [root@myvm ~]# cat /etc/resolv.conf nameserver 172.16.200.30 nameserver 172.16.200.31 The above resolve conf entry means that,Your DNS servers are 172.16.200.30 & 31. Whatever application you use, the operating system will send DNS queries to those two DNS servers. STEP 1: You enter www.example.com in the browser. So the operating system's resolver will send a DNS query for the A record to the DNS server 172.16.200.30 . STEP2: The DNS server 172.16.200.30 on receiving the query, will look through its tables(cache) to find the IP address(A record) for the domain www.example.com. But it does not have the entry. STEP 3: As the answer for the query is not available with the DNS server 172.16.200.30, this server sends a query to one of the DNS root server,for the answer. Now an important fact to note here is that root server's are always iterative servers. Related: DNS root servers and their Locations STEP 4: The dns root server's will reply with a list of server's (referral) that are responsible for handling the .COM gTLD's. STEP 5: Our DNS server 172.16.200.30 will select one of the .COM gTLD server from the list given by the root server, to query the answer for "www.example.com" STEP 6: Similar to the root server's , the gTLD server's are also iterative in nature, so it replies back to our DNS server 172.16.200.30 with the list of IP addresses of the DNS server's responsible for the domain(authoritative name server for the domain) www.example.com. Related: DNS Zone File And Its Contents STEP 7: This time also our DNS server will select one of the IP from the given list of authoritative name servers, and queries the A record for www.example.com. The authoritative name server queried, will reply back with the A record as below. www.example.com = <XXX:XX:XX:XX> (Some IP address) STEP 8: Our DNS server 172.16.200.30 will reply us back with the ip domain pair(and any other resource if available). Now the browser will send request to the ip given, for the web page www.example.com. Below shown diagram might make the concept clear. As you can see from the above figure. Our DNS server(172.16.200.30) queries through other dns server's on behalf of us. Note: The above explained scenario of recursive query happened, only because, our DNS server 172.16.200.30 was configured as a recursive name server. You can also disable this feature for your DNS server. In the above case, you might have seen that our DNS server 172.16.200.30, had to select one server, from the given list of servers to query, multiple times. For example there are 13 root servers(Well when i say 13 root servers, 13 is the number of addresses that is universal. There are Hundreds of servers at different locations in the world. These 13 root server addresses are anycasted addresses.), which root server will be queried, for an answer? Related: What is IP Anycast, and how it works? Almost all DNS server's uses an algorithm, to select one from the list, in order to distribute the load and response time. The most Famous DNS server software BIND uses a technique called as rtt metric(Round Trip Time metric). Using this technique, the server tracks the RTT of each root server, and selects the one,with lower RTT. What is an iterative or Non-recursive query?Before beginning the explanation for iterative query. An important thing to note is that, all DNS server's must support iterative(non-recursive)query. In an iterative query, the name server, will not go and fetch the complete answer for your query, but will give back a referral to other DNS server's, which might have the answer. In our previous example our DNS server 172.16.200.30, went to fetch the answer on behalf of our resolver, and provided us with the final answer. But if our DNS server 172.16.200.30 is not a recursive name server(which means its iterative), it will give us the answer if it has in its records. Otherwise will give us the referral to the root servers(it will not query the root server's and other servers by itself.). Now its the job of our resolver to query the root server, .COM TLD servers, and authoritative name server's, for the answer. Lets go through the steps involved. STEP 1: You enter www.example.com in the browser. So the operating system's resolver will send a DNS query for the A record to the DNS server 172.16.200.30 . STEP 2: The DNS server 172.16.200.30 on receiving the query, will look through its tables(cache) to find the IP address(A record) for the domain www.example.com. But it does not have the entry. STEP 3: Now instead of querying the root server's, our DNS server will reply us back with a referral to root servers. Now our operating system resolver, will query the root servers for the answer. Now the rest of the steps are all the same. The only difference in iterative query is that
It can be clearly noted from the above figure, that in an iterative query, a DNS server queried will never go and fetch the answer for you(but will give you the answer if it already has the answer). But will give your resolver a referral to other DNS server's(root server in our case). We will be discussing inverse queries in another post. Hope this post was helpful in understanding iterative(non-recursive) & recursive DNS queries. |