Intranet: Setup a DNSCACHE for your network using DJBDNS

On this tutorial you will learn how to using DJBDNS to setup a DNS cache to help speed up queries for your local network.

 

I like using Debian, so that is the distribution I'll be using for most of my tutorials. Current version as of this, is Squeeze.

 

0.Install build-essential and daemontools and ucspi-tcp so we can get started:

# apt-get install build-essential ucspi-tcp daemontools daemontools-run

 

You can do everything as root, to make your life easier…. or just do the make commands (if you're paranoid):

 

1. Download and untar DjbDNS

# wget -q http://cr.yp.to/djbdns/djbdns-1.05.tar.gz
# tar -zxvvf djbdns-1.05.tar.gz

 

2. Add users for DjbDNS to /etc/passwd

# echo 'dnscache:*:54321:54321:dnscache:/dev/null:/dev/null' >> /etc/passwd
# echo 'dnslog:*:54322:54322:dnslog:/dev/null:/dev/null' >> /etc/passwd

 

3. Compile DjbDNS nameserver

# cd djbdns-1.05
# echo gcc -O2 -include /usr/include/errno.h > conf-cc

 

4. Compile it

# make

 

5. Install the binaries

# make setup check

 

 

6. Copy the list of IP addresses of the global DNS root servers in /etc/

# cp -rpf dnsroots.global /etc/

 

7.  Configure dnscache:

# ./dnscache-conf dnscache dnslog /etc/dnscache <IP address of this box>

 

8. Allow your network to use the DNS cache

# cd /etc/dnscache/root/ip
# touch 10.0.0

* This assumes you're using a network class A, like 10.0.0.0/24

 

9. Start the daemon

# ln -sf /etc/dnscache /etc/service/dnscache
# ps ax|grep -i readproc
 1071 ?        S      0:00 readproctitle service errors: ................................................................................................................................................................................................................................................................................................................................................................................................................
 1206 pts/1    S+     0:00 grep -i readproc
You can later check it's running using:
 
svstat /etc/service/dnscache
 
10. As root, add:
 
nameserver <IP address of this box>

 

to /etc/resolv.conf

 
 
11. Do a quick test:
(
If you're using ArchLinux, use:
pacman -Syu dnsutils
to install "host"
)
# host portnumber53.com <eth0 IP address>
Using domain server:
Name: localhost
Address: 127.0.0.1#53
Aliases:

portnumber53.com has address 205.186.185.42
portnumber53.com mail is handled by 20 ALT2.ASPMX.L.GOOGLE.com.
portnumber53.com mail is handled by 30 ASPMX2.GOOGLEMAIL.com.
portnumber53.com mail is handled by 20 ALT1.ASPMX.L.GOOGLE.com.
portnumber53.com mail is handled by 30 ASPMX3.GOOGLEMAIL.com.
portnumber53.com mail is handled by 30 ASPMX4.GOOGLEMAIL.com.
portnumber53.com mail is handled by 30 ASPMX5.GOOGLEMAIL.com.
portnumber53.com mail is handled by 10 ASPMX.L.GOOGLE.com.
 
 
12. Report success:
# ( echo 'First M. Last'; cat `cat SYSDEPS` ) \
# | mail djb-sysdeps@cr.yp.to

 

 

 

 

 

 

Don't forget to replace First M. Last with your full name.
 
 

Later on you can monitor what's going under the hood by using:

# tail -f /etc/service/dnscache/log/main/current

 

If you installed following ArchLinux AUR packages, this may work better:

 

#tail -f /etc/dnscache/log/main/current

 

 

Tagged , , , . Bookmark the permalink.

3 Responses to Intranet: Setup a DNSCACHE for your network using DJBDNS

  1. Pingback: Selling Gold Coins For Cash

  2. Pingback: Bluehost Review

  3. Pingback: PAR20 LED lights

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

  • IGlr