From: Steinar H. Gunderson Date: Sun, 9 Apr 2006 19:08:37 +0000 (+0000) Subject: Insert extra magic for splitting nets by option 82. X-Git-Url: https://git.sesse.net/?p=nms;a=commitdiff_plain;h=d521bf6ef18e20681e44bf4afcac0fd1f6b46b98 Insert extra magic for splitting nets by option 82. --- diff --git a/config/make-dhcpd.pl b/config/make-dhcpd.pl index 2cac76e..e81d1d8 100755 --- a/config/make-dhcpd.pl +++ b/config/make-dhcpd.pl @@ -24,6 +24,22 @@ option domain-name-servers 194.0.254.2; # ddns-update-style none; ddns-update-style interim; +# extra logging for option 82 +if exists agent.circuit-id +{ + log ( + info, + concat ( + "option-82 info for ", binary-to-ascii (16, 8, ":", hardware), + ": interface ", binary-to-ascii (10, 8, "/", suffix ( option agent.circuit-id, 2)), + ", VLAN ", binary-to-ascii (10, 16, "", substring( option agent.circuit-id, 2, 2)), + ", switch '", substring( option agent.remote-id, 2, 6), + "', port-name '", substring ( option agent.circuit-id, 2, extract-int ( substring ( option agent.circuit-id, 3, 1 ), 8 ) ), + "'" + ) + ); +} + key DHCP_UPDATER { algorithm HMAC-MD5.SIG-ALG.REG.INT; secret removed; @@ -71,16 +87,58 @@ for my $net (@nets) { my $rangestart = "194.0.$majorsubnet." . ($minorsubnet + 10); my $rangeend = "194.0.$majorsubnet." . ($minorsubnet + $numpc - 2); - print <<"EOF"; + if ($domain =~ /^split:(.*)/) { + my @domains = split /,/, $1; + for my $d (@domains) { + print <<"EOF"; +zone $d.tg06.gathering.org. { + primary 127.0.0.1; + key DHCP_UPDATER; +} +EOF + } + print <<"EOF"; +subnet 194.0.$net netmask $netmask { + authoritative; + option routers $gw; + +EOF + my $numpc_sub = int($numpc / scalar(@domains)); + for my $d (@domains) { + print <<"EOF"; + class "$d" { + match if substring ( option agent.circuit-id, 2, extract-int ( substring ( option agent.circuit-id, 3, 1 ), 8 ) ) = "$d"; + } +EOF + } + + my $i = 0; + for my $d (@domains) { + my $rangestart = "194.0.$majorsubnet." . ($minorsubnet + $i * $numpc_sub + 10); + my $rangeend = "194.0.$majorsubnet." . ($minorsubnet + $i * $numpc_sub + $numpc_sub - 2); + + print <<"EOF"; + pool { + allow members of "$d"; + range $rangestart $rangeend; + option domain-name "$d.tg06.gathering.org"; + ddns-domainname "$.tg06.gathering.org"; + ignore client-updates; + } +EOF + ++$i; + } + } else { + print <<"EOF"; zone $domain.tg06.gathering.org. { primary 127.0.0.1; key DHCP_UPDATER; } subnet 194.0.$net netmask $netmask { authoritative; - range $rangestart $rangeend; option routers $gw; + range $rangestart $rangeend; option domain-name "$domain.tg06.gathering.org"; ddns-domainname "$domain.tg06.gathering.org"; ignore client-updates;