V-TEK Weblog about webdevelopment and linux

21Mar/070

Change/Update DNS zone serial script

Shell Script IconWhen 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;

Download the script

How to use this script

  1. First create a file called output.txt with a list of all domains (each domain on a new line)
  2. Then check where your dns zones are stored ( in most cases : /var/named/ )
  3. Define the new serial
  4. Save the file with a name you like, for example raiseserial.sh and chmod it to 755
  5. Execute the file!
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


No trackbacks yet.