As part of our isp services, we provide dns for our customers. A growing problem as we add more and more zones, is that customers move their domains out of our nameservers, sometimes without informing us, and thus leaves us with obsolete info in our nameservers...
This small script is written to check against another nameserver that you are authorative for the zones in your dns file, I didn't bother to make it nest up all your include statements, if you have separate files change the var and run the script for those as well :)
hope someone finds this useful. Note that it requires Net::DNS from cpan
#!/usr/bin/perl -w #Change this! my $nsconf="/etc/named.conf"; # Your nameserver config file. my $other_ns="193.212.1.10"; # Nameserver to check against. my @names=("ns.songnetworks.no", "ns.tele1europe.no"); # Names of this nameserver. use strict; use Net::DNS; open CONF,"$nsconf"; my $res = new Net::DNS::Resolver; $res->nameservers($other_ns); while (<CONF>) { # match <<zone "perlmonks.org" in {>> if (m/^zone\s+\"([a-z0-9._\-]+)\"\s+in/i) { my $zone=$1; next if ($zone eq "." || $zone =~ /0.0.127.in-addr.arpa/); my $name=0; my $query = $res->query($zone, "NS"); if ($query) { foreach my $rr ($query->answer) { next unless $rr->type eq "NS"; my $nameserver=$rr->nsdname; $name=1 if grep(/$nameserver/i, @names); } print "$zone is out of date!\n" unless $name; } } }
qw(marcus)
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: weedzones - avoid zonerot!
by Anonymous Monk on Dec 19, 2001 at 07:33 UTC |
Back to
Cool Uses for Perl