Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

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="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)

Comment on weedzones - avoid zonerot!
Select or Download Code
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 "perlmonks.org" {>> if (m/^zone\s+\"([a-z0-9._\-]+)\"\s+/i) {

    I don't say 'zone "perlmonks.org" 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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2014-09-17 21:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (99 votes), past polls