Solved

How does iterative and recursive query works in DNS?

Posted on 2011-09-21
6
1,432 Views
Last Modified: 2012-05-12
Hello, I would like to know how does iterative and recursive query works in DNS? If I have a linux (ubuntu) box and /etc/resolv.conf has three nameserver mentioned then which query does it use by default? iterative or recursive?

can we force a query using nslookup/host/dig to use only iterative or recursive to resolve a hostname? Thanks!
0
Comment
Question by:beer9
  • 4
6 Comments
 
LVL 28

Expert Comment

by:Jan Springer
ID: 36575640
recursion is the action of going up to tree (and possbily to the root) to find an authoritative server for a FQDN in question.

dig www.domain.com @A.B.C.D
0
 
LVL 70

Expert Comment

by:Chris Dent
ID: 36575785
In short:

Recursive - Client sends request to a server, server deals with it
Iterative - Client is expected to do all the work

The catch is, a DNS server can be both a Server and a Client. It can be the Server for the Recursive part, waiting for queries from clients and expecting to fulfil them. And it can be the client, performing Iterative queries.

You can see an Iterative query in action using Dig with:

dig domain.example +trace

In this dig, as the client, is doing all the work, it's performing an Iterative query.

If you just run this:

dig domain.example @someserver

Then you'll send a DNS packet, which includes a request for recursion from the server and the sever, if it's allowed, will get on with it for you. You can say don't like this:

dig domain.example +norecurse @someserver

And in that case you'll get the best answer the server can give you (worst case, nothing or root hints; best case, a cached answer).

Finally, if a server is configured not to accept recursive queries it will always return the best answer it can (which depending on configuration, may include Query Refused).

Chris
0
 
LVL 70

Accepted Solution

by:
Chris Dent earned 500 total points
ID: 36575817
Forgot to address this bit:

> has three nameserver mentioned then which query does it use by default?

Recursive.

You'll find most client-side resolvers (not debugging tools) are stub-resolvers. They can't perform full Iterative queries, they can only hope a DNS server can help out.

And...

> can we force a query using nslookup/host/dig to use only iterative or recursive to resolve a hostname?

NsLookup can do a query without asking for recursion:

nslookup
set norecurse
domain.example

But it can't do iteration.

I think it's the same for host. -r makes it send a request without asking for recursion, but again it can't do iteration.

Chris
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 70

Expert Comment

by:Chris Dent
ID: 36575836
And just one more :)

The most succinct definition of recursion vs iteration is in RFC 1034:

http://www.ietf.org/rfc/rfc1034.txt

To quote:

  - In any system that has a distributed database, a particular
     name server may be presented with a query that can only be
     answered by some other server.  The two general approaches to
     dealing with this problem are "recursive", in which the first
     server pursues the query for the client at another server, and
     "iterative", in which the server refers the client to another
     server and lets the client pursue the query.  Both approaches
     have advantages and disadvantages, but the iterative approach
     is preferred for the datagram style of access.  The domain
     system requires implementation of the iterative approach, but
     allows the recursive approach as an option.

Chris
0
 

Author Comment

by:beer9
ID: 36576360
can we force a query using nslookup/host/dig to use only iterative or recursive to resolve a hostname?

NsLookup can do a query without asking for recursion:

nslookup
set norecurse
domain.example

But it can't do iteration.

I think it's the same for host. -r makes it send a request without asking for recursion, but again it can't do iteration.

Thanks for the detailed information Chris, I just wanted to know when you say to set 'no recurse' on host/nslookup then it doesn't mean iteration?

I assumed opposite of recursion is iteration.

So if I just use the command "host google.com" then did it use iterative or recursive?

as per my understanding:

host google.com is iteration
host -r google.com is non-recursive (but not iteration?)

Please clarify if my understanding is right.. Thanks again for your help :-)
0
 
LVL 70

Expert Comment

by:Chris Dent
ID: 36576523
> So if I just use the command "host google.com" then did it use iterative or recursive?

Recursive (that's the default in almost all cases).

> host -r google.com is non-recursive (but not iteration?)

It can be the starting point for an iterative query process. However, since it can't complete and get to an answer it's difficult to refer to it as an iterative query. Does that make sense?

Chris
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

I will assume you are running a non-server version of some sort of Windows throughout this article. There are many flavors of Windows since Windows Server 2000 - 2008, XP Home & Pro, Vista Home & Pro, and Windows 7 Starter, Home, Pro, Ultimate, etc.…
Occasionally you run into the website or two that will not resolve properly using your own DNS servers.  Some people simply set up global forwarders for their DNS server.  I don’t recommend doing this because it can cause problems resolving addresse…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now