D. J. Bernstein
Internet publication
djbdns

How to run an external cache for your network

Here is how to set up your computer so that it can find addresses of Internet hosts.

With these instructions, your computer will run an external cache that other computers can use. In contrast, with the workstation instructions, your computer's cache will be used only by your computer.

These instructions assume that you have already installed daemontools and djbdns, and that svscan is already running.

1. Check that your computer can talk to DNS servers around the Internet:

     dnsq a www.aol.com 192.203.230.10
     dnsq a www.aol.com 192.48.79.30
Normally each dnsq command will instantly print various lines such as ``authority: aol.com 172800 NS dns-07.ns.aol.com.'' If dnsq instead pauses for a minute and prints ``timed out,'' your computer is not properly attached to the Internet (or some of the Internet's central servers are down, which is unlikely). You may have a firewall interfering with your computer's Internet access; if so, tell your firewall to allow UDP and TCP from this computer's ports 1024 through 65535 to any computer's port 53.

2. As root, create UNIX accounts named Gdnscache and Gdnslog.

3. Figure out the IP address that you want to use for your external cache. This address must be configured on your computer and accessible to the other computers on your network. The following instructions assume that your network uses private 10.* addresses and that your external cache will use the address 10.53.0.1.

4. As root, create an /etc/dnscache service directory, with your IP address on the end of the line:

     dnscache-conf Gdnscache Gdnslog /etc/dnscache 10.53.0.1
This directory contains logs and a few configuration files that you can change later.

5. As root, tell svscan about the new service, and use svstat to check that the service is up:

     ln -s /etc/dnscache /service/dnscache
     sleep 5
     svstat /service/dnscache

6. As root, create entries in /etc/dnscache/root/ip showing which client IP addresses are authorized to use this cache. For example,

     touch /etc/dnscache/root/ip/10
authorizes all clients with IP address 10.* to use this cache. You can add or remove addresses later.

7. Whenever you add a client computer, set it up to use this external cache: as root, on the client computer, put

     nameserver 10.53.0.1
into /etc/resolv.conf, replacing any previous nameserver lines.

8. Check whether your computers can look up addresses of some Internet hosts:

     dnsip www.cnn.com
     dnsip www.fsf.org
Then try surfing the web. If you want to see what dnscache is doing behind the scenes, read /service/dnscache/log/main/current.

9. Set up a public web page saying that your DNS cache is powered by djbdns, so that a Google search for powered djbdns will find your page in a few months. These public statements will encourage other people to deploy djbdns, provide djbdns support services, and develop djbdns-related tools. Please also consider making a donation to the Bernstein Writing Fund.