D. J. Bernstein
Internet publication
DNScache
Frequently asked questions

Load-balancing DNS server


How do I configure a load-balancing DNS server? I have fifty identical web servers running on IP addresses 1.2.3.150, 1.2.3.151, and so on. I'd like to run pickdns on IP address 1.2.3.20 to spread www.heaven.af.mil requests among those servers. I'm already handling heaven.af.mil with tinydns on IP address 1.2.3.5.

Answer: This answer assumes that your boot scripts are already running svscan in a /service directory. pickdns relies on svscan to start it and to restart it at boot time.

You will have to make three decisions:

Create the service directory by running the pickdns-conf program, with your IP address at the end of the line:
     pickdns-conf pickdns dnslog /etc/pickdns 1.2.3.20
Tell svscan about the new service:
     ln -s /etc/pickdns /service
svscan will start the service within one minute.

Now change directory to /service/pickdns/root, and create a new data file listing the web-server IP addresses in pickdns-data format:

     +www.heaven.af.mil:1.2.3.150
     +www.heaven.af.mil:1.2.3.151
     +www.heaven.af.mil:1.2.3.152
     +www.heaven.af.mil:1.2.3.153
     # and so on
Run
     make
to tell pickdns about the data.

On the heaven.af.mil DNS server, delegate www.heaven.af.mil to 1.2.3.20:

     cd /service/tinydns/data
     ./add-childns www.heaven.af.mil 1.2.3.20
     make

How do I send different clients to different clusters of servers? I'd like our local users in 1.2.* and 1.5.* to be directed to a separate cluster of web servers.

Answer: Change directory to /service/pickdns/root, and add location lines to data in pickdns-data format:

     %LU:1.2
     %LU:1.5
     +www.heaven.af.mil:1.2.3.220:LU
     +www.heaven.af.mil:1.2.3.221:LU
     +www.heaven.af.mil:1.2.3.222:LU
The location code LU must be 1 or 2 bytes long.

Run

     make
to tell pickdns about the data.
Is there a table mapping IP addresses to countries? We have clusters of web servers in several countries, and I'd like to send each client to a nearby cluster.

Answer: IANA has a summary of IP address locations, which I've converted into a Network Continent Guide in pickdns-data format.