User Tools

Site Tools


Convert tinydns data format to zone file format described by RFC 1035 (bind-style)

This simple script converts the content of tinydns' data file into separate zone files - one zone file per domain. The major conversion is done by the axfrdns program which is part of djbdns.


  • Access to tinydns' data file - the script below assumes its location in /etc/tinydns/root. If it is located in a different path simply adjust the script.

Setting up axfrdns

Use axfrdns-conf. Make sure that the user account gaxfrdns and the group gdnslog exists. The following lines will set up axfrdns to listen on and to control the process via daemontools.

axfrdns-conf gaxfrdns gdnslog /etc/axfrdns /etc/tinydns
ln -s /etc/axfrdns /etc/service

Conversion Script


set -e
cd /etc/tinydns/root
mkdir -p zone
SERIAL=$(date +%Y%m%d)01
grep "^\." data | cut -d: -f1 | uniq | cut -c2- | while read domain; do
   echo -e "; vim\\x3a ts=8" > zone/$
   echo -e '$TTL 86400\n' >> zone/$
   dig +nostats +onesoa +nocmd @ AXFR $domain | \
   sed -e "s/\(.*\)2560\(.*SOA\t[^ ]\+ [^ ]\+ \)[0-9 ]\+/\1259200\2(\n\t$SERIAL ; serial\n\t3H         ; refresh\n\t1H         ; retry\n\t3W         ; expire\n\t600)       ; ttl neg caching/" >> zone/$
convert_tinydns_data_format_to_zone_file_format_described_by_rfc_1035_bind-style.txt · Last modified: 2020/04/08 21:28 by admin