Intranet: setup DJBDNS to respond for *.local to help development

 

0. Follow instructions to setup a DNS Cache

 

1. Create an alias for eth0:

# nano /etc/network/interfaces

auto eth0:0
iface eth0:0 inet static
       address 10.0.0.251
       netmask 255.255.255.0
       network 10.0.0.0
       broadcast 10.0.0.255
       gateway 10.0.0.254

2 . restart networking

# /etc/init.d/networking restart

 

3. Use tinydns-conf to setup djbdns 

# tinydns-conf dnscache dnslog /etc/tinydns 10.0.0.251

 

# ln -svf /etc/tinydns /etc/service

# cd /etc/service/tinydns/root/

 

 

4. Setup the "local" domain name:

# ./add-ns local 10.0.0.251

#./add-host a.ns.local 10.0.0.251

 

5. Create the data file for tinydns

# cd /etc/service/tinydns/root/

# nano data

 

.local:10.0.0.251:a:259200
=a.ns.local:10.0.0.251:86400
+*.local:10.0.0.250:86400

 
In the sample file above:
– 10.0.0.251 is the IP address of the DNS server, so it is the one responsibe for domain name responses
– 10.0.0.250 is the IP address of your future Web server
 
Save and update data/cdb
# make
 
 
 
6. Edit /etc/resolv.conf
search portnumber53.local
nameserver 10.0.0.251

 

 

7. Let dnscache know about your *.local domain names:

# cd /etc/service/dnscache

# echo 10.0.0.251 > root/servers/local

# chmod 644 root/servers/local

 

8. Restart dnscache

# svc -t .

 

 

 

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

 

 

  • IGlr