Network Administration: DNS Queries

When a DNS client needs to resolve a DNS name to an IP address, it uses a library routine — a resolver — to handle the query. The resolver takes care of sending the query message over the network to the DNS server, receiving and interpreting the response, and informing the client of the results of the query.

A DNS client can make two basic types of queries: recursive and iterative. The following list describes the difference between these two query types. (The following discussion assumes that the client is asking the server for the IP address of a host name, which is the most common type of DNS query. You find out about other types of queries later; they, too, can be either recursive or iterative.)

  • Recursive queries: When a client issues a recursive DNS query, the server must reply with either the IP address of the requested host name or an error message indicating that the host name doesn’t exist. If the server doesn’t have the information, it asks another DNS server for the IP address.

    When the first server finally gets the IP address, it sends it back to the client. If the server determines that the information doesn’t exist, it returns an error message.

  • Iterative queries: When a server receives an iterative query, it returns the IP address of the requested host name if it knows the address. If the server doesn’t know the address, it returns a referral, which is simply the address of a DNS server that should know. The client can then issue an iterative query to the server to which it was referred.

Normally, DNS clients issue recursive queries to DNS servers. If the server knows the answer to the query, it replies directly to the client. If not, the server issues an iterative query to a DNS server that it thinks should know the answer.

If the original server gets an answer from the second server, it returns the answer to the client. If the original server gets a referral to a third server, the original server issues an iterative query to the third server. The original server keeps issuing iterative queries until it either gets the answer or an error occurs. It then returns the answer or the error to the client.