D. J. Bernstein
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 22.214.171.124.
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_name4, dns_mx, and dns_txt
library routines in djbdns,
and by programs that use those routines.
The client finds the IP address of the DNS cache
on a nameserver line
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
by including several nameserver lines.
Servers after the 16th are ignored.
You can override /etc/resolv.conf
by setting the $DNSCACHEIP environment variable.
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.
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.
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.