Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

weedzones - avoid zonerot!

by marcus (Scribe)
on Nov 26, 2001 at 19:06 UTC ( #127549=CUFP: print w/replies, xml ) Need Help??

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=""; # Nameserver to check against. my @names=("", ""); # 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 "" in {>> if (m/^zone\s+\"([a-z0-9._\-]+)\"\s+in/i) { my $zone=$1; next if ($zone eq "." || $zone =~ /; 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; } } }


Replies are listed 'Best First'.
Re: weedzones - avoid zonerot!
by Anonymous Monk on Dec 19, 2001 at 07:33 UTC
    Wow, I'd just sat down to write the same script, and a search for an example of the Net::DNS::Resolver led me here. I had to make one small change because of a small difference in the formatting of my named.conf...

    # match <<zone "" {>> if (m/^zone\s+\"([a-z0-9._\-]+)\"\s+/i) {

    I don't say 'zone "" in {'... I leave out the 'in'. I'm sure there's a way to make it optional in the regex, but I'm no perl wizard - I was just happy to get it working.

    I hope this helps someone!

    Thanks for the cool script.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: CUFP [id://127549]
Approved by root
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2020-03-28 23:44 GMT
Find Nodes?
    Voting Booth?
    To "Disagree to disagree" means to:

    Results (168 votes). Check out past polls.