OpenBSD Wiki
Advertisement

Before installing djbdns, you must have daemontools and ucspi-tcp installed.

Installation[]

cd /usr/src
wget http://cr.yp.to/djbdns/djbdns-1.05.tar.gz
tar xpzf djbdns-1.05.tar.gz
cd djbdns-1.05
make
make setup check

chmod 0755 /usr/local /usr/local/bin

The chmod is because hier.c is modifying /usr/local and /usr/local/bin to 02755 and /etc/security then complaints.

Configuration[]

dnscache:[]

groupadd -g 5000 nofiles
useradd -u 5010 -g nofiles -d /var/dnscache -s /sbin/nologin dnscache
useradd -u 5011 -g nofiles -d /var/dnscache/log -s /sbin/nologin dnslog

dnscache-conf dnscache dnslog /var/dnscache 192.168.0.1
cd /var/dnscache
dd if=/dev/srandom of=seed bs=128 count=1
chown -R dnscache:nofiles .
chown -R dnslog log
touch /var/dnscache/root/ip/192.168.0

ln -s /var/dnscache /service

Where 192.168.0.1 is the IP address where you will run the DNS cache. (with dnscache-conf)

You allow the entire 192.168.0 network to access your DNS cache. (with touch)

Patches[]

Dumpcache:[]

As dnscache works only on memory it will discard all it's content of cache data upon reboot. This is a patch to djbdns that will enable you to dump the cache from a running dnscache, or load a previously dumped cache at startup.
It is useful when you have an OpenBSD box that you shutdown daily and you want to preserve all the dns resolved catches that djbdns have done.

Download the patch from http://efge.free.fr/djbdns/
Outside of your djbdns-1.05 directory apply the patch, stop dnscache, compile and install:

patch -p0 < patch-dnscache-dumpcache-v4.txt
svc -d /service/dnscache
cd djbdns-1.05
make
make setup check

Configure some dumpcache options and restart dnscache:

cd /service/dnscache/env
echo dump/dumpcache > DUMPCACHE
echo dump/dumpcache.tmp > DUMPCACHETMP
echo dump/dumpcache > SLURPCACHE
svc -t /service/dnscache

You can configure the logs to show only the lines you want. Here is an example of /service/dnscache/log/run:

#!/bin/sh
exec setuidgid dnslog multilog t '-*' '+* stats *' '+* slurp *' \
 '+* dump *' '+* tcp*' '+* cachesize *' '+* starting' ./main

You need to tell OpenBSD to dump the cache to the file upon reboot or shutdown. Here is an example of /etc/rc.shutdown:

# dump djbdns cache:
/usr/local/bin/svc -a /service/dnscachex

At startup dnscache will automatically read the file in SLURPCACHE and load its contents.

Links[]

  • daemontools
  • ucspi-tcp

References[]

Advertisement