diff --git a/src/etc/inc/plugins.inc.d/unbound.inc b/src/etc/inc/plugins.inc.d/unbound.inc index be9a142b9..c6b00ef86 100644 --- a/src/etc/inc/plugins.inc.d/unbound.inc +++ b/src/etc/inc/plugins.inc.d/unbound.inc @@ -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; diff --git a/src/www/services_unbound.php b/src/www/services_unbound.php index e528f6012..177e2c750 100644 --- a/src/www/services_unbound.php +++ b/src/www/services_unbound.php @@ -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"); /> =gettext("Register DHCP leases in the DNS Resolver");?>