DHCP: Allow using external name servers for leases

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.
This commit is contained in:
Michael Tremer
2015-03-15 13:34:02 +01:00
parent 3d53eb68af
commit f5fb9a0466

View 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 {