Finished functions for working out reverse zones and record names for IPv6 addresses.

This commit is contained in:
Maff 2014-02-08 00:10:22 +00:00
parent 93d352a6b4
commit 48dfd3c988
1 changed files with 2 additions and 6 deletions

View File

@ -45,9 +45,8 @@ sub get_arpa {
$ip =~ m/^([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)$/;
return ($4, "$3.$2.$1.in-addr.arpa");
}
#IP is v6, use Net::IP->new->reverse_ip assuming subnet prefix /64 unless specified
my $len = ($prefixlen-1);
Net::IP->new($ip)->reverse_ip =~ /^(.*){\Q$len}\.(.*)$/;
my $len = ($prefixlen/2);
Net::IP->new($ip)->reverse_ip =~ /^(.*)\.(.{$len}ip6\.arpa)\.$/;
return ($1,$2);
}
sub nicedie {
@ -70,6 +69,3 @@ GetOptions(
my $ip = shift or nicedie "No IP given!";
my $domain = shift or nicedie "No FQDN given!" unless $fsync || $reset || $delptr;
$prefixlen = $1 if $ip =~ s/\/([0-9]+)//;
my ($rec,$zone) = get_arpa $ip;
print "IP = $ip, optional prefixlen $prefixlen. arpa zone = $zone, record = $rec\n";