Sockets: Internet Domains 1211
Using the above approach allows DNS to cope with large namespaces, and does not
require centralized management of names.
Figure 59-2: A subset of the DNS hierarchy
Recursive and iterative resolution requests
DNS resolution requests fall into two categories: recursive and iterative. In a recur-
sive request, the requester asks the server to handle the entire task of resolution,
including the task of communicating with any other DNS servers, if necessary.
When an application on the local host calls getaddrinfo(), that function makes a
recursive request to the local DNS server. If the local DNS server does not itself have
the information to perform the resolution, it resolves the domain name iteratively.
We explain iterative resolution via an example. Suppose that the local DNS
server is asked to resolve the name http://www.otago.ac.nz. To do this, it first communicates
with one of a small set of root name servers that every DNS server is required to know
about. (We can obtain a list of these servers using the command dig. NS or from
the web page at http://www.root-servers.org/.)) Given the name http://www.otago.ac.nz, the
root name server refers the local DNS server to one of the nz DNS servers. The local
DNS server then queries the nz server with the name http://www.otago.ac.nz, and receives a
response referring it to the ac.nz server. The local DNS server then queries the ac.nz
server with the name http://www.otago.ac.nz, and is referred to the otago.ac.nz server. Finally,
the local DNS server queries the otago.ac.nz server with the name http://www.otago.ac.nz,
and obtains the required IP address.
If we supply an incomplete domain name to gethostbyname(), the resolver will
attempt to complete it before resolving it. The rules on how a domain name is com-
pleted are defined in /etc/resolv.conf (see the resolv.conf(5) manual page). By default,
the resolver will at least try completion using the domain name of the local host. For
example, if we are logged in on the machine oghma.otago.ac.nz and we type the com-
mand ssh octavo, the resulting DNS query will be for the name octavo.otago.ac.nz.
com edu net org de nz us
google kernel
Generic
domains
eu
Country
domains
gnu
ftp www
Top-level
domains
Anonymous root
ac
canterbury
www
Second-
level
domains
http://www.kernel.org.
www