D. J. Bernstein
Internet publication
djbdns
User's guide to name resolution
Resolution means conversion
of a host name that you type,
such as www.cnn.com,
into an IP address,
such as 64.236.16.84.
Internet computers actually contact each other using IP addresses;
your browser needs to resolve www.cnn.com
before it can contact www.cnn.com.
Most of the effort in name resolution is carried out by
DNS caches such as dnscache.
DNS clients (sometimes called stub resolvers),
such as your browser,
resolve names by contacting a nearby DNS cache.
This page explains the djbdns client-cache communication procedure.
This procedure is followed by the
dns_ip4, dns_ip4_qualify,
dns_name4, dns_mx, and dns_txt
library routines in djbdns,
and by programs that use those routines.
Cache selection
The client finds the IP address of the DNS cache
on a nameserver line
in /etc/resolv.conf:
nameserver 10.53.0.1
If /etc/resolv.conf does not exist
or does not list any IP addresses,
the client uses IP address 127.0.0.1:
in other words, it contacts a DNS cache on the same computer.
The system administrator can list several DNS caches
in /etc/resolv.conf
by including several nameserver lines.
Servers after the 16th are ignored.
You can override /etc/resolv.conf
by setting the $DNSCACHEIP environment variable.
For example,
env DNSCACHEIP=127.0.0.1 dnsip www.aol.com
will use IP address 127.0.0.1
no matter what is listed in /etc/resolv.conf.
Retransmission
The client sends a request to the first DNS cache,
waits 3 seconds for a response,
sends the same request to the second DNS cache,
waits 3 seconds for a response, etc.
It then sends a request to each cache again,
but waits 11 seconds for each response.
It then tries each cache one last time, waiting 45 seconds.
Compatibility notes
Different DNS client programs use different procedures
for contacting caches.
Three differences between the djbdns procedure
and other procedures:
- Most programs use only /etc/resolv.conf.
They don't know anything about $DNSCACHEIP.
- Most programs use a different retransmission strategy.
- Most long-running programs
don't notice changes in /etc/resolv.conf;
they read /etc/resolv.conf when they start,
and they don't reread it until they are restarted.
In contrast, the djbdns procedure
checks for changes every 10 minutes or 10000 uses.