Changeset 346


Ignore:
Timestamp:
06/13/12 15:05:29 (12 years ago)
Author:
Kris Deugau
Message:

/trunk

Delegation type now exports correctly, or at least as correctly as the
input data can manage. Nested super-/24 and sub-/24 delegations may
not resolve correctly depending on whether a DNS server hands out only
the super-/24 delegation records or only the CNAMEs for the sub-/24, or
both.

As a nice bonus, it doesn't matter for most delegations whether you use
explicit NS records or the "Delegation" pseudotype. Only sub-/24
delegations will not be fully created (including the CNAMEs for each IP)
with just NS records.

See #26.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/DNSDB.pm

    r345 r346  
    43504350
    43514351        if ($revrec eq 'y') {
    4352 
    4353 print "$zone has\t$val NS $host\n";
    43544352          $val = NetAddr::IP->new($val);
    4355           $zone = NetAddr::IP->new($zone);
    4356 #print "$val NS $host\n";
    43574353          # handle split-n-multiply SOA for off-octet (8 < mask < 16) or (16 < mask < 24) v4 zones
    43584354          if (!$val->{isv6} && ($val->masklen < 24) && ($val->masklen % 8 != 0)) {
    4359             foreach my $szone ($zone->split($val->masklen + (8 - $val->masklen % 8))) {
     4355            foreach my $szone ($val->split($val->masklen + (8 - $val->masklen % 8))) {
    43604356              my $szone2 = _ZONE($szone, 'ZONE.in-addr.arpa', 'r', '.');
    4361 next if $$recflags{"$szone2-sub"} && $zone != $val;
    4362 print " $szone2-sub     NS $host\n";
    4363 # && $zone == $val;
     4357              next if $$recflags{$szone2} && $$recflags{$szone2} > $val->masklen;
    43644358              print $datafile "\&$szone2"."::$host:$ttl:$stamp:$loc\n";
    4365               $$recflags{"$szone2-sub"}++ if $zone != $val;
     4359              $$recflags{$szone2} = $val->masklen;
    43664360            }
    4367 #print "recflags should have stuff set?\n";
    4368             return; # skips "default" bits just below
     4361          } elsif ($val->{isv6} && ($val->masklen < 64) && ($val->masklen % 4 !=0)) {
     4362            foreach my $szone ($val->split($val->masklen + (4 - $val->masklen % 4))) {
     4363              my $szone2 = _ZONE($szone, 'ZONE.ip6.arpa', 'r', '.');
     4364              next if $$recflags{$szone2} && $$recflags{$szone2} > $val->masklen;
     4365              print $datafile "\&$szone2"."::$host:$ttl:$stamp:$loc\n";
     4366              $$recflags{$szone2} = $val->masklen;
     4367            }
     4368          } else {
     4369            my $val2 = _ZONE($val, 'ZONE', 'r', '.').($val->{isv6} ? '.ip6.arpa' : '.in-addr.arpa');
     4370            print $datafile "\&$val2"."::$host:$ttl:$stamp:$loc\n";
     4371            $$recflags{$val2} = $val->masklen;
    43694372          }
    4370 my $val2 = _ZONE($val, 'ZONE', 'r', '.').($val->{isv6} ? '.ip6.arpa' : '.in-addr.arpa');
    4371 #print "checking recflags for $val\n";
    4372 #return if $$recflags{$val};
    4373           print $datafile '&'.$val2."::$host:$ttl:$stamp:$loc\n";
    4374           $$recflags{"$val2-sub"}++ if $val == $zone;
    4375 print "$zone;\t$val2-sub NS $host\n";
    4376 ##NSfixme
    43774373        } else {
    43784374          print $datafile "\&$host"."::$val:$ttl:$stamp:$loc\n";
     
    45334529        # This is intended for reverse zones, but may prove useful in forward zones.
    45344530
    4535 if ($revrec eq 'n') {
    4536   # It's an NS record.  Recurse and handle.
    4537   _printrec_tiny($datafile,$revrec,$recflags,$zone,$host,$reverse_typemap{'NS'},
    4538         $val,$dist,$weight,$port,$ttl,$loc,$stamp);
    4539 } else {
    4540   # It's a delegation.  We may need to actually generate several NS records, and
    4541   # for IPv4 we may also need to generate a set of CNAMEs for sub-/24 blocks.
    4542 #  print "delegation $val to $host\n";
    4543   my $dblock = NetAddr::IP->new($val);
    4544   if ($dblock->{isv6}) {
    4545     my @subs = $dblock->split($dblock->masklen + (4 - $dblock->masklen % 4) % 4);
    4546     foreach (@subs) {
    4547       _printrec_tiny($datafile, $revrec, $recflags, $zone, $host, $reverse_typemap{'NS'},
    4548         "$_", $dist, $weight, $port, $ttl, $loc, $stamp);
    4549     }
    4550   } else {
    4551     my @subs = $dblock->split($dblock->masklen + (8 - $dblock->masklen % 8) % 8);
    4552     foreach (@subs) {
    4553       if ($dblock->masklen <= 24) {
    4554         _printrec_tiny($datafile, $revrec, $recflags, $zone, $host, $reverse_typemap{'NS'},
    4555                 "$_", $dist, $weight, $port, $ttl, $loc, $stamp);
    4556 #print $datafile "$_ NS $host\n";
    4557 ##nsdeleg
    4558       } else {
    4559         my ($oct) = ($_->addr =~ /(\d+)$/);
    4560         #print "$_ CNAME $oct."._ZONE($dblock, 'ZONE.in-addr.arpa', 'r', '.')."\n";
    4561       }
    4562     }
    4563   }
    4564 
    4565 #print $datafile "C$host:$val:$ttl:$stamp:$loc\n";
    4566 }
     4531        # All delegations need to create one or more NS records.  The NS record handler knows what to do.
     4532        _printrec_tiny($datafile,$revrec,$recflags,$zone,$host,$reverse_typemap{'NS'},
     4533                $val,$dist,$weight,$port,$ttl,$loc,$stamp);
     4534        if ($revrec eq 'y') {
     4535          # In the case of a sub-/24 v4 reverse delegation, we need to generate CNAMEs
     4536          # to redirect all of the individual IP lookups as well.
     4537          # Not sure how this would actually resolve if a /24 or larger was delegated
     4538          # one way, and a sub-/24 in that >=/24 was delegated elsewhere...
     4539          my $dblock = NetAddr::IP->new($val);
     4540          if (!$dblock->{isv6} && $dblock->masklen > 24) {
     4541            my @subs = $dblock->split;
     4542            foreach (@subs) {
     4543              next if $$recflags{"$_"};
     4544              my ($oct) = ($_->addr =~ /(\d+)$/);
     4545              print $datafile "C"._ZONE($_, 'ZONE.in-addr.arpa', 'r', '.').":$oct.".
     4546                _ZONE($dblock, 'ZONE.in-addr.arpa', 'r', '.').":$ttl:$stamp:$loc\n";
     4547              $$recflags{"$_"}++;
     4548            }
     4549          }
     4550        }
    45674551
    45684552      } else {
Note: See TracChangeset for help on using the changeset viewer.