DNS Queries — Recursive and Iterative

Geeky much!
Networks & Security

--

The goal of DNS (Domain Name System) is to resolve a fully qualified domain name (FQDN) to an IP address and the process is called name resolution.

A recursive DNS lookup is where one DNS server communicates with several other DNS servers to hunt down an IP address and return it to the client. This is in contrast to an iterative DNS query, where the client communicates directly with each DNS server involved in the lookup.

The recursive query is between a client and its local DNS server. On the other hand, iterative DNS query is between local DNS server and other DNS servers.

The iterative DNS lookup doesn’t require name resolution as any DNS server can provide the name resolution if known or respond with a referral to the server with name resolution known.

Let’s take an example to see both of these in action —

Suppose you want to go to www.google.com, you type it in the url field in your brower, → the browser then checks if there is any previous name resolution for this address — first in your browser’s cache memory and if not found, it checks in a text file called hosts C:/Windows/System32/drivers/etc/hosts

Now assume that there is no record in either of these locations, the computer then talks with the local DNS server asking for the IP address of www.google.com. This is the recursive query in where you computer(DNS client) talks with the local DNS server.

If the local DNS server doesn’t have a record for name resoltion for the site, it talks with the other higher level DNS servers in the network which can provide a refferal for the IP address. This is the iterative query.

As a DNS server finds the name resolved for the IP address we requested, it replies the client with the IP address and the browser stores the information in memory and the next time you look for www.google.com you can avoid the whole process because you have it in memory.

--

--

Geeky much!
Networks & Security

Being a smarter developer and security guy everyday !!