DNS Query Differences: Iterative and Recursive

By SB •  Updated: 03/09/21 •  5 min read

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.

DNS Queries

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:

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:

SB

I've been practicing OSINT and utilizing Linux as my daily operating system for over twenty years. The tools are always changing and so I'm always learning, but helping you understand the value of protecting your own data remains at the forefront of everything I do.