A howto on building a DNS caching and Resolving server with dnscache. This server will resolve and cache DNS requests from root servers for other networks/machines.

Scenario : For example all machines of network 10.20.x.x will be using this server with IP for DNS resolution.


  • Centos server ( any other Linux/Unix distro can be used )
  • Atleast 1 configured public IP address :: Let it be ( you need to do configure a proper IP )


daemontools must be installed for monitoring and supervising dnscache

Step 1

Install daemontools

root@serv:~# yum install make gcc

root@serv:~# cd /usr/src
root@serv:~# wget http://www.qmail.org/moni.csi.hu/pub/glibc-2.3.1/daemontools-0.76.errno.patch

root@serv:~# mkdir -p /package
root@serv:~# chmod 1755 /package
root@serv:~# cd /package
root@serv:~# wget  http://cr.yp.to/daemontools/daemontools-0.76.tar.gz
root@serv:~# tar -zxvf daemontools-0.76.tar.gz
root@serv:~# rm daemontools-0.76.tar.gz
root@serv:~# cd admin/daemontools-0.76
root@serv:~# patch -p1 < /usr/src/daemontools-0.76.errno.patch
root@serv:~# package/install

Step 2

Install djbdns package

root@serv:~# cd /usr/src/
root@serv:~# wget http://cr.yp.to/djbdns/djbdns-1.05.tar.gz
root@serv:~# tar -xf djbdns-1.05.tar.gz
root@serv:~# cd djbdns-1.05
root@serv:~# echo gcc -O2 -include /usr/include/errno.h > conf-cc
root@serv:~# make
root@serv:~# make setup check


You need to configure dnscache to listen to the IP configured on your server so that external machines can use it as resolver IP

root@serv:~# useradd dnslog
root@serv:~# useradd dnscache
root@serv:~# dnscache-conf dnscache dnslog /etc/dnscache

Add it to svscan to keep the service under monitoring

root@serv:~# ln -s /etc/dnscache /service/dnscache
root@serv:~# svc -d /service/dnscache
root@serv:~# svc -u /service/dnscache

Authorize the external network that want to use the server as a DNS resolver ( as an example  10.20.x.x )

root@serv:~# touch /etc/dnscache/root/ip/10.20

Client Configuration

You will be able to use the IP as DNS nameserver on all machine of network 10.20.x.x

Log file