Created
September 29, 2013 12:38
-
-
Save bessangel/6752176 to your computer and use it in GitHub Desktop.
Synchronize slave dns zone between bind9 servers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## slave-dns-reload.sh | |
#!/bin/bash | |
cd /etc/bind | |
MASTERS=`grep "type master" -B1 named.conf.local | perl -ne '/"(.*)"/ && print "$1\n"'` | |
for i in $MASTERS;do perl -i -pe "if(/zone \"$i\"/){ \$_=''} " slave-zones.conf.tmp ; done | |
test `diff -w slave-zones.conf slave-zones.conf.tmp | wc -l` -gt 0 && cp slave-zones.conf{.tmp,} && /etc/init.d/bind9 reload | |
###slave-dns-send.sh | |
#!/bin/sh | |
cd /etc/bind | |
MASTER_IP=XXX.XXX.XXX.XXX | |
(for i in `grep "type master" -B1 named.conf.local | perl -ne '/"(.*)"/ && print "$1\n"' `; | |
do | |
echo "zone \"$i\" { type slave; allow-transfer {none;}; masters {$MASTER_IP;}; file \"/var/lib/bind/slave-$i.host\";};"; | |
done;) | \ | |
ssh -i /home/bind9sync/.ssh/id_rsa bind9sync@srv2.mitalex.org "(cd /etc/bind; cat - > slave-zones.conf.tmp)" | |
#### add in named.conf | |
include "/etc/bind/slave-zones.conf"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment