• Member Login

    Sign Up !

    Forgot Password ?




Log-in|Register
  • Buy iRedlof Ajax Login v4.0 [WP]

    Add to Cart Buy Now!

Shell script to check domain serial numbers across all name servers

#!/bin/bash
# Linux shell script to check BIND named domain serial numbers across all name servers
# Tested on RHEL, Fedora, Centos and Debian Linux
# Requires named-checkzone, host utilities, and BIND server.
# -----------------------------------------------------
# This script is licensed under GNU GPL version 2.0 or above
# -----------------------------------------------------
# This script is part of nixCraft shell script collection (NSSC)
# Visit http://blog.iredlof.com/ for more information.
# -----------------------------------------------------
# Last updated on : March-2009.
# -----------------------------------------------------
### Set me ###
CZBASE=/etc/bind/zones
NAMED_CHKZON=/usr/sbin/named-checkzone
NS1=ns1.nixcraft.com
NS2=ns2.nixcraft.com
NS3=ns3.nixcraft.com
ZPREF=master
if [ $# -eq 0 ]
then
echo "$0 domain-name"
exit 1
fi
d=$1
ZONEFILE=${CZBASE}/${ZPREF}.${d}
if [  -f $ZONEFILE ]
then
S1=$(host -t soa $d $NS2 | grep "^$d" | awk ''{ print $7 }'')
S2=$(host -t soa $d $NS3 | grep "^$d" | awk ''{ print $7 }'')
M=$($NAMED_CHKZON -t $CZBASE $d ${ZPREF}.${d}| grep "$d" | awk ''{ print $5 }'')
echo -e "$NS1 # $S1\\n$NS2 # $S2\\n$NS3 # $M"
$NAMED_CHKZON -q -t $CZBASE $d ${ZPREF}.${d}
[ $? -eq 0 ] && echo "$d : OK"
[ $S1 -eq $S2 -a $S1 -eq $M -a $S2 -eq $S1 -a $S2 -eq $M -a $M -eq $S1 -a $M -eq $S2 ] \\
&& echo "$d : Serial numbers same!" || echo "$d : Serial number different, reload named!"
else
echo "Error - $d domain or $ZONEFILE zone file does not exits!"
fi

Input :

$ ./zonev iredlof.com

Output :

ns1.nixcraft.com # 2008072318
ns2.nixcraft.com # 2008072318
ns3.nixcraft.com # 2008072318
iredlof.com : OK
iredlof.com : Serial numbers same!
VN:F [1.9.3_1094]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.3_1094]
Rating: 0 (from 0 votes)
This entry was posted in Ubuntu. Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

Post a Comment

You must be logged in to post a comment.