Skip to content

Instantly share code, notes, and snippets.

@b4ldr
Last active August 29, 2015 14:05
Show Gist options
  • Save b4ldr/d1d6448af82a0c46b4de to your computer and use it in GitHub Desktop.
Save b4ldr/d1d6448af82a0c46b4de to your computer and use it in GitHub Desktop.
ZONE_PATH="/home/bind"
BIND_PATH="/var/lib/bind"
TMP=$(mktemp)
FC="dns.zones.txt"
for ZONE in $(awk '$2=="Primary" {print $1}' "${ZONE_PATH}/${FC}")
do
echo -e "zone ${ZONE} {\n\ttype slave;\n\tmasters { 192.168.1.100; };\n\tfile \"${BIND_PATH}/${ZONE}.zone\";\n};"
done > ${TMP}
for ZONE in "${BIND_PATH}/*.zone"
do
grep -q "^${ZONE##*/}" "${TMP}" || rm "${ZONE}"
done
mv ${TMP} /etc/bind/named.conf.slave-zones
rndc reload
ZONE_PATH="/home/bind"
BIND_PATH="/var/lib/bind"
TMP=$(mktemp)
FC="dns.zones.txt"
for ZONE in $(awk '$2=="Primary" {print $1}' "${ZONE_PATH}/${FC}")
do
printf "zone %s {\n\ttype slave;\n\tmasters { 192.168.1.100; };\n\tfile \"%s/%s.zone\";\n};\n" "${ZONE}" "${BIND_PATH}" "${ZONE}"
done > ${TMP}
for ZONE in "${BIND_PATH}/*.zone"
do
grep -q "^${ZONE##*/}" "${TMP}" || rm "${ZONE}"
done
mv ${TMP} /etc/bind/named.conf.slave-zones
rndc reload
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment