• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1896
  • Last Modified:

How does iterative and recursive query works in DNS?

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
beer9
Asked:
beer9
  • 4
1 Solution
 
Jan SpringerCommented:
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
 
Chris DentPowerShell DeveloperCommented:
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
 
Chris DentPowerShell DeveloperCommented:
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
Evaluating UTMs? Here's what you need to know!

Evaluating a UTM appliance and vendor can prove to be an overwhelming exercise.  How can you make sure that you're getting the security that your organization needs without breaking the bank? Check out our UTM Buyer's Guide for more information on what you should be looking for!

 
Chris DentPowerShell DeveloperCommented:
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
 
beer9Author Commented:
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
 
Chris DentPowerShell DeveloperCommented:
> 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

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now