unbound: register dhcp domain override for #1250

This commit is contained in:
Franco Fichtner 2016-11-23 18:15:50 +01:00
parent 2ca7253326
commit 33c41b1613
2 changed files with 29 additions and 7 deletions

View File

@ -452,10 +452,13 @@ function unbound_execute($cmd)
switch ($cmd) {
case 'start':
$local_domain = !empty($config['system']['domain']) ? $config['system']['domain'] : "local";
$domain = $config['system']['domain'];
if (isset($config['unbound']['regdhcpdomain'])) {
$domain = $config['unbound']['regdhcpdomain'];
}
killbypid('/var/run/unbound_dhcpd.pid', 'TERM', true);
if (isset($config['unbound']['regdhcp'])) {
mwexecf('/usr/local/opnsense/scripts/dns/unbound_dhcpd.py /domain %s', $local_domain);
mwexecf('/usr/local/opnsense/scripts/dns/unbound_dhcpd.py /domain %s', $domain);
}
mwexecf('/usr/local/sbin/unbound -c %s', "{$g['unbound_chroot_path']}/unbound.conf");
break;

View File

@ -49,6 +49,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
// text values
$pconfig['port'] = !empty($a_unboundcfg['port']) ? $a_unboundcfg['port'] : null;
$pconfig['custom_options'] = !empty($a_unboundcfg['custom_options']) ? $a_unboundcfg['custom_options'] : null;
$pconfig['regdhcpdomain'] = !empty($a_unboundcfg['regdhcpdomain']) ? $a_unboundcfg['regdhcpdomain'] : null;
// array types
$pconfig['active_interface'] = !empty($a_unboundcfg['active_interface']) ? explode(",", $a_unboundcfg['active_interface']) : array();
$pconfig['outgoing_interface'] = !empty($a_unboundcfg['outgoing_interface']) ? explode(",", $a_unboundcfg['outgoing_interface']) : array();
@ -69,6 +70,9 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
if (isset($pconfig['enable']) && isset($config['dnsmasq']['enable']) && (empty($pconfig['port']) || $pconfig['port'] == '53')) {
$input_errors[] = gettext("The DNS Forwarder is still active. Disable it before enabling the DNS Resolver.");
}
if (!empty($pconfig['regdhcpdomain']) && !is_domain($pconfig['regdhcpdomain'])) {
$input_errors[] = gettext("The domain may only contain the characters a-z, 0-9, '-' and '.'.");
}
if (empty($pconfig['active_interface'])) {
$input_errors[] = gettext("A single network interface needs to be selected for the DNS Resolver to bind to.");
}
@ -87,6 +91,11 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
} elseif (isset($a_unboundcfg['port'])) {
unset($a_unboundcfg['port']);
}
if (!empty($pconfig['regdhcpdomain'])) {
$a_unboundcfg['regdhcpdomain'] = $pconfig['regdhcpdomain'];
} elseif (isset($a_unboundcfg['regdhcpdomain'])) {
unset($a_unboundcfg['regdhcpdomain']);
}
$a_unboundcfg['custom_options'] = !empty($pconfig['custom_options']) ? str_replace("\r\n", "\n", $pconfig['custom_options']) : null;
// boolean values
$a_unboundcfg['enable'] = !empty($pconfig['enable']);
@ -205,11 +214,21 @@ include_once("head.inc");
<input name="regdhcp" type="checkbox" id="regdhcp" value="yes" <?=!empty($pconfig['regdhcp']) ? "checked=\"checked\"" : "";?> />
<strong><?=gettext("Register DHCP leases in the DNS Resolver");?></strong>
<div class="hidden" for="help_for_regdhcp">
<?= sprintf(gettext("If this option is set, then machines that specify".
" their hostname when requesting a DHCP lease will be registered".
" in the DNS Resolver, so that their name can be resolved.".
" You should also set the domain in %sSystem:".
" General setup%s to the proper value."),'<a href="system_general.php">','</a>')?>
<?= gettext("If this option is set, then machines that specify " .
"their hostname when requesting a DHCP lease will be registered " .
"in the DNS Resolver, so that their name can be resolved."); ?>
</div>
</td>
</tr>
<tr>
<td><a id="help_for_regdhcpdomain" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("DHCP Domain Override");?></td>
<td>
<input name="regdhcpdomain" type="text" id="regdhcpdomain" value="<?= $pconfig['regdhcpdomain'] ?>"/>
<div class="hidden" for="help_for_regdhcpdomain">
<?= gettext("The domain name to use for DHCP hostname registration. " .
"If empty, the default system domain is used. Note that all DHCP " .
"leases will be assigned to the same domain. If this is undesired, " .
"static DHCP lease registration is able to provide coherent mappings.") ?>
</div>
</td>
</tr>