- Timestamp:
- 06/13/12 15:05:29 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/DNSDB.pm
r345 r346 4350 4350 4351 4351 if ($revrec eq 'y') { 4352 4353 print "$zone has\t$val NS $host\n";4354 4352 $val = NetAddr::IP->new($val); 4355 $zone = NetAddr::IP->new($zone);4356 #print "$val NS $host\n";4357 4353 # handle split-n-multiply SOA for off-octet (8 < mask < 16) or (16 < mask < 24) v4 zones 4358 4354 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))) { 4360 4356 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; 4364 4358 print $datafile "\&$szone2"."::$host:$ttl:$stamp:$loc\n"; 4365 $$recflags{ "$szone2-sub"}++ if $zone != $val;4359 $$recflags{$szone2} = $val->masklen; 4366 4360 } 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; 4369 4372 } 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 ##NSfixme4377 4373 } else { 4378 4374 print $datafile "\&$host"."::$val:$ttl:$stamp:$loc\n"; … … 4533 4529 # This is intended for reverse zones, but may prove useful in forward zones. 4534 4530 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 } 4567 4551 4568 4552 } else {
Note:
See TracChangeset
for help on using the changeset viewer.