
We are going to setup and configure DNS server for a small network with hundred units of networked computers. Due to cost factor, the most organizations decide to run an open-source DNS daemon on Linux server.
As the djbdns / tinydns server performance is quite satisfactory! Therefore, we take this opportunity to write out our tinydns setup blog for users.
First download daemontools.tar.gz and djbdns.tar.gz as follows.
cd /tmp wget http://walkernewsdownload.googlepages.com/daemontools-0.76.tar.gz wget http://walkernewsdownload.googlepages.com/djbdns-1.05.tar.gz
djbdns runs under daemontools so daemontools should be installed. Let’s install daemontools.
For daemontools we need to create /package directory
mkdir –p /package chmod 1755 /package
After creating /package directory just copy daemontools-0.76.tar.gz into /package directory and untar the gzipped source code:
tar -zxvpf daemontools-0.76.tar.gz cd admin/daemontools-0.76
Fix daemontools compilation problem on latest version of glibc package:
edit file src/error.h to replace extern int errno; with #include
After fixing the glibc run this command to install daemntools
package/install
The above command will install daemontools and start the service. You can check the process of daemontools using this command.
command ps -aux | grep svscan
The output something like this.
/bin/sh /command/svscanboot and svscan /service are running.
daemontools is configure. Let’s install djbdns server
Copy djbdns-1.05.tar.gz into /package directory and un-zip the gzipped source code:
tar -zxvpf djbdns-1.05.tar.gz cd /package/djbdns-1.05
Fix djbdns / tinydns compilation problem on latest version of glibc package:
vi error.h to replace extern int errno; with #include
After fixing the glibc execute these commands to install djbdns
make make setup check
Configure djbdns
We need to create tinydns user account to run tinydns service and logging facility:
/usr/sbin/useradd –s /bin/false tinydns /usr/sbin/useradd –s /bin/false dnslog
Configure tinydns service with the bundled tinydns-conf utility:
tinydns-conf tinydns dnslog /etc/tinydns 192.168.1.1
The tinydns-conf utility will configure tinydns user account to run tinydns service, dnslog user account to run DNS logging facility, creates /etc/tinydns directory and defines that the tinydns service will listen on the server IP address (192.168.1.1).
Create symbolic link of /etc/tinydns to /service directory so that the svscan of daemontools will start up tinydns service and continue monitor the states:
ln –s /etc/tinydns /service
To confirm the tinydns service is running:
svstat /service/tinydns
Alternative, you can use netstat or lsof command to confirm the UDP port 53 (domain service port as per RFC-1035) has been opened by djbdns / tinydns:
netstat -tulpa | grep domain lsof -i | grep domain
Now, it’s time to maintain the data file of tinyDNS. The tinyDNS stores DNS information in /service/tinydns/root/data file. We need to edit data file
cd /service/tinydns/root vi data
and insert the djbdns / tinydns server IP as the first record:
..:192.168.1.15:a:259200
Subsequently, add hostname-IP of other networked computers into this ASCII text file. For example,
=dev.techbabu.comt:192.168.1.1:300 =images.techbabu.com:192.168.1.1:300
to add hostname-IP of dev.techbabu.com (the djbdns / tinydns server itself) and images.techbabu.com (just another internal networked host). Detailed format of data file records is given below.
After save and exit the /service/tinydns/root/data file, type make command (must be done inside /service/tinydns/root directory) to “compile” the /service/tinydns/root/data to /service/tinydns/root/data.cdb, which is used by the daemon to resolve hostname-IP requests.
cd /service/tinydns/root make
Given below is specific format of TinyDNS Records
Z defines the zone record & defines a name server @ defines an MX record + defines an A record ^ defines a PTR record = defines BOTH an A record and the PTR record at once C defines a CNAME -- DO NOT USE THESE
Here is sample data for domain techbabu.com
Ztechbabu.com:ns1.techbabu.com.:hostmaster.techbabu.com &techbabu.com::ns1.techbabu.com &techbabu.com::ns2.techbabu.com @techbabu.com::techbabu.com.:10 +techbabu.com:192.168.1.1 +*.techbabu.com:techbabu.com =dev.techbabu.comt:192.168.1.1:300 =images.techbabu.com:192.168.1.1:300 ..:192.168.1.1:a:259200
To test your tinydns Server, use 192.168.1.1 as nameserver in your resolv.conf.
vi /etc/resolv.conf nameserver 192.168.1.1
Query DNS to find NS, MX & A records
nslookup techbabu.com
The output should be like this
Server: 192.168.1.1 Address: 192.168.1.1#53
Name: techbabu.com Address: 192.168.1.1
That is our tinyDNS step is completed and working as per our requirements.
