FreeBSD DJBDNS: Create Secondary TinyDNS Server

How do I create a secondary djbdns dns name server to resolve names if primary went down?

You can easily create secondary dns server using djbdns. Type the following commands to install secondary DNS server on FreeBSD server itself (type all the following commands on Secondary NameServer Installation and Configuration

Install djbdns:
# portsnap fetch update
# cd /usr/ports/dns/djbdns
# make install clean && rehash

Create users and required directories:
# pw groupadd dnsusers
# pw useradd tinydns -s /bin/nologin -G dnsusers
# pw useradd dnslog -s /bin/nologin -G dnsusers
# pw useradd axfrdns -s /bin/nologin -G dnsusers
# mkdir /var/service/
# echo 'svscan_enable="YES"' >> /etc/rc.conf
# /usr/local/etc/rc.d/ start

Create Directory For Your Zone File

You need to create /var/ as follows:
# mkdir /var/
# tinydns-conf tinydns dnslog /var/
# ln -s /var/ /var/service/
# sockstat -4 -p 53

Now, your secondary tinydns server is running.

How Do I Replicate My DNS Data From (first tinydns server)?

You have two options here as follows:

Replicating Your DNS Data Using axfrDNS Program

axfrdns bind to TCP port # 53. It reads a zone-transfer request in DNS-over-TCP format from its standard input, and responds with locally configured information. This program is useful to talk with external dns servers such as BIND. Using tcp client one can request a zone-transfer request for secondary tinydns. It is also useful to answer queries on TCP port # 53. Usually most client will use UDP port. See how to setup axfrdns on primary name server to accept a zone-transfer requests.

Replicating Your DNS Data ( Using rsync or scp

You can just copy the generated data.cdb to the second tinydns name server using rsync or scp. This is preferred method when you just want to talk between your own two tindydns servers. Simply use scp command as follows to copy data.cdb from primary name server
# scp /var/
You can automate this procedure from itself. Login to your primary name server and cd to /var/
# cd /var/
Open Makefile file, enter:
# vi Makefile
Update file as follows (to avoid password prompt setup ssh-key based login between and

remote: data.cdb
	/usr/local/bin/rsync -az -e ssh data.cdb

data.cdb: data

Save and close the file. Finally, update Makefile on as follows:
# cd /var/
# vi Makefile

Append the following line protects data.cdb by stopping make:
# echo "foo" > Makefile

Posted by: SXI ADMIN

The author is the creator of SXI LLC and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

Leave a Reply

Your email address will not be published. Required fields are marked *

Previous Post

How to Make Website WCAG Compliant?

Next Post

Link download Kali Linux 2020.1 (ISO + Torrent)

Related Posts