aboutsummaryrefslogtreecommitdiffstats
path: root/bootstrap/make-first-zones.pl
diff options
context:
space:
mode:
authorKristian Lyngstol <kly@kly@.no>2016-03-23 00:39:18 +0100
committerKristian Lyngstol <kly@kly@.no>2016-03-23 00:39:18 +0100
commit38d65bd3baa5d48ca7786d2b374a240576d762ee (patch)
tree6e0ae53021cb8cbed0db6f5a64089c6f2778ffe2 /bootstrap/make-first-zones.pl
parent7b5eee1f23bb66a6de8484c4ff5ad5b2021915ea (diff)
parentdcf06094021f4cb0cb74ae00cdb2629fccffff6e (diff)
Merge branch 'master' of github.com:tech-server/tgmanage
Diffstat (limited to 'bootstrap/make-first-zones.pl')
-rwxr-xr-xbootstrap/make-first-zones.pl43
1 files changed, 30 insertions, 13 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"; }