]> git.sesse.net Git - nms/commitdiff
Insert extra magic for splitting nets by option 82.
authorSteinar H. Gunderson <sesse@samfundet.no>
Sun, 9 Apr 2006 19:08:37 +0000 (19:08 +0000)
committerSteinar H. Gunderson <sesse@samfundet.no>
Sun, 9 Apr 2006 19:08:37 +0000 (19:08 +0000)
config/make-dhcpd.pl

index 2cac76e19d930221d05f6851c2471b0a00d968ea..e81d1d808ee8820ed32ef563e089d671c942e040 100755 (executable)
@@ -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;