puzzling.org · mary.gardiner.id.au · Macquarie University

djbdns tricks

[mid 2000]

Setting up local DNS on a private network using djbdns on a single machine.

First of all, a note about tinydns - it only returns authoritative records - ie if it can't find the information in its own databases, it returns nothing. Secondly, a note about tinydns and dnscache - they won't share an interface. Thirdly a note about dnscache - it only returns non-authoritative answers.

The reason for all the notes is that this system won't work on a server you intend to register with the appropriate authorities as a DNS server. You'll need, to bite the bullet, and put tinydns on a public interface, meaning you'll have to have two IP addresses, if you want dnscache too.

Anyhow, onto to the private network stuff.

You have a private network, and you want to assign hostnames to computers in the private address space. You want to use a single machine to do the DNS serving for the local addresses, and to look up external addresses as well.

Assume your local network is 192.168.0, and you have four machines on it: 192.168.0.1, 192.168.0.2, 192.168.0.3 and 192.168.0.4. Their names are going to be happy.local, sad.local, grumpy.local and silly.local. Assume 192.168.0.1 is going to be the nameserver.

You've compiled djbdns and have svscan running. If not see here first and here next.

For reasons outlined above, namely that tinydns won't do the external lookups for you, you only put tinydns on the loopback (local) interface, it's not the one everyone else wants to talk to. On machine 192.168.0.1 you create accounts tinydns and dnslog and install tinydns on 127.0.0.1:

tinydns-conf tinydns dnslog /etc/tinydns 127.0.0.1

You tell svscan about tinydns:

ln -s /etc/tinydns /service

You tell tinydns the domains it is expected to serve for:

cd /service/tinydns/root
./add-ns local 127.0.0.1
./add-ns 0.168.192.in-addr.arpa 127.0.0.1
make

You add the hostnames to tinydns's database:

cd /service/tinydns/root
./add-host happy.local 192.168.0.1
./add-host sad.local 192.168.0.2
./add-host grumpy.local 192.168.0.3
./add-host silly.local 192.168.0.4
make

Now create account dnscache and install external dnscache on 192.168.0.1:

dnscache-conf dnscache dnslog /etc/dnscachex 192.168.0.1

Tell svscan about dnscache:

ln -s /etc/dnscachex /service/

You tell dnscache to answer any hosts in the 192.168.0 space:

touch /service/dnscachex/root/ip/192.168.0

You tell dnscache to talk to tinydns for any hosts in 192.168.0 and .local:

cd /service/dnscachex/root/servers
echo "127.0.0.1" > 0.168.192.in-addr.arpa
echo "127.0.0.1" > local

Tell dnscache to start with the new configuration:

svc -t /service/dnscachex

Check the logs in /service/tinydns/log/main/current and /service/dnscachex/log/main/current for errors/connections.

Last modified: 11 September 2003