User Tools

Site Tools


convert_tinydns_data_format_to_zone_file_format_described_by_rfc_1035_bind-style

This is an old revision of the document!


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

Requirements

Script

#!/bin/bash
set -e
cd /etc/tinydns/root
make
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/$domain.zone
   echo -e '$TTL 86400\n' >> zone/$domain.zone
   dig +nostats +onesoa +nocmd @127.0.0.1 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/$domain.zone
done

rm -f zone/zones.conf.*
grep "^\." data | cut -d: -f1 | uniq | cut -c2- | while read domain; do
   sed -e "s/XXX/$domain/" zone-list-master.tpl >> zone/zones.conf.master
   sed -e "s/XXX/$domain/" zone-list-slave.tpl >> zone/zones.conf.slave
done
zone-list-master.tpl
<zone>
   domain      XXX
   file        masters/XXX.zone
   type        master
   #dnssec-policy           "normal-policy"
</zone>
zone-list-slave.tpl
<zone>
   domain      XXX
   file        slaves/XXX.zone
   type        slave
   master      10.0.0.1
</zone>
convert_tinydns_data_format_to_zone_file_format_described_by_rfc_1035_bind-style.1549364290.txt.gz · Last modified: 2020/04/08 21:22 (external edit)