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)


In reply to weedzones - avoid zonerot! by marcus

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.