DNS BIND 9 Primary named.conf reformat/convert to Secondary server script

JPrine joel at suite224.net
Thu Feb 26 15:33:33 UTC 2004


This script will create a file named "named.conf.gypsy" that is an
exact copy of named.conf, but reformatted to the way a secondary DNS
server needs it. How you get it to the secondary is up to you, i use
crontabs to scp it over every night. Used in combination with "rndc
reload" and "rndc flush" this should eliminate the need for any DNS
maintenance on a secondary server. Please let me know how it
goes...Enjoy!

Here she blows...

***** START *****
#! /bin/sh
cd /etc/

#store number of lines in conf file
lines=`cat named.conf | wc -l`

# bc calculates how many lines to tail - header
modifylines=`echo "$lines-22" | bc`

#write the header to a file (first 22 lines)
head -22 named.conf > named.conf.head

# just modify the zone file lines, the first 22 lines do not need to
be changed
tail -$modifylines named.conf > named.conf.tail

sed -e "s/type master/type slave/g" named.conf.tail > named.conf.slave
sed -e "s/file \"pri\/rev\//file \"sec\/rev\//g" named.conf.slave >
named.conf.rev
sed -e "s/file \"pri\/fwd\//file \"sec\/fwd\//g" named.conf.rev >
named.conf.fwd

awk '{print $0} /\";/ {found=1} /\";/ && found {print "\tmasters { (IP
Address); };\n\tallow-transfer { none; };"}' named.conf.fwd >
named.conf.tailnew

cat named.conf.head named.conf.tailnew > named.conf.gypsy


rm named.conf.tail;rm named.conf.head;rm named.conf.fwd;rm
named.conf.slave;rm named.conf.tailnew;rm named.conf.rev

#SCP it over to secondary
#scp /etc/named.conf.gypsy gypsy.suite224.net:/etc/named.conf
***** END *****


More information about the bind-users mailing list