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
Donation Section: Background
Monero Badge: QR-Code
Monero Badge: Logo Icon Donate with Monero Badge: Logo Text
82uymVXLkvVbB4c4JpTd1tYm1yj1cKPKR2wqmw3XF8YXKTmY7JrTriP4pVwp2EJYBnCFdXhLq4zfFA6ic7VAWCFX5wfQbCC

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."