Re: Looking for advice - Auditing zones on a set of name servers

2012-03-22 Thread Landon Stewart
..snip..

  I need it to do since sometimes we are authoritative but there are no NS
  records or they are wrong.  I'm also not sure beating on google's name
  servers is a good idea either so you should fill in your OWN recursive
 name
  servers instead f 8.8.8.8 and 8.8.4.4.

 don't you really want to walk the tree from . down? so dig +trace |
 machine-ify
 then make sure that the criteria you care about work out properly?
 (this avoides people's old/legacy/super-long-ttl causing problems in
 the shorter term)


I've done it this way.  Another person wrote me off list and said the same
thing so I've modified things to do it this way and it looks good.

Thanks for your reply!


Looking for advice - Auditing zones on a set of name servers

2012-03-20 Thread Landon Stewart
Hi Everyone,

I'm looking for some advice here.  I'm attempting to clean up a set of name
servers and have a list of domain names that should not actually be hosted
on those name servers.  In some cases there are issues where there are
actually no NS records in a domain but it should be hosted on those name
servers.  In some cases the name servers just aren't authoritative and the
domain should be removed.  The name servers are all djbdns, not that it
matters a whole lot.

I'm wondering if anyone knows of some tools that I can use other than
homegrown ones that are a little more robust in terms of thinking of every
little possible issue for or against a domain than I can think of.  Of a
list of domains that I marked for deletion some of them simply had little
problems but should not be deleted (rather just have their NS records
fixed).  I also don't' want to pound on someone else's recursive name
servers or even the root name servers trying to audit ours since that's not
very nice.  If anything I guess I could spread out the queries if I had the
right tools.

I wrote a quick script that looks up the NS records for a zone, then the A
records for those NS records and checks the resulting IP addresses against
a list of IP addresses that are our name servers.  It's not quite doing all
I need it to do since sometimes we are authoritative but there are no NS
records or they are wrong.  I'm also not sure beating on google's name
servers is a good idea either so you should fill in your OWN recursive name
servers instead f 8.8.8.8 and 8.8.4.4.

Thanks for reading!  :-D

#!/usr/bin/perl
# No warranty or guarantee of fitness for any purpose or use.  Do not use
# if you don't know what it does.
#
use strict;
use Net::Nslookup;

die (Usage: $0 zone list file\n) if !$ARGV[0];

# Array of the IP addresses of YOUR name servers
my @goodns = (
  10.10.0.5,
  10.10.1.5,
);

open(F,$ARGV[0]) or die(Cannot open file: $ARGV[0]\n);
my @zonelist = F;
close(F);
chomp(@zonelist);

#
# Cycle through each zone to find out if we are authoritative on one of the
IPs listed
# above in @goodns.
#
foreach my $zone (@zonelist) {
  # Sub 8.8.8.8 and 8.8.4.4 for your own recursive name server IP addresses
to
  # avoid being rude to google's name servers if you are doing a lot of
lookups.
  #
  # Find the NS records for the zone
  my @pns = nslookup(domain = $zone, type = NS, server = [ '8.8.8.8',
'8.8.4.4'] );
  # Cycle through each NS record and store an IP address for each
  my @dns_a_records = ();
  foreach my $ns (@pns) {
my $arr = nslookup(domain = $ns, type = A, server = [ '8.8.8.8',
'8.8.4.4'] );
push(@dns_a_records,$arr);
  }
  #
  # If @dns_a_records contains stuff that's also in @goodns then it means
  # we are probably authoritative in some way.
  #
  my %goodns=map{$_ =1} @goodns;
  my %dns_a_records=map{$_=1} @dns_a_records;
  my @isect = grep( $goodns{$_}, @dns_a_records );
  if (!@isect) {
@dns_a_records[0] = NONE if (!@dns_a_records);
# We are not authoritative - print the zone and ns record information
with a -
print -:$zone: .join(,,@pns).\[.join(,, @dns_a_records).\]\n;
  } else {
# We are authoritative print it with a +
print +:$zone: .join(,,@pns).\[.join(,, @dns_a_records).\]\n;
  }

}
# END

---
Landon Stewart lstew...@superb.net mailtolstew...@superb.net
Sr. Administrator
Systems Engineering
Superb Internet Corp - 888-354-6128 x 4199
Web hosting and more Ahead of the Rest: www.superb.net


Re: Looking for advice - Auditing zones on a set of name servers

2012-03-20 Thread Christopher Morrow
On Tue, Mar 20, 2012 at 4:53 PM, Landon Stewart lstew...@superb.net wrote:
 I'm looking for some advice here.  I'm attempting to clean up a set of name
 servers and have a list of domain names that should not actually be hosted
 on those name servers.  In some cases there are issues where there are
 actually no NS records in a domain but it should be hosted on those name
 servers.  In some cases the name servers just aren't authoritative and the
 domain should be removed.  The name servers are all djbdns, not that it
 matters a whole lot.

snip

 I wrote a quick script that looks up the NS records for a zone, then the A
 records for those NS records and checks the resulting IP addresses against
 a list of IP addresses that are our name servers.  It's not quite doing all
 I need it to do since sometimes we are authoritative but there are no NS
 records or they are wrong.  I'm also not sure beating on google's name
 servers is a good idea either so you should fill in your OWN recursive name
 servers instead f 8.8.8.8 and 8.8.4.4.

don't you really want to walk the tree from . down? so dig +trace | machine-ify
then make sure that the criteria you care about work out properly?
(this avoides people's old/legacy/super-long-ttl causing problems in
the shorter term)

-chris