diff options
author | Joachim Tingvold <joachim@tingvold.com> | 2016-03-22 23:18:02 +0100 |
---|---|---|
committer | Joachim Tingvold <joachim@tingvold.com> | 2016-03-22 23:18:02 +0100 |
commit | 219f42f4d80b6432bc1f9ad76236304e448b70eb (patch) | |
tree | 09f44468403b1f1dc631c240c3b6c9314235ae01 | |
parent | 068baf7c5de1c4bf3a9b12a5eb8c88057178b19d (diff) |
Fixed IPv6 PTR; split up into /32's.
-rwxr-xr-x | bootstrap/make-first-zones.pl | 43 | ||||
-rwxr-xr-x | bootstrap/make-named.pl | 33 |
2 files changed, 59 insertions, 17 deletions
diff --git a/bootstrap/make-first-zones.pl b/bootstrap/make-first-zones.pl index 0f2754c..63cf1d0 100755 --- a/bootstrap/make-first-zones.pl +++ b/bootstrap/make-first-zones.pl @@ -1,6 +1,7 @@ #!/usr/bin/perl -I /root/tgmanage use strict; use Net::IP; +use NetAddr::IP; use POSIX qw(strftime); BEGIN { @@ -76,13 +77,18 @@ EOF } else { print "Skipped infra-zone, file exists.\n"; } -$zonefile = $base . "bind/" . $nms::config::ipv6zone . ".zone"; -if ( not -f $zonefile ) -{ - print $zonefile . "\n"; - open IPV6ZONE, ">" . $zonefile or die $! . " " . $zonefile; +# IPv6 PTR +foreach my $ipv6_net (NetAddr::IP->new($nms::config::base_ipv6net)->split(32)){ + my $ipv6 = Net::IP->new($ipv6_net); + (my $ipv6zone = $ipv6->reverse_ip()) =~ s/\.$//; - print IPV6ZONE <<"EOF"; + $zonefile = $base . "bind/" . $ipv6zone . ".zone"; + if ( not -f $zonefile ) + { + print $zonefile . "\n"; + open IPV6ZONE, ">" . $zonefile or die $! . " " . $zonefile; + + print IPV6ZONE <<"EOF"; ; autogenerated, and updated from dhcpd -- DO NOT TOUCH! \$TTL 3600 @ IN SOA $nms::config::pri_hostname.$nms::config::tgname.gathering.org. abuse.gathering.org. ( @@ -97,12 +103,23 @@ if ( not -f $zonefile ) ; WARNING! Do not edit this file directly! ; on the bootstrapping/nms server! - EOF - my $ip_pri = Net::IP->new( $nms::config::pri_v6 ) or die ( "Error, new Net::IP for " . $nms::config::pri_v6 ); - my $ip_sec = Net::IP->new( $nms::config::sec_v6 ) or die ( "Error, new Net::IP for " . $nms::config::sec_v6 ); - print IPV6ZONE $ip_pri->reverse_ip() . " IN PTR $nms::config::pri_hostname.$nms::config::tgname.gathering.org.\n"; - print IPV6ZONE $ip_sec->reverse_ip() . " IN PTR $nms::config::sec_hostname.$nms::config::tgname.gathering.org.\n"; - close IPV6ZONE; + + # print NS reverse + my $ipv6addr = NetAddr::IP->new($ipv6_net); + my $ip_pri_1 = NetAddr::IP->new($nms::config::pri_v6); + if($ipv6addr->contains($ip_pri_1)){ + my $ip_pri = Net::IP->new( $nms::config::pri_v6 ) or die ( "Error, new Net::IP for " . $nms::config::pri_v6 ); + print IPV6ZONE $ip_pri->reverse_ip() . " IN PTR $nms::config::pri_hostname.$nms::config::tgname.gathering.org.\n"; + } + + my $ip_sec_1 = NetAddr::IP->new($nms::config::sec_v6); + if($ipv6addr->contains($ip_sec_1)){ + my $ip_sec = Net::IP->new( $nms::config::sec_v6 ) or die ( "Error, new Net::IP for " . $nms::config::sec_v6 ); + print IPV6ZONE $ip_sec->reverse_ip() . " IN PTR $nms::config::sec_hostname.$nms::config::tgname.gathering.org.\n"; + } + + close IPV6ZONE; + } + else { print "Skipped v6-reverse-zone, file exists.\n"; } } -else { print "Skipped v6-reverse-zone, file exists.\n"; } diff --git a/bootstrap/make-named.pl b/bootstrap/make-named.pl index 2681506..a59198f 100755 --- a/bootstrap/make-named.pl +++ b/bootstrap/make-named.pl @@ -116,14 +116,26 @@ zone "infra.$nms::config::tgname.gathering.org" { allow-transfer { ns-xfr; }; }; -zone "$nms::config::ipv6zone" { +EOF + +# IPv6 PTR +foreach my $ipv6_net (NetAddr::IP->new($nms::config::base_ipv6net)->split(32)){ + my $ipv6 = Net::IP->new($ipv6_net); + (my $ipv6zone = $ipv6->reverse_ip()) =~ s/\.$//; + + print NFILE <<EOF; +zone "$ipv6zone" { type master; allow-update { key DHCP_UPDATER; }; notify yes; - file "$nms::config::ipv6zone.zone"; + file "$ipv6zone.zone"; allow-transfer { ns-xfr; ext-xfr; }; }; +EOF + + print NFILE <<EOF; + include "/etc/bind/named.conf.default-zones"; include "named.reverse4.conf"; include "named.master-include.conf"; @@ -150,14 +162,27 @@ zone "infra.$nms::config::tgname.gathering.org" { masters { master_ns; }; }; -zone "$nms::config::ipv6zone" { +EOF + + # IPv6 PTR + foreach my $ipv6_net (NetAddr::IP->new($nms::config::base_ipv6net)->split(32)){ + my $ipv6 = Net::IP->new($ipv6_net); + (my $ipv6zone = $ipv6->reverse_ip()) =~ s/\.$//; + + print NFILE <<EOF; +zone "$ipv6zone" { type slave; notify no; masters { master_ns; }; - file "slave/$nms::config::ipv6zone:"; + file "slave/$ipv6zone"; allow-transfer { ns-xfr; ext-xfr; }; }; +EOF + } + + print NFILE <<EOF; + include "named.conf.default-zones"; include "named.slave-reverse4.conf"; include "named.slave-include.conf"; |