aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoachim Tingvold <joachim@tingvold.com>2015-03-21 22:48:32 +0100
committerJoachim Tingvold <joachim@tingvold.com>2015-03-21 22:48:32 +0100
commit6669f020b17779cc6767a30ca2e7c51de766b9b8 (patch)
treef15349365fd6d905a49b64cbd6ab19bb27f8451b
parentfe80e0a56b3b67699a6117b010e6d5c81e8391ba (diff)
Spring cleaning for TG15.
Preparing for DHCP6. Cleanup of old files.
-rw-r--r--bootstrap/README.md8
-rwxr-xr-xbootstrap/make-base-requires.sh8
-rwxr-xr-xbootstrap/make-dhcpd-include.pl16
-rwxr-xr-xbootstrap/make-dhcpd.pl60
-rwxr-xr-xbootstrap/make-dhcpd6.pl140
-rwxr-xr-xbootstrap/make-first-zones.pl5
-rwxr-xr-xbootstrap/make-missing-conf.pl125
-rwxr-xr-xbootstrap/make-pxeboot.sh2
-rwxr-xr-xbootstrap/make-reverse4-files.pl93
-rwxr-xr-xinclude/config.pm.dist38
-rwxr-xr-x[-rw-r--r--]mbd/make-mbd-nets.pl4
-rwxr-xr-xtools/generate-rowdns.pl (renamed from tools/dlink-ng2dns.pl)0
12 files changed, 366 insertions, 133 deletions
diff --git a/bootstrap/README.md b/bootstrap/README.md
index 1363223..8ebb444 100644
--- a/bootstrap/README.md
+++ b/bootstrap/README.md
@@ -58,8 +58,8 @@ The rest of the information needed should be pulled from techwiki.g.o The
format of the file is: one net per line, lines starting with # are skipped,
format of each net-line is:
- # <network adress> <prefixlen> <network-name>
- 176.110.124.0 24 noc
+ # <v4 net> <v6 net> <network-name>
+ 151.216.129.0/26 2a02:ed02:129a::/64 noc
Run 'bootstrap/make-base-requires.sh'. This script will log in on the Primary and
@@ -77,7 +77,9 @@ scripts are run by bootstrap/make-base-requires.sh, you should not need to run t
* bootstrap/make-reverse4-files.pl
* Creates reverse-zones for IPv4
* bootstrap/make-dhcpd.pl
- * Sets up the base setup for DHCP
+ * Sets up the base setup for DHCP4
+ * bootstrap/make-dhcpd6.pl
+ * Sets up the base setup for DHCP6
3++: Update during the party using update-baseservice.sh from bootstrap
------------------------------------------------------------------
diff --git a/bootstrap/make-base-requires.sh b/bootstrap/make-base-requires.sh
index 2de7a2d..228c620 100755
--- a/bootstrap/make-base-requires.sh
+++ b/bootstrap/make-base-requires.sh
@@ -40,21 +40,25 @@ fi
ssh -l root ${PRIMARY} "mkdir -p ${BASE}/bind/conf-master/"
ssh -l root ${PRIMARY} "mkdir -p ${BASE}/bind/reverse/"
ssh -l root ${PRIMARY} "mkdir -p ${BASE}/bind/dynamic/"
-ssh -l root ${PRIMARY} "mkdir -p ${BASE}/dhcp/conf.d/"
+ssh -l root ${PRIMARY} "mkdir -p ${BASE}/dhcp/conf-v4/"
+ssh -l root ${PRIMARY} "mkdir -p ${BASE}/dhcp/conf-v6/"
ssh -l root ${PRIMARY} "~/tgmanage/bootstrap/make-dhcp6-init.sh"
ssh -l root ${PRIMARY} "~/tgmanage/bootstrap/make-named.pl master ${BASE}"
ssh -l root ${PRIMARY} "~/tgmanage/bootstrap/make-dhcpd.pl ${BASE}"
+ssh -l root ${PRIMARY} "~/tgmanage/bootstrap/make-dhcpd6.pl ${BASE}"
ssh -l root ${PRIMARY} "~/tgmanage/bootstrap/make-first-zones.pl ${BASE}"
ssh -l root ${PRIMARY} "~/tgmanage/bootstrap/make-reverse4-files.pl master ${BASE}"
-ssh -l root ${SECONDARY} "mkdir -p ${BASE}/dhcp/conf.d/"
ssh -l root ${SECONDARY} "mkdir -p ${BASE}/bind/conf-slave/"
ssh -l root ${SECONDARY} "mkdir -p ${BASE}/bind/slave/"
+ssh -l root ${SECONDARY} "mkdir -p ${BASE}/dhcp/conf-v4/"
+ssh -l root ${SECONDARY} "mkdir -p ${BASE}/dhcp/conf-v6/"
ssh -l root ${SECONDARY} "~/tgmanage/bootstrap/make-dhcp6-init.sh"
ssh -l root ${SECONDARY} "insserv -r isc-dhcp-server"
ssh -l root ${SECONDARY} "~/tgmanage/bootstrap/make-dhcpd.pl ${BASE}"
+ssh -l root ${SECONDARY} "~/tgmanage/bootstrap/make-dhcpd6.pl ${BASE}"
ssh -l root ${SECONDARY} "~/tgmanage/bootstrap/make-named.pl slave ${BASE}"
ssh -l root ${SECONDARY} "~/tgmanage/bootstrap/make-reverse4-files.pl slave ${BASE}"
diff --git a/bootstrap/make-dhcpd-include.pl b/bootstrap/make-dhcpd-include.pl
index ded5551..86673cb 100755
--- a/bootstrap/make-dhcpd-include.pl
+++ b/bootstrap/make-dhcpd-include.pl
@@ -5,9 +5,9 @@ $base = $ARGV[0] if $#ARGV > -1;
$base .= "/" if not $base =~ m/\/$/ and not $base eq "";
my $dhcpd_base = $base . "dhcp/";
-my $includeconfig = $dhcpd_base . "generated-include.conf";
+my $includeconfig = $dhcpd_base . "v4-generated-include.conf";
-my $glob = $dhcpd_base . "conf.d/*.conf";
+my $glob = $dhcpd_base . "conf-v4/*.conf";
my @configs = glob($glob);
open CONF, ">" . $includeconfig or die ( $! . " " . $includeconfig);
@@ -16,3 +16,15 @@ foreach my $config ( @configs )
print CONF "include \"" . $config . "\";\n";
}
close CONF;
+
+$includeconfig = $dhcpd_base . "v6-generated-include.conf";
+
+my $glob = $dhcpd_base . "conf-v6/*.conf";
+my @configs = glob($glob);
+
+open CONF, ">" . $includeconfig or die ( $! . " " . $includeconfig);
+foreach my $config ( @configs )
+{
+ print CONF "include \"" . $config . "\";\n";
+}
+close CONF; \ No newline at end of file
diff --git a/bootstrap/make-dhcpd.pl b/bootstrap/make-dhcpd.pl
index f1a398e..802c2ad 100755
--- a/bootstrap/make-dhcpd.pl
+++ b/bootstrap/make-dhcpd.pl
@@ -15,9 +15,10 @@ $base = $ARGV[0] if $#ARGV > -1;
$base .= "/" if not $base =~ m/\/$/ and not $base eq "";
my $dhcpd_base = $base . "dhcp/";
-my $dhcpd_conf = $dhcpd_base . "dhcpd.conf";
-my $dhcpd_pxeconf = $dhcpd_base . "pxe-boot.conf";
-my $dhcpd_wlc_conf= $dhcpd_base . "wlc-conf.conf";
+my $dhcpd_conf = $dhcpd_base . "dhcpd.conf";
+my $dhcpd_pxeconf = $dhcpd_base . "v4-pxe-boot.conf";
+my $dhcpd_wlc_conf = $dhcpd_base . "v4-wlc.conf";
+my $dhcpd_voip_conf = $dhcpd_base . "v4-voip.conf";
# primary
my $pri_range = Net::IP->new($nms::config::pri_net) or die ("pri_range fail");
@@ -29,7 +30,7 @@ my $sec_range = Net::IP->new($nms::config::sec_net) or die ("sec_range fail");
my $sec_mask = $sec_range->mask();
my $sec_net = $sec_range->ip();
-# Create PXE-boot configuration file for DHCP on master.
+# Create PXE-boot configuration file for DHCP
if ( not -f $dhcpd_conf )
{
print STDERR "Creating file " . $dhcpd_conf . "\n";
@@ -57,27 +58,37 @@ key DHCP_UPDATER {
subnet $pri_net netmask $pri_mask {}
subnet $sec_net netmask $sec_mask {}
-include "/etc/dhcp/revzones.conf";
-include "/etc/dhcp/generated-include.conf";
+include "/etc/dhcp/v4-revzones.conf";
+include "/etc/dhcp/v4-generated-include.conf";
include "$dhcpd_pxeconf";
include "$dhcpd_wlc_conf";
+include "$dhcpd_voip_conf";
EOF
close DHCPDFILE;
}
-# Create PXE-boot configuration file for DHCP on master.
+# Create PXE-boot configuration file for DHCP
if ( not -f $dhcpd_pxeconf )
{
print STDERR "Creating file " . $dhcpd_pxeconf . "\n";
open PXEFILE, ">" . $dhcpd_pxeconf or die ( $! . " " . $dhcpd_pxeconf);
- print PXEFILE "next-server " . $nms::config::pxe_server . ";\n";
- print PXEFILE "filename \"pxelinux.0\";\n";
+ print PXEFILE <<"EOF";
+option arch code 93 = unsigned integer 16;
- close PXEFILE;
+if option arch = 00:07 {
+ filename "bootx64.efi";
+} else {
+ filename "pxelinux.0";
}
+next-server $nms::config::pxe_server_v4;
+
+EOF
+
+ close PXEFILE;
+}
# Create WLC configuration file
if ( not -f $dhcpd_wlc_conf )
@@ -99,3 +110,32 @@ EOF
close WLCFILE;
}
+# Create VoIP config
+if ( not -f $dhcpd_voip_conf )
+{
+ print STDERR "Creating file " . $dhcpd_voip_conf . "\n";
+ open VOIPFILE, ">" . $dhcpd_voip_conf or die ( $! . " " . $dhcpd_voip_conf);
+
+ print VOIPFILE <<"EOF";
+option space CiscoVOIP;
+option CiscoVOIP.cm-tftp-server code 150 = array of ip-address;
+
+class "cisco-voip-lan" {
+ match if substring (option vendor-class-identifier, 0, 28) = "Cisco Systems, Inc. IP Phone";
+ vendor-option-space CiscoVOIP;
+ log( info, concat( "LOLOPHONE: " , option vendor-class-identifier ));
+ option CiscoVOIP.cm-tftp-server $nms::config::voip1;
+ next-server $nms::config::voip1;
+}
+
+class "cisco-voip-wlan" {
+ match if substring (option vendor-class-identifier, 0, 33) = "Cisco Systems Inc. Wireless Phone";
+ vendor-option-space CiscoVOIP;
+ log( info, concat( "BANANAPHONE: " , option vendor-class-identifier ));
+ option CiscoVOIP.cm-tftp-server $nms::config::voip1;
+ next-server $nms::config::voip1;
+}
+EOF
+ close VOIPFILE;
+}
+
diff --git a/bootstrap/make-dhcpd6.pl b/bootstrap/make-dhcpd6.pl
new file mode 100755
index 0000000..e27e0f4
--- /dev/null
+++ b/bootstrap/make-dhcpd6.pl
@@ -0,0 +1,140 @@
+#!/usr/bin/perl -I /root/tgmanage
+use strict;
+
+use Net::IP;
+
+BEGIN {
+ require "include/config.pm";
+ eval {
+ require "include/config.local.pm";
+ };
+}
+
+my $base = "/etc";
+$base = $ARGV[0] if $#ARGV > -1;
+$base .= "/" if not $base =~ m/\/$/ and not $base eq "";
+
+my $dhcpd_base = $base . "dhcp/";
+my $dhcpd_conf = $dhcpd_base . "dhcpd.conf";
+my $dhcpd_pxeconf = $dhcpd_base . "v6-pxe-boot.conf";
+my $dhcpd_wlc_conf = $dhcpd_base . "v6-wlc.conf";
+my $dhcpd_voip_conf = $dhcpd_base . "v6-voip.conf";
+
+# primary
+my $pri_range = Net::IP->new($nms::config::pri_net) or die ("pri_range fail");
+my $pri_mask = $pri_range->mask();
+my $pri_net = $pri_range->ip();
+
+# secondary
+my $sec_range = Net::IP->new($nms::config::sec_net) or die ("sec_range fail");
+my $sec_mask = $sec_range->mask();
+my $sec_net = $sec_range->ip();
+
+# Create PXE-boot configuration file for DHCP
+if ( not -f $dhcpd_conf )
+{
+ print STDERR "Creating file " . $dhcpd_conf . "\n";
+ open DHCPDFILE, ">" . $dhcpd_conf or die ( $! . " " . $dhcpd_conf);
+
+ print DHCPDFILE <<"EOF";
+# GENERATED BY make-dhcpd.pl
+#
+# Central concept: as little config in the main .conf,
+# include almost everything from separate files..
+#
+# log-facility local7;
+option domain-name "$nms::config::tgname.gathering.org";
+option domain-name-servers $nms::config::pri_v4, $nms::config::sec_v4;
+default-lease-time 3600;
+max-lease-time 7200;
+authoritative;
+
+ddns-update-style interim;
+key DHCP_UPDATER {
+ algorithm HMAC-MD5.SIG-ALG.REG.INT;
+ secret $nms::config::ddns_key;
+}
+
+subnet $pri_net netmask $pri_mask {}
+subnet $sec_net netmask $sec_mask {}
+
+include "/etc/dhcp/v6-generated-include.conf";
+include "$dhcpd_pxeconf";
+#include "$dhcpd_wlc_conf";
+#include "$dhcpd_voip_conf";
+
+EOF
+ close DHCPDFILE;
+}
+
+# Create PXE-boot configuration file for DHCP
+if ( not -f $dhcpd_pxeconf )
+{
+ print STDERR "Creating file " . $dhcpd_pxeconf . "\n";
+ open PXEFILE, ">" . $dhcpd_pxeconf or die ( $! . " " . $dhcpd_pxeconf);
+
+ print PXEFILE <<"EOF";
+option dhcp6.bootfile-url code 59 = string;
+option dhcp6.client-arch-type code 61 = array of unsigned integer 16;
+
+if option dhcp6.client-arch-type = 00:07 {
+ option dhcp6.bootfile-url "tftp://[$nms::config::pxe_server_v6]/bootx64.efi";
+} else {
+ # support a hypothetical BIOS system that can PXE boot over IPv6
+ option dhcp6.bootfile-url "tftp://[$nms::config::pxe_server_v6]/pxelinux.0";
+}
+
+EOF
+
+ close PXEFILE;
+}
+
+# Create WLC configuration file
+if ( not -f $dhcpd_wlc_conf )
+{
+ print STDERR "Creating file " . $dhcpd_wlc_conf . "\n";
+ open WLCFILE, ">" . $dhcpd_wlc_conf or die ( $! . " " . $dhcpd_wlc_conf);
+
+ print WLCFILE <<"EOF";
+option space AP;
+option AP.server-address code 241 = array of ip-address;
+set vendor-string = option vendor-class-identifier;
+
+class "cisco-aps" {
+ match if substring (option vendor-class-identifier, 0, 8) = "Access Point";
+ vendor-option-space AP;
+ option AP.server-address $nms::config::wlc1;
+}
+EOF
+ close WLCFILE;
+}
+
+# Create VoIP config
+if ( not -f $dhcpd_voip_conf )
+{
+ print STDERR "Creating file " . $dhcpd_voip_conf . "\n";
+ open VOIPFILE, ">" . $dhcpd_voip_conf or die ( $! . " " . $dhcpd_voip_conf);
+
+ print VOIPFILE <<"EOF";
+option space CiscoVOIP;
+option CiscoVOIP.cm-tftp-server code 150 = array of ip-address;
+
+class "cisco-voip-lan" {
+ match if substring (option vendor-class-identifier, 0, 28) = "Cisco Systems, Inc. IP Phone";
+ vendor-option-space CiscoVOIP;
+ log( info, concat( "LOLOPHONE: " , option vendor-class-identifier ));
+ option CiscoVOIP.cm-tftp-server $nms::config::voip1;
+ next-server $nms::config::voip1;
+}
+
+class "cisco-voip-wlan" {
+ match if substring (option vendor-class-identifier, 0, 33) = "Cisco Systems Inc. Wireless Phone";
+ vendor-option-space CiscoVOIP;
+ log( info, concat( "BANANAPHONE: " , option vendor-class-identifier ));
+ option CiscoVOIP.cm-tftp-server $nms::config::voip1;
+ next-server $nms::config::voip1;
+}
+EOF
+ close VOIPFILE;
+}
+
diff --git a/bootstrap/make-first-zones.pl b/bootstrap/make-first-zones.pl
index 7d6d9f4..065b2a5 100755
--- a/bootstrap/make-first-zones.pl
+++ b/bootstrap/make-first-zones.pl
@@ -1,6 +1,5 @@
#!/usr/bin/perl -I /root/tgmanage
use strict;
-
use Net::IP;
BEGIN {
@@ -99,8 +98,8 @@ if ( not -f $zonefile )
; on the bootstrapping/nms server!
EOF
- my $ip_pri = new Net::IP( $nms::config::pri_v6 ) or die ( "Error, new Net::IP for " . $nms::config::pri_v6 );
- my $ip_sec = new Net::IP( $nms::config::sec_v6 ) or die ( "Error, new Net::IP for " . $nms::config::sec_v6 );
+ 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;
diff --git a/bootstrap/make-missing-conf.pl b/bootstrap/make-missing-conf.pl
index 598964f..e45a473 100755
--- a/bootstrap/make-missing-conf.pl
+++ b/bootstrap/make-missing-conf.pl
@@ -1,5 +1,6 @@
#!/usr/bin/perl -I /root/tgmanage
use strict;
+use Net::IP;
BEGIN {
require "include/config.pm";
@@ -8,10 +9,6 @@ BEGIN {
};
}
-
-use Net::IP;
-use Net::IP qw(:PROC);
-
my $serial = strftime("%Y%m%d", localtime(time())) . "01";
unless ( (($#ARGV == 0 ) || ( $#ARGV == 1))
@@ -34,51 +31,88 @@ print STDERR "Base dir is " . $base . "\n";
my $bind_base = $base . "bind/";
my $dhcpd_base = $base . "dhcp/";
-my $dhcp_dynconf_dir = $dhcpd_base . "conf.d/";
my $bind_conf_master = $bind_base . "conf-master/";
my $bind_conf_slave = $bind_base . "conf-slave/";
-my $tgname = $nms::config::tgname;
-
-my $pri_hostname = $nms::config::pri_hostname;
-my $pri_v4 = $nms::config::pri_v4;
-my $pri_v6 = $nms::config::pri_v6;
-
-my $sec_hostname = $nms::config::sec_hostname;
-my $sec_v4 = $nms::config::sec_v4;
-my $sec_v6 = $nms::config::sec_v6;
-
-my $ddns_key = $nms::config::ddns_key;
-
-my $ddns_to = $nms::config::ddns_to;
-
-my $base_ipv4 = new Net::IP( $nms::config::base_ipv4net );
+my $base_ipv4 = Net::IP->new( $nms::config::base_ipv4net );
my ($cp_oct, $cs_oct, $ct_oct) = ($nms::config::base_ipv4net =~ m/^(\d+)\.(\d+)\.(\d+)\..*/);
-while ( <STDIN> )
-{
+while ( <STDIN> ){
next if ( $_ =~ m/^#/);
my $line = $_;
chomp $line;
- die ("Invalid format on input") if not $line =~ m/^(\d+)\.(\d+)\.(\d+)\.(\d+)\s+(\d+)\s+([\w|-]+)\s*.*/;
- my ( $p_oct, $s_oct, $t_oct, $f_oct, $size, $name ) = ( $1, $2, $3, $4, $5, $6 );
+ # <v4 net> <v6 net> <network-name>
+ # 151.216.129.0/26 2a02:ed02:129a::/64 noc
+ # we assume not smaller than /64 on v6
+ die ("Invalid format on input") if not $line =~ m/^((\d+\.){3}\d+\/\d+)\s+(([a-fA-F0-9]+\:){1,4}\:\/\d+)\s+([\w|-]+).*/;
+ my ( $v4_net, $v6_net, $name ) = ( $1, $3, $5 );
-
- my $dhconfig = $dhcp_dynconf_dir . $name . ".conf";
my $master_config = $bind_conf_master . $name . ".conf";
my $slave_config = $bind_conf_slave . $name . ".conf";
- my $zone_file = $bind_base . "dynamic/$name.$tgname.gathering.org.zone";
+ my $zone_file = $bind_base . "dynamic/$name.$nms::config::tgname.gathering.org.zone";
+
+ my $v4_range = Net::IP->new( $v4_net ) or die ("v4_net fail");
+ my $v6_range = Net::IP->new( $v6_net ) or die ("v6_net fail");
+
+ # DHCP4
+ my $dhcp_dynconf_dir = $dhcpd_base . "conf-v4/";
+ my $dhconfig = $dhcp_dynconf_dir . $name . ".conf";
+
+ if ( not -f $dhconfig )
+ {
+ print STDERR "Creating file " . $dhconfig . "\n";
+ my $numhosts = $range->size();
+ my $mask = $range->mask();
+ my $router = $net_base . "." . ($f_oct+1);
+ my $first = $net_base . "." . ( $f_oct + 5 );
+
+ my $last = $first;
+ if ( $size < 24 )
+ {
+ # Net::IP iteration is crazyslow. So, we stopped using iterations.
+ my $last_ip = $range->last_ip();
+ $last_ip =~ m/(\d+)\.(\d+)\.(\d+)\.(\d+)/;
+ $last = sprintf("%d.%d.%d.%d", $1, $2, $3, $4-2);
+ }
+ else { $last = $net_base . "." . ( $f_oct + $numhosts - 2 ); }
+
+ #print STDERR "Name : " . $name . "\n";
+ #print STDERR "Net : " . $net . "\n";
+ #print STDERR "Mask : " . $mask . "\n";
+ #print STDERR "Router : " . $router . "\n";
+ #print STDERR "Size : " . $size . "\n";
+ #print STDERR "Numhosts : " . $numhosts . "\n";
+ #print STDERR "First : " . $first . "\n";
+ #print STDERR "Last : " . $last . "\n";
+
+ open DFILE, ">" . $dhconfig or die ( $! . " " . $dhconfig);
+
+ print DFILE "zone $name.$nms::config::tgname.gathering.org {\n";
+ print DFILE " primary $nms::config::ddns_to;\n";
+ print DFILE " key DHCP_UPDATER;\n";
+ print DFILE "}\n\n";
+
+ print DFILE "subnet $net netmask $mask {\n";
+ print DFILE " authoritative;\n";
+ print DFILE " option routers $router;\n";
+ print DFILE " option domain-name \"$name.$nms::config::tgname.gathering.org\";\n";
+ print DFILE " ddns-domainname \"$name.$nms::config::tgname.gathering.org\";\n";
+ print DFILE " range $first $last;\n";
+ print DFILE " ignore client-updates;\n";
+ print DFILE "}\n\n";
+
+ close DFILE;
+ }
- my $net_base = $p_oct . "." . $s_oct . "." . $t_oct;
- my $net = $net_base . "." . $f_oct;
- my $range = new Net::IP( $net . "/" . $size ) or die ("oopxos");
+ # DHCP6
+ my $dhcp_dynconf_dir = $dhcpd_base . "conf-v6/";
+ my $dhconfig = $dhcp_dynconf_dir . $name . ".conf";
- # Create configuration files for DHCP on master/primary
- if ( ( not -f $dhconfig ) && ( $role eq "master" ) )
+ if ( not -f $dhconfig )
{
print STDERR "Creating file " . $dhconfig . "\n";
my $numhosts = $range->size();
- my $mask = $range->mask();
+ my $mask = $range->mask();
my $router = $net_base . "." . ($f_oct+1);
my $first = $net_base . "." . ( $f_oct + 5 );
@@ -103,16 +137,16 @@ while ( <STDIN> )
open DFILE, ">" . $dhconfig or die ( $! . " " . $dhconfig);
- print DFILE "zone $name.$tgname.gathering.org {\n";
- print DFILE " primary $ddns_to;\n";
+ print DFILE "zone $name.$nms::config::tgname.gathering.org {\n";
+ print DFILE " primary $nms::config::ddns_to;\n";
print DFILE " key DHCP_UPDATER;\n";
print DFILE "}\n\n";
print DFILE "subnet $net netmask $mask {\n";
print DFILE " authoritative;\n";
print DFILE " option routers $router;\n";
- print DFILE " option domain-name \"$name.$tgname.gathering.org\";\n";
- print DFILE " ddns-domainname \"$name.$tgname.gathering.org\";\n";
+ print DFILE " option domain-name \"$name.$nms::config::tgname.gathering.org\";\n";
+ print DFILE " ddns-domainname \"$name.$nms::config::tgname.gathering.org\";\n";
print DFILE " range $first $last;\n";
print DFILE " ignore client-updates;\n";
print DFILE "}\n\n";
@@ -128,21 +162,20 @@ while ( <STDIN> )
print ZFILE << "EOF";
; Base reverse zones are updated from dhcpd -- DO NOT TOUCH!
\$TTL 3600
-@ IN SOA $pri_hostname.$tgname.gathering.org. abuse.gathering.org. (
+@ IN SOA $nms::config::pri_hostname.$nms::config::tgname.gathering.org. abuse.gathering.org. (
$serial ; serial
3600 ; refresh
1800 ; retry
608400 ; expire
3600 ) ; minimum and default TTL
- IN NS $pri_hostname.$tgname.gathering.org.
- IN NS $sec_hostname.$tgname.gathering.org.
-\$ORIGIN $name.$tgname.gathering.org.
+ IN NS $nms::config::pri_hostname.$nms::config::tgname.gathering.org.
+ IN NS $nms::config::sec_hostname.$nms::config::tgname.gathering.org.
+\$ORIGIN $name.$nms::config::tgname.gathering.org.
EOF
close ZFILE;
}
-
-
+
# Create bind9 configuration files for zones.
my $bind_file = "";
$bind_file = $master_config if ( $role eq "master");
@@ -154,19 +187,19 @@ EOF
print STDERR "Creating file " . $bind_file . "\n";
open NFILE, ">" . $bind_file or die ( $! . " " . $bind_file);
- print NFILE "zone \"$name.$tgname.gathering.org\" {\n";
+ print NFILE "zone \"$name.$nms::config::tgname.gathering.org\" {\n";
if ( $role eq "master" ) {
print NFILE " type master;\n";
print NFILE " notify yes;\n";
print NFILE " allow-update { key DHCP_UPDATER; };\n";
- print NFILE " file \"dynamic/$name.$tgname.gathering.org.zone\";\n";
+ print NFILE " file \"dynamic/$name.$nms::config::tgname.gathering.org.zone\";\n";
}
else
{
print NFILE " type slave;\n";
print NFILE " notify no;\n";
print NFILE " masters { bootstrap; };\n";
- print NFILE " file \"slave/$name.$tgname.gathering.org.zone\";\n";
+ print NFILE " file \"slave/$name.$nms::config::tgname.gathering.org.zone\";\n";
}
print NFILE " allow-transfer { ns-xfr; };\n";
print NFILE "};\n";
diff --git a/bootstrap/make-pxeboot.sh b/bootstrap/make-pxeboot.sh
index f5e603f..9492ad4 100755
--- a/bootstrap/make-pxeboot.sh
+++ b/bootstrap/make-pxeboot.sh
@@ -13,7 +13,7 @@ apt-get -y install nfs-kernel-server
cat << END > /etc/default/tftpd-hpa
TFTP_USERNAME="tftp"
TFTP_DIRECTORY="/var/lib/tftpboot"
-TFTP_ADDRESS="0.0.0.0:69"
+TFTP_ADDRESS=":69"
TFTP_OPTIONS="--secure"
END
diff --git a/bootstrap/make-reverse4-files.pl b/bootstrap/make-reverse4-files.pl
index be4ad99..3d8d993 100755
--- a/bootstrap/make-reverse4-files.pl
+++ b/bootstrap/make-reverse4-files.pl
@@ -26,23 +26,14 @@ $base .= "/" if not $base =~ m/\/$/ and not $base eq "";
my $bind_base = $base . "bind/";
my $dhcpd_base = $base . "dhcp/";
-my $dhcp_revzones_file = $dhcpd_base . "revzones.conf";
+my $dhcp_revzones_file = $dhcpd_base . "v4-revzones.conf";
my $bind_pri_revzones_file = $bind_base . "named.reverse4.conf";
my $bind_sec_revzones_file = $bind_base . "named.slave-reverse4.conf";
-my $pri_v4 = $nms::config::pri_v4;
-my $pri_v6 = $nms::config::pri_v6;
-
-my $sec_v4 = $nms::config::sec_v4;
-my $sec_v6 = $nms::config::sec_v6;
-
my $base_ipv4 = Net::IP->new($nms::config::base_ipv4net) or die ("base_v4 fail");
my ($p_oct, $s_oct, $t_oct) = ($nms::config::base_ipv4net =~ m/^(\d+)\.(\d+)\.(\d+)\..*/);
-
-$pri_v4 =~ m/^(\d+)\.(\d+)\.(\d+)\.(\d+).*/;
-my ( $pp_oct, $ps_oct, $pt_oct, $pf_oct) = ( $1, $2, $3, $4 );
-$sec_v4 =~ m/^(\d+)\.(\d+)\.(\d+)\.(\d+).*/;
-my ( $sp_oct, $ss_oct, $st_oct, $sf_oct) = ( $1, $2, $3, $4 );
+my ($pp_oct, $ps_oct, $pt_oct, $pf_oct) = ($nms::config::pri_v4 =~ m/^(\d+)\.(\d+)\.(\d+)\.(\d+).*/);
+my ($sp_oct, $ss_oct, $st_oct, $sf_oct) = ($nms::config::sec_v4 =~ m/^(\d+)\.(\d+)\.(\d+)\.(\d+).*/);
if ( $role eq "master" )
{
@@ -58,34 +49,40 @@ else
die ("WTF, role is neither 'master' or 'slave'");
}
-while (1)
-{
-
+sub add_zone{
my $block = $p_oct . "." . $s_oct . "." . $t_oct . ".0/24";
- my $current = new Net::IP( $block ) or die ("new Net::IP failed for " . $block);
-
my $rev_zone = $t_oct . "." . $s_oct . "." . $p_oct . ".in-addr.arpa";
-
+
if ( $role eq "master" )
{
# Generating IPv4-related reverse-stuff for
# both bind9 and dhcp on master.
- print DFILE "zone " . $rev_zone . " { primary " . $nms::config::ddns_to . "; key DHCP_UPDATER; }\n";
+ print DFILE <<"EOF";
+zone "$rev_zone" {
+ primary $nms::config::ddns_to;
+ key DHCP_UPDATER;
+}
+EOF
+
+ print NFILE <<"EOF";
+// $block
+zone "$rev_zone" {
+ type master;
+ allow-update { key DHCP_UPDATER; };
+ notify yes;
+ allow-transfer { ns-xfr; ext-xfr; };
+ file "reverse/$rev_zone.zone";
+};
- print NFILE "zone \"". $rev_zone ."\" {\n";
- print NFILE " type master;\n";
- print NFILE " allow-update { key DHCP_UPDATER; };\n";
- print NFILE " notify yes;\n";
- print NFILE " allow-transfer { ns-xfr; ext-xfr; };\n";
- print NFILE " file \"reverse/". $rev_zone .".zone\";\n";
- print NFILE "};\n\n";
+EOF
my $zfilename = $bind_base . "reverse/" . $rev_zone . ".zone";
open ZFILE, ">", $zfilename;
- print ZFILE "; " . $zfilename . "\n";
print ZFILE <<"EOF";
+; $zfilename
+; $block
; Base reverse zones are updated from dhcpd -- DO NOT TOUCH!
\$TTL 3600
@ IN SOA $nms::config::pri_hostname.$nms::config::tgname.gathering.org. abuse.gathering.org. (
@@ -100,6 +97,8 @@ while (1)
\$ORIGIN $rev_zone.
EOF
+
+ # add reverse if DNS-servers belong to zone
if ( ($pt_oct == $t_oct) && ($ps_oct == $s_oct) )
{
print ZFILE $pf_oct . " IN PTR $nms::config::pri_hostname.$nms::config::tgname.gathering.org.\n";
@@ -111,24 +110,44 @@ EOF
}
else
{
- # AKA "if not master", as in "is slave".
- # A lot less work: update the named.slave-reverse4.conf file..
- print SFILE "zone \"". $rev_zone ."\" {\n";
- print SFILE " type slave;\n";
- print SFILE " notify no;\n";
- print SFILE " file \"slave/". $rev_zone .".cache\";\n";
- print SFILE " masters { bootstrap; };\n";
- print SFILE " allow-transfer { ns-xfr; ext-xfr; };\n";
- print SFILE "};\n\n";
+ # if not master, aka slave
+ print SFILE <<"EOF";
+// $block
+zone "$rev_zone" {
+ type slave;
+ notify no;
+ file "slave/$rev_zone.cache";
+ masters { master_ns; };
+ allow-transfer { ns-xfr; ext-xfr; };
+};
+
+EOF
}
+}
+# for each /24 in the primary v4-net
+while (1){
+ my $current = Net::IP->new($block) or die ("Net::IP failed for " . $block);
+
+ add_zone();
+
if ( $current->last_int() == $base_ipv4->last_int() )
{
- print STDERR "Reached last IP network. Finished\n";
+ print STDERR "Reached last IP network. Finished.\n";
last;
}
$t_oct++;
}
+
+# for each specially defined /24
+foreach my $special_net (@nms::config::extra_nets){
+ # a.b.c.d/24
+ $base_ipv4 = Net::IP->new($special_net) or die ("base_v4 fail");
+ ($p_oct, $s_oct, $t_oct) = ($special_net =~ m/^(\d+)\.(\d+)\.(\d+)\..*/);
+
+ add_zone();
+}
+
# Close all files, even those that have never been opened ;)
close DFILE;
close NFILE;
diff --git a/include/config.pm.dist b/include/config.pm.dist
index 6539c92..041a7da 100755
--- a/include/config.pm.dist
+++ b/include/config.pm.dist
@@ -57,36 +57,20 @@ our $ipv6zone = "2.0.d.e.2.0.a.2.ip6.arpa";
# that should have recursive DNS access
our $rec_net = "185.12.59.0/24";
+# extra networks that are outside the normal ranges
+# that should be added to DNS
+our @extra_nets = (
+ '185.12.59.0/24', # Norsk nett
+);
+
# add WLC's
our $wlc1 = "151.216.253.21";
-# Change from tg14: PXE-server is set to Secondary/SMTP/TFTP box,
-# and the toolchain assumes this fact. Variable kept for clarity:
-our $pxe_server = $sec_v4;
-
-# Used by ipv6-stats, but never got updated for tg11-ip's. Commenting.
-# The following is the list of routing netboxes (core, dist, tele, a.s.o)
-our @distrobox_ips = (
- '151.216.255.1', # telegw
- '151.216.255.2', # nocgw
- '151.216.255.3', # camgw
- '151.216.255.4', # stageboh
- '151.216.255.5', # wtfgw
- '151.216.255.6', # logistikkgw
- '151.216.255.7', # crewgw
- '151.216.255.8', # gamegw
- '151.216.255.9', # resepsjongw
- '151.216.255.10', # sponsorgw
- '151.216.255.11', # eldregw
- '151.216.255.17', # distro0
- '151.216.255.18', # distro1
- '151.216.255.19', # distro2
- '151.216.255.20', # distro3
- '151.216.255.21', # distro4
- '151.216.255.22', # slutgw
-);
+# add VOIP-server
+our $voip1 = "134.90.150.162";
-# Forwarding zones.
-our @forwarding_zones = qw( );
+# PXE-server (rest of bootstrap assumes $sec_v4/$sec_v6)
+our $pxe_server_v4 = $sec_v4;
+our $pxe_server_v6 = $sec_v6;
1;
diff --git a/mbd/make-mbd-nets.pl b/mbd/make-mbd-nets.pl
index 6af76f0..7f6ec97 100644..100755
--- a/mbd/make-mbd-nets.pl
+++ b/mbd/make-mbd-nets.pl
@@ -17,9 +17,9 @@ while(<NETLIST>) {
next if /^(.*#|\s+$)/; # skip if comment, or blank line
chomp;
- my ($network, $prefix, $switchname, undef) = split;
+ my ($v4_net, $v6_net, $net_name) = split;
- print "\t\"$network/$prefix\",\n";
+ print "\t\"$v4_net\",\n";
}
print ");\n";
diff --git a/tools/dlink-ng2dns.pl b/tools/generate-rowdns.pl
index 157d43b..157d43b 100755
--- a/tools/dlink-ng2dns.pl
+++ b/tools/generate-rowdns.pl