Change/Update DNS zone serial script
When you changed/updated several DNS zones with a script and need to raise the serial of the dns zone, this script might be handy for you.
#!/bin/sh
#
# --------------------------------------------
# Author: Ferdinant Visser
# Visit http://www.vtek.nl for more info
# --------------------------------------------
#
# USE THIS SCRIPT AT YOUR OWN RISK!# define file with domains
dnsfile="output.txt"# define where dns zones are stored, include a trailing slash!
named_dir="/var/named/"# define new serial
new_serial="2007032010"#--- no editing below this line -----
cat $dnsfile| while read fileline;
do
grep "[0-9]\{10\}" $named_dir$fileline\.db | \
sed 's/;.*//g' | \
sed 's/[[:space:]]//g' | \
while read line;
do
replace "$line" "$new_serial" -- \
$named_dir$fileline\.db;
done;
done;
How to use this script
- First create a file called output.txt with a list of all domains (each domain on a new line)
- Then check where your dns zones are stored ( in most cases : /var/named/ )
- Define the new serial
- Save the file with a name you like, for example raiseserial.sh and chmod it to 755
- Execute the file!