Feb 022011

I’ve found this usefull script on bind-user mailing list, to check NS serial number if they are in the same value.
credit: pyh – at – mail.nsbeta.info

use strict;
use Net::DNS;
use Getopt::Std;
my %opts;

getopts('hm:s:z:', \%opts);
if ($opts{'h'}) {
my $master = $opts{'m'} || usage();
my $slave = $opts{'s'} || usage();
my $zone = $opts{'z'} || usage();
my $s1 = qrsoa($master,$zone);
my $s2 = qrsoa($slave,$zone);
if ($s1 != -1 && $s1 == $s2) {
 print "OK\n";
 exit 0;
} else {
 print "CRITICAL: zone $zone sync error\n";
 exit 2;

sub qrsoa {
 my $host = shift;
 my $zone = shift;
 my $res   = Net::DNS::Resolver->new(nameservers => [$host]);
 my $query = $res->query($zone, "SOA");
 return $query ? ($query->answer)[0]->serial : -1;

sub usage {
 print <<EOF;
 Usage: $0 -m -s -z example.com
 -m  master DNS ip or name
 -s  slave DNS ip or name
 -z  zone name
 -h  show this help page
 exit 0;


$ ./nsserial.pl -m ns1.he.net -s ns1.kutukupret.com -z kutukupret.com

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>