aboutsummaryrefslogtreecommitdiffstats
path: root/bootstrap/make-first-zones.pl
diff options
context:
space:
mode:
authorKristian Lyngstol <kristian@bohemians.org>2016-03-27 08:27:17 +0200
committerKristian Lyngstol <kristian@bohemians.org>2016-03-27 08:27:17 +0200
commit1d2470a411e5eaac7e5a1c5d5b6b81e92c92f4a8 (patch)
tree54b901757b088d54d33e70f28a6203383b4dc844 /bootstrap/make-first-zones.pl
parent0a230ac5481b9518abc64181dbbb4509d83c0b89 (diff)
parent96a9bb4c42f4b53020302fea2a46e734c61c0319 (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"; }