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

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 0 comments... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf duf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Modern utilitiesbat exa
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg glances gtop jobs killall kill pidof pstree pwdx time vtop
Searchingag grep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
0 comments… add one

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum