From 18c3d97ef2b6ce0867fb9890a9aff5bdfa5371ba Mon Sep 17 00:00:00 2001 From: Franco Fichtner Date: Sun, 16 Sep 2018 15:07:10 +0200 Subject: [PATCH] unbound: always bind to loopback get_possible_listen_ips() should go away and Dnsmasq already does the right thing so let Unbound follow. While here get rid of writing empty values into the config and even offering them on the GUI... --- src/etc/inc/plugins.inc.d/unbound.inc | 10 +++- src/etc/inc/system.inc | 5 +- src/www/services_dnsmasq.php | 2 +- src/www/services_unbound.php | 76 +++++++++++++-------------- 4 files changed, 49 insertions(+), 44 deletions(-) diff --git a/src/etc/inc/plugins.inc.d/unbound.inc b/src/etc/inc/plugins.inc.d/unbound.inc index 2b203e92f..34e93e6bb 100644 --- a/src/etc/inc/plugins.inc.d/unbound.inc +++ b/src/etc/inc/plugins.inc.d/unbound.inc @@ -163,16 +163,24 @@ EOF; $bindints = ""; if (!empty($config['unbound']['active_interface'])) { $active_interfaces = explode(",", $config['unbound']['active_interface']); + $loopback = false; foreach ($active_interfaces as $ubif) { $intip = get_interface_ip($ubif); if (!empty($intip)) { $bindints .= "interface: $intip\n"; + if ($intip == '127.0.0.1') { + $loopback = true; + } } $intip = get_interface_ipv6($ubif); if (!empty($intip)) { $bindints .= "interface: $intip\n"; } } + if (!$loopback) { + /* always bind to this loopback IP for system */ + $bindints .= "interface: 127.0.0.1\n"; + } } else { $bindints .= "interface: 0.0.0.0\n"; $bindints .= "interface: ::0\n"; @@ -696,7 +704,7 @@ function unbound_acls_subnets() /* add our networks for active interfaces including localhost */ $subnets = array('127.0.0.1/8', '::1/64'); - foreach ($active_interfaces as $ubif => $ifdesc) { + foreach ($active_interfaces as $ubif => $unused) { foreach (legacy_getall_interface_addresses(get_real_interface($ubif)) as $subnet) { $subnets[] = $subnet; } diff --git a/src/etc/inc/system.inc b/src/etc/inc/system.inc index 087b9f816..8d03abbbc 100644 --- a/src/etc/inc/system.inc +++ b/src/etc/inc/system.inc @@ -157,10 +157,7 @@ function system_resolvconf_generate($verbose = false) $resolvconf = "domain {$syscfg['domain']}\n"; } - /* XXX Unbound should always bind to loopback like Dnsmasq */ - if (!isset($config['system']['dnslocalhost']) && (isset($config['dnsmasq']['enable']) || - (isset($config['unbound']['enable']) && (empty($config['unbound']['active_interface']) || - in_array('lo0', explode(',', $config['unbound']['active_interface'])))))) { + if (!isset($config['system']['dnslocalhost']) && (isset($config['dnsmasq']['enable']) || isset($config['unbound']['enable']))) { $resolvconf .= "nameserver 127.0.0.1\n"; } diff --git a/src/www/services_dnsmasq.php b/src/www/services_dnsmasq.php index c358a9e0c..da71a1e7e 100644 --- a/src/www/services_dnsmasq.php +++ b/src/www/services_dnsmasq.php @@ -349,7 +349,7 @@ $( document ).ready(function() { - $ifacename): ?>