A recursive query in DNS (Domain Name System) is the process of a DNS Client (user’s computer) querying a local DNS Server.
An iterative query is the process of a DNS Server making repeated DNS Queries to different DNS Servers for domain name resolution on behalf of the DNS Client.
A Domain Name Server (DNS) is a naming system that takes alphanumeric domain names and translates them into numeric IP addresses, but did you know that a couple of activities go on behind the scene to make that happen?
For instance, when you enter a website, such as “domainname.com”, into your address bar, a translation occurs between the domain name and the IP address linked to it — this activity is called DNS name resolution. And since it would be very difficult for humans to memorize long digits (an IP address), the DNS system was created to work as a directory for the internet with the help of a process, called DNS Query.
A DNS query is a demand for information regarding the IP address linked to the domain name, sent from a client to a DNS server. There are three main types of DNS queries: recursive DNS query, iterative DNS query, and inverse queries. However, for the sake of this post, we’ll only be focusing on two of them; the recursive and iterative DNS query.
When a client sends a recursive DNS query or an iterative DNS query, both queries want information regarding the IP address linked to the fully qualified domain name (FQDN). But Inverse (or reverse) DNS queries work opposite to normal DNS queries, and are used when the user wants to resolve the IP Address to an FQDN. That is, the user has the IP address and wants to find the FQDN corresponding to that IP Address.
What is the difference between the standard DNS queries of recursive and iterative?
In a recursive DNS query the DNS client sends a query only to the DNS server, relying on it to provide the IP address or a “not found” result. This is not the case for the iterative DNS query, as the burden to find the domain name server address is always on the server referring the same query to another server until the name is resolved.
In the rest of this article, we’ll be exploring everything that you need to know about the recursive DNS query and the iterative DNS query.
What Is Iterative Resolution?
An iterative query is a DNS request which asks, “Send me the answer or give me any information that will help me find the answer.”
In the iterative resolution, the DNS client sends a DNS query to a DNS server, demanding for the IP address linked to the fully qualified domain name. The DNS does its work by trying to resolve the query and get the right answer.
However, if after searching its tables, it still ends up not getting the answer, it sends feedback to the DNS client, referring it to the root servers. So, the client does the job of sending a query to the servers until it is rightly resolved.
Here’s a step by step illustration of how iterative resolution works below:
- Let’s say you enter a website, such as domainname.com, in your browser URL address bar. Immediately, the DNS client will send a query to the DNS server, asking for information about the IP address linked to the domain name.
- After receiving the query, the DNS server tries all it can to resolve the query. It does that by searching its tables or cache to find the IP address that’s exactly linked to the domain name.
- If the DNS server doesn’t have the information about the IP address, instead of further searching the root servers, it sends feedback back to the resolver by referring it to the root servers.
- Next, the DNS resolver or local operating system resolver does the job of finding the IP address, by sending a query to the root servers one by one.
What Is Recursive Resolution?
Just like the iterative resolution, the recursive DNS query also works to get information regarding the IP address linked to the domain name. However, it does it differently, compared to that of the iterative resolution. Everything all starts with the DNS Client or local operating system resolver querying the DNS server to get information about the IP address.
The DNS server continues to search its cache for the right information. As soon as it is able to resolve the query, it sends the answer back to the local operating system resolver. However, if the DNS server is unable to locate the answer in its cache, it proceeds to querying other root servers until it finds the IP address.
Here is a quick look at the step-by-step illustration of how recursive resolution works:
- You enter a website, such as domainname.com, into your browser URL address tab. Immediately, the local operating system resolver sends a query to the DNS server, asking for information about the IP address linked to the domain name.
- Upon receiving the query, the DNS server tries all it can to resolve the query by searching its cache to find the IP address linked to the domain name. Here, two things might happen: it either finds the IP address in its cache, or it does not.
- If it finds the IP address, then the work is over. It will only send the answer back to the resolver.
- However, if it does not find the answer in its cache, it proceeds by looking for the answer in the root servers.