diff options
author | Joachim Tingvold <joachim@tingvold.com> | 2017-04-07 21:58:24 +0200 |
---|---|---|
committer | Joachim Tingvold <joachim@tingvold.com> | 2017-04-07 21:58:24 +0200 |
commit | ed6c253dfd6c76afeaf71a871d6c8915acb102f6 (patch) | |
tree | a59aa788266ab49a731cc6e853e6093690debf2b | |
parent | 80e7346876c24dc68ff10fd3ec77b62165ed501a (diff) |
Make DHCP-networks for distro-mgmt-networks.
-rwxr-xr-x | bootstrap/make-dhcpd.pl | 85 | ||||
-rwxr-xr-x | include/config.pm.dist | 18 |
2 files changed, 69 insertions, 34 deletions
diff --git a/bootstrap/make-dhcpd.pl b/bootstrap/make-dhcpd.pl index 7bd1a5c..ad39704 100755 --- a/bootstrap/make-dhcpd.pl +++ b/bootstrap/make-dhcpd.pl @@ -4,10 +4,10 @@ use Net::IP; use NetAddr::IP; BEGIN { - require "include/config.pm"; - eval { - require "include/config.local.pm"; - }; + require "include/config.pm"; + eval { + require "include/config.local.pm"; + }; } my $base = "/etc"; @@ -39,10 +39,10 @@ my $sec_n = $sec_num - int($sec_num / 4); # don't use more than 1/4 of the net f # Create main 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 STDERR "Creating file " . $dhcpd_conf . "\n"; + open DHCPDFILE, ">" . $dhcpd_conf or die ( $! . " " . $dhcpd_conf); - print DHCPDFILE <<"EOF"; + print DHCPDFILE <<"EOF"; # GENERATED BY make-dhcpd.pl # 60 min leasetime, 120 min max @@ -105,16 +105,16 @@ include "$dhcpd_voip_conf"; include "$dhcpd_fap_conf"; EOF - close DHCPDFILE; + 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 STDERR "Creating file " . $dhcpd_pxeconf . "\n"; + open PXEFILE, ">" . $dhcpd_pxeconf or die ( $! . " " . $dhcpd_pxeconf); - print PXEFILE <<"EOF"; + print PXEFILE <<"EOF"; option arch code 93 = unsigned integer 16; if option arch = 00:07 { @@ -127,16 +127,16 @@ next-server $nms::config::pxe_server_v4; EOF - close PXEFILE; + 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 STDERR "Creating file " . $dhcpd_wlc_conf . "\n"; + open WLCFILE, ">" . $dhcpd_wlc_conf or die ( $! . " " . $dhcpd_wlc_conf); - print WLCFILE <<"EOF"; + print WLCFILE <<"EOF"; option space WLC; option WLC.controller-address code 43 = text; set vendor-string = option vendor-class-identifier; @@ -149,16 +149,16 @@ class "access-points" { option WLC.controller-address "$nms::config::wlc1_v4"; } EOF - close WLCFILE; + 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 STDERR "Creating file " . $dhcpd_voip_conf . "\n"; + open VOIPFILE, ">" . $dhcpd_voip_conf or die ( $! . " " . $dhcpd_voip_conf); - print VOIPFILE <<"EOF"; + print VOIPFILE <<"EOF"; option space CiscoVOIP; option CiscoVOIP.cm-tftp-server code 150 = array of ip-address; @@ -178,16 +178,18 @@ class "cisco-voip-wlan" { next-server $nms::config::voip1_v4; } EOF - close VOIPFILE; + close VOIPFILE; } # Create FAP/Gondul config if ( not -f $dhcpd_fap_conf ) { - print STDERR "Creating file " . $dhcpd_fap_conf . "\n"; - open FAPFILE, ">" . $dhcpd_fap_conf or die ( $! . " " . $dhcpd_fap_conf); + print STDERR "Creating file " . $dhcpd_fap_conf . "\n"; + open FAPFILE, ">" . $dhcpd_fap_conf or die ( $! . " " . $dhcpd_fap_conf); + + print FAPFILE <<"EOF"; +# FAP DHCP-configuration - print FAPFILE <<"EOF"; # Define structure of option 43 ( Zero Touch Protocol options) option space ztp; #option ztp.image-file-name code 0 = text; @@ -203,21 +205,20 @@ option option-150 code 150 = { ip-address }; # define option 60 - used for classifying ZTP clients ("vendor class identifier") option vendor-class-identifier code 60 = text; -# set short leasetime, so that it times out at reboot -default-lease-time 120; -max-lease-time 120; - -# define ranges group { # No DDNS ddns-updates off; ddns-hostname = none; ddns-domainname = none; - + # supershort leasetime default-lease-time 120; max-lease-time 120; + # set short leasetime, so that it times out at reboot + default-lease-time 120; + max-lease-time 120; + # ZTP Settings option option-150 $nms::config::fap_server_v4; option tftp-server-name "$nms::config::fap_server_v4"; @@ -225,12 +226,32 @@ group { option ztp.config-file-name = concat("api/config/", (option agent.circuit-id)); #option ztp.image-file-name "files/jinstall-ex-2200-14.1X53-D15.2-domestic-signed.tgz"; - -} + ### define ranges EOF - close FAPFILE; + + foreach my $fap_net (@nms::config::fap_networks){ + my $fap_subnet = Net::IP->new($fap_net)->ip(); + my $fap_mask = Net::IP->new($fap_net)->mask(); + (my $fap_last = NetAddr::IP->new($fap_net)->last()) =~ s/\/[0-9]{1,2}//; + (my $fap_gw = NetAddr::IP->new($fap_net)->first()) =~ s/\/[0-9]{1,2}//; + my $fap_num = NetAddr::IP->new($fap_net)->num(); + my $fap_n = $fap_num - int($fap_num / 2); # don't use more than 1/2 of the net for DHCP + (my $fap_first = NetAddr::IP->new($fap_net)->nth($fap_n)) =~ s/\/[0-9]{1,2}//; + + print FAPFILE <<"EOF"; + subnet $fap_subnet netmask $fap_mask { + range $fap_first $fap_last; + option subnet-mask $fap_mask; + option routers $fap_gw; + } +EOF + + } + + print FAPFILE "}\n"; + close FAPFILE; } diff --git a/include/config.pm.dist b/include/config.pm.dist index f10757c..9094331 100755 --- a/include/config.pm.dist +++ b/include/config.pm.dist @@ -68,10 +68,10 @@ our $sec_net_v6 = "2a06:5841:1337::/64"; # for RIPE to get reverse zones via DNS AXFR # https://www.ripe.net/data-tools/dns/reverse-dns/how-to-set-up-reverse-delegation -our $ext_xfer = "193.0.0.0/22; 2001:610:240::/48; 2001:67c:2e8::/48"; +our $ext_xfer = "193.0.0.0/22; 2001:610:240::/48; 2001:67c:2e8::/48"; # allow XFR from NOC -our $noc_net = "185.110.150.0/25; 2a06:5841:150a::1/64"; +our $noc_net = "185.110.150.0/25; 2a06:5841:150a::1/64"; # To generate new dnssec-key for ddns: # dnssec-keygen -a HMAC-MD5 -b 512 -n HOST DHCP_UPDATER @@ -113,5 +113,19 @@ our $pxe_server_v6 = $sec_v6; # FAP-server (Gondul) our $fap_server_v4 = "<removed>"; # TODO: Remove before publishing "goodiebag" our $fap_server_v6 = "<removed>"; # TODO: Remove before publishing "goodiebag" +our @fap_networks = ( + '88.92.54.0/26', # distro0 + '88.92.54.64/26', # distro1 + '88.92.54.128/26', # distro2 + '88.92.54.192/26', # distro3 + '88.92.55.0/26', # distro4 + '88.92.55.64/26', # distro5 + '88.92.55.128/26', # distro6 + '88.92.55.192/26', # distro7 + '88.92.56.0/26', # distro8 + '88.92.56.64/26', # vc1.ring +); + + 1; |