diff --git a/src/etc/inc/plugins.inc.d/unbound.inc b/src/etc/inc/plugins.inc.d/unbound.inc index 0b1e27102..4334102e2 100644 --- a/src/etc/inc/plugins.inc.d/unbound.inc +++ b/src/etc/inc/plugins.inc.d/unbound.inc @@ -509,7 +509,14 @@ function unbound_add_host_entries() { global $config; - $unbound_entries = "local-zone: \"{$config['system']['domain']}\" transparent\n"; + // Make sure the config setting is a valid unbound local zone type. If not use "transparent". + if (array_key_exists($config['unbound']['system_domain_local_zone_type'], unbound_local_zone_types())) { + $system_domain_local_zone_type = $config['unbound']['system_domain_local_zone_type']; + } else { + $system_domain_local_zone_type = "transparent"; + } + + $unbound_entries = "local-zone: \"{$config['system']['domain']}\" $system_domain_local_zone_type\n"; // IPv4 entries $unbound_entries .= "local-data-ptr: \"127.0.0.1 localhost\"\n"; @@ -747,3 +754,18 @@ function unbound_hosts_generate() killbypid('/var/run/unbound.pid', 'HUP'); } + +// Array of valid unbound local zone types +function unbound_local_zone_types() { + return array( + "deny" => gettext("Deny"), + "refuse" => gettext("Refuse"), + "static" => gettext("Static"), + "transparent" => gettext("Transparent"), + "typetransparent" => gettext("Type Transparent"), + "redirect" => gettext("Redirect"), + "inform" => gettext("Inform"), + "inform_deny" => gettext("Inform Deny"), + "nodefault" => gettext("No Default") + ); +} diff --git a/src/www/services_unbound.php b/src/www/services_unbound.php index 832231787..72234a415 100644 --- a/src/www/services_unbound.php +++ b/src/www/services_unbound.php @@ -51,6 +51,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { // 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(); + $pconfig['system_domain_local_zone_type'] = !empty($a_unboundcfg['system_domain_local_zone_type']) ? $a_unboundcfg['system_domain_local_zone_type'] : 'transparent'; } elseif ($_SERVER['REQUEST_METHOD'] === 'POST') { $input_errors = array(); $pconfig = $_POST; @@ -108,6 +109,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { // array types $a_unboundcfg['active_interface'] = !empty( $pconfig['active_interface']) ? implode(",", $pconfig['active_interface']) : array(); $a_unboundcfg['outgoing_interface'] = !empty( $pconfig['outgoing_interface']) ? implode(",", $pconfig['outgoing_interface']) : array(); + $a_unboundcfg['system_domain_local_zone_type'] = $pconfig['system_domain_local_zone_type']; write_config("DNS Resolver configured."); mark_subsystem_dirty('unbound'); @@ -191,6 +193,21 @@ include_once("head.inc"); +