Add DDNS client update option to DHCPv4 configuraiton

This commit is contained in:
Steve Beaver 2018-02-02 12:57:16 -05:00
parent 12f1619688
commit 67784aa66f
2 changed files with 35 additions and 5 deletions

View File

@ -693,6 +693,14 @@ EOPP;
$newzone['domain-name'] = $config['system']['domain'];
}
if (empty($dhcpifconf['ddnsclientupdates'])) {
$ddnsclientupdates = 'allow';
} else {
$ddnsclientupdates = $dhcpifconf['ddnsclientupdates'];
}
$dnscfg .= " {$ddnsclientupdates} client-updates;\n";
$revsubnet = array_reverse(explode('.',$subnet));
/* Take care of full classes first */
@ -2209,18 +2217,18 @@ function services_unbound_configure($restart_dhcp = true) {
$wanif = get_real_interface("wan", "inet6");
if (platform_booting()) {
for ($i=1; $i <= 10; $i++) {
if (!file_exists("/tmp/{$wanif}_dhcp6_complete")) {
if (!file_exists("/tmp/{$wanif}_dhcp6_complete")) {
log_error(gettext("Unbound start waiting on dhcp6c."));
sleep(1);
} else {
unlink_if_exists("/tmp/{$wanif}_dhcp6_complete");
log_error(gettext("dhcp6 init complete. Continuing"));
break;
}
}
}
}
}
sync_unbound_service();
if (platform_booting()) {
log_error(gettext("sync unbound done."));

View File

@ -201,6 +201,7 @@ if (is_array($dhcpdconf)) {
$pconfig['netmask'] = $dhcpdconf['netmask'];
$pconfig['numberoptions'] = $dhcpdconf['numberoptions'];
$pconfig['statsgraph'] = $dhcpdconf['statsgraph'];
$pconfig['ddnsclientupdates'] = $dhcpdconf['ddnsclientupdates'];
}
$ifcfgip = $config['interfaces'][$if]['ipaddr'];
@ -585,6 +586,7 @@ if (isset($_POST['save'])) {
$dhcpdconf['ddnsforcehostname'] = ($_POST['ddnsforcehostname']) ? true : false;
$dhcpdconf['mac_allow'] = $_POST['mac_allow'];
$dhcpdconf['mac_deny'] = $_POST['mac_deny'];
$dhcpdconf['ddnsclientupdates'] = $_POST['ddnsclientupdates'];
unset($dhcpdconf['ntpserver']);
if ($_POST['ntp1']) {
@ -1145,6 +1147,19 @@ $section->addInput(new Form_Input(
$pconfig['ddnsdomainkey']
))->setHelp('Dynamic DNS domain key secret which will be used to register client names in the DNS server.');
$section->addInput(new Form_Select(
'ddnsclientupdates',
'DDNS Client Updates',
$pconfig['ddnsclientupdates'],
array(
'allow' => gettext('Allow'),
'deny' => gettext('Deny'),
'ignore' => gettext('Ignore'))
))->setHelp('How Forward entries are handled when client indicates they wish to update DNS. ' .
'Allow prevents DHCP from updating Forward entries, Deny indicates that DHCP will ' .
'do the updates and the client should not, Ignore specifies that DHCP will do the ' .
'update and the client can also attempt the update usually using a different domain name.');
// Advanced MAC
$btnadv = new Form_Button(
'btnadvmac',
@ -1535,8 +1550,14 @@ events.push(function() {
// On page load decide the initial state based on the data.
if (ispageload) {
<?php
if (!$pconfig['ddnsupdate'] && !$pconfig['ddnsforcehostname'] && empty($pconfig['ddnsdomain']) && empty($pconfig['ddnsdomainprimary']) &&
empty($pconfig['ddnsdomainkeyname']) && empty($pconfig['ddnsdomainkeyalgorithm']) && empty($pconfig['ddnsdomainkey'])) {
if (!$pconfig['ddnsupdate'] &&
!$pconfig['ddnsforcehostname'] &&
empty($pconfig['ddnsdomain']) &&
empty($pconfig['ddnsdomainprimary']) &&
empty($pconfig['ddnsdomainkeyname']) &&
empty($pconfig['ddnsdomainkeyalgorithm']) &&
(empty($pconfig['ddnsclientupdates']) || ($pconfig['ddnsclientupdates'] == "allow")) &&
empty($pconfig['ddnsdomainkey'])) {
$showadv = false;
} else {
$showadv = true;
@ -1555,6 +1576,7 @@ events.push(function() {
hideInput('ddnsdomainkeyname', !showadvdns);
hideInput('ddnsdomainkeyalgorithm', !showadvdns);
hideInput('ddnsdomainkey', !showadvdns);
hideInput('ddnsclientupdates', !showadvdns);
if (showadvdns) {
text = "<?=gettext('Hide Advanced');?>";