DNS cache with DJBDNS for Debian

In order to inaugurate this new Debian section here we go with an easy and quick way to setup your own DNS cache. So let’s go!

A DNS caching resolver performs the function of caching answers to previous queries so that there is no need to repeatedly query for the same information. Setting up such a thing with djbdns is a trivial task. Proceed as follows:

NOTE: This instructions assume Debian Sarge but I guess this is not much different with other Debians.

apt-get install daemontools-installer djbdns-installer ucspi-tcp-src

Then build the packages following the instructions provided by APT (build-daemontool, build-djbdns, etc…).

Once installed proceed with the configuration:

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

Now edit your resolver configuration file to look like this:

nameserver 127.0.0.1

I have had some problems with the init script that Debian Sarge installed (note that I’ve created the files in /etc/dnscache), so I modified a couple of lines and now looks like this:

…..
start)
echo -n “Starting djbdns: ”
#for i in `ls -d /var/lib/svscan/dnscache* /var/lib/svscan/tinydns* /var/lib/svscan/axfrdns* 2>/dev/null`; do
for i in `ls -d /service/dnscache* 2>/dev/null`; do
…..
stop)
echo -n “Stopping djbdns: ”
#for i in `ls -d /var/lib/svscan/dnscache* /var/lib/svscan/tinydns* /var/lib/svscan/axfrdns* 2>/dev/null`; do
for i in `ls -d /service/dnscache* 2>/dev/null`; do
…..

That’s all folks!

References:

Leave a Reply

You must be logged in to post a comment.