dns replication using rsync
There are many ways to transfer domain information among DNS Servers, but the preferred method using djbdns (or tinydns) is through rsync using ssh.
There is a tiny program/script called axfrdns, but this is most likely used to update DNS servers running bind.
Since tinydns/djbdns uses a single data file to store domain information, it is easy to simply setup a few servers that will “replicate” dns — providing master-master replication and synchronization, as opposed to master-slave replication.
Here’s how some friends and I have it setup.
We created a dnsadmin user on each box. We then created public/private ssh keys using ssh-keygen:
After copying the generated id_dsa.pub entry to the other server’s trusted, authorized_keys2 :
We then tested a quick copy:
And after some permission fixes, came up with this script that goes in /var/tinydns/root/ to update dns on all 3 boxes:
## pushes out dns changes to backup servers
make=”/usr/bin/make”
rsync=”/usr/bin/rsync”
chown=”/usr/bin/chown”
remoteips=”xxx.xxx.xxx.xxx”
remoteuser=”dnsadmin”
identity=”/home/dnsadmin/.ssh/id_dsa”
$make
$chown dnsadmin:root /var/tinydns/root/data.cdb
$chown dnsadmin:root /var/tinydns/root/data
for ip in $remoteips; do
$rsync -az -e “ssh -i $identity” data $remoteuser@$ip:/var/tinydns/root/data
$rsync -az -e “ssh -i $identity” data.cdb $remoteuser@$ip:/var/tinydns/root/data.cdb
done
