]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/commitdiff
DHCP: Allow using external name servers for leases
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 15 Mar 2015 12:34:02 +0000 (13:34 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 15 Mar 2015 12:34:02 +0000 (13:34 +0100)
These changes allow a user to use RFC2136 in order to
update their (public) DNS zone with the dynamic or
static leases.

A TSIG key may optionally be used to authenticate
the updates.

html/cgi-bin/dhcp.cgi

index 9a7d983eefd0233693a9e647a4c692ef2ef05442..e9442ebfd615219d3cd251d81bc6b14024abb671 100644 (file)
@@ -70,11 +70,17 @@ foreach my $itf (@ITFs) {
     $dhcpsettings{"NTP2_${itf}"} = '';
     $dhcpsettings{"NEXT_${itf}"} = '';
     $dhcpsettings{"FILE_${itf}"} = '';
+    $dhcpsettings{"DNS_UPDATE_KEY_NAME_${itf}"} = '';
+    $dhcpsettings{"DNS_UPDATE_KEY_SECRET_${itf}"} = '';
+    $dhcpsettings{"DNS_UPDATE_KEY_ALGO_${itf}"} = '';
 }
 
 $dhcpsettings{'SORT_FLEASELIST'} = 'FIPADDR';
 $dhcpsettings{'SORT_LEASELIST'} = 'IPADDR';
 
+# DNS Update settings
+$dhcpsettings{'DNS_UPDATE_ENABLED'} = 'off';
+
 #Settings2 for editing the multi-line list
 #Must not be saved with writehash !
 $dhcpsettings{'FIX_MAC'} = '';
@@ -1102,9 +1108,18 @@ sub buildconf {
     flock(FILE, 2);
 
     # Global settings
-    print FILE "ddns-update-style none;\n";
     print FILE "deny bootp;    #default\n";
     print FILE "authoritative;\n";
+
+    # DNS Update settings
+    if ($dhcpsettings{'DNS_UPDATE_ENABLED'} eq 'on') {
+        print FILE "ddns-updates           on;\n";
+        print FILE "ddns-update-style      interim;\n";
+        print FILE "ignore                 client-updates;\n";
+        print FILE "update-static-leases   on;\n";
+    } else {
+        print FILE "ddns-update-style none;\n";
+    }
     
     # Write first new option definition
     foreach my $line (@current1) {
@@ -1177,6 +1192,17 @@ sub buildconf {
            }# foreach line
            print FILE "} #$itf\n";
 
+           if (($dhcpsettings{"DNS_UPDATE_ENABLED"} eq "on") && ($dhcpsettings{"DNS_UPDATE_KEY_NAME_${itf}"} ne "")) {
+               print FILE "key " . $dhcpsettings{"DNS_UPDATE_KEY_NAME_${itf}"} . "{\n";
+               print FILE "\talgorithm " . $dhcpsettings{"DNS_UPDATE_KEY_ALGO_${itf}"} . ";\n";
+               print FILE "\tsecret \"" . $dhcpsettings{"DNS_UPDATE_KEY_SECRET_${itf}"} . "\";\n";
+               print FILE "};\n\n";
+
+               print FILE "zone " . $dhcpsettings{"DOMAIN_NAME_${itf}"} . ". {\n";
+               print FILE "\tkey " . $dhcpsettings{"DNS_UPDATE_KEY_NAME_${itf}"} . ";\n";
+               print FILE "}\n\n";
+           }
+
            system ('/usr/bin/touch', "${General::swroot}/dhcp/enable_${lc_itf}");
            &General::log("DHCP on ${itf}: " . $Lang::tr{'dhcp server enabled'})
        } else {