diff options
| author | Kristian Lyngstol <kly@kly@.no> | 2016-03-23 00:39:18 +0100 | 
|---|---|---|
| committer | Kristian Lyngstol <kly@kly@.no> | 2016-03-23 00:39:18 +0100 | 
| commit | 38d65bd3baa5d48ca7786d2b374a240576d762ee (patch) | |
| tree | 6e0ae53021cb8cbed0db6f5a64089c6f2778ffe2 /bootstrap | |
| parent | 7b5eee1f23bb66a6de8484c4ff5ad5b2021915ea (diff) | |
| parent | dcf06094021f4cb0cb74ae00cdb2629fccffff6e (diff) | |
Merge branch 'master' of github.com:tech-server/tgmanage
Diffstat (limited to 'bootstrap')
| -rwxr-xr-x | bootstrap/make-first-zones.pl | 43 | ||||
| -rwxr-xr-x | bootstrap/make-named.pl | 38 | 
2 files changed, 64 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..62ad584 100755 --- a/bootstrap/make-named.pl +++ b/bootstrap/make-named.pl @@ -1,5 +1,6 @@  #!/usr/bin/perl -I /root/tgmanage  use strict; +use NetAddr::IP;  BEGIN {          require "include/config.pm"; @@ -54,6 +55,7 @@ options {          recursion yes;          auth-nxdomain no;          listen-on-v6 { any; }; +	statistics-file "/etc/bind/named.rndc-stats";  };  logging { @@ -116,18 +118,33 @@ 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";  EOF +	  }  if ( $role eq "slave" ) @@ -150,14 +167,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"; | 
