Menü schliessen
Created: February 28th 2023
Categories: Linux
Author: LEXO

BIND Nameserver :: Linux Script to retransfer all all zones registered in BIND

Tags:  bind,  Linux,  nameserver,  script

The following simple script will scrape through all the registered BIND zones and execute the retransfer command for every single zone in just one simple loop:

#! /bin/bash
TIME_START=$(date +"%s")

RNDC="/usr/sbin/rndc"

ls /var/lib/bind/*.hosts | while read zf; do basename $zf .hosts ; done | while read zone ; do
${RNDC} retransfer ${zone}
done

TIME_DIFF=$(($(date +"%s")-${TIME_START}))

echo "Zone Retransfer finished in $((${TIME_DIFF} / 60)) Minutes and $((${TIME_DIFF} % 60)) Seconds."