From bd5737dc22b0e52a52e84fc2d9d1193deb43811d Mon Sep 17 00:00:00 2001 From: jim-p Date: Wed, 23 Apr 2014 10:14:59 -0400 Subject: [PATCH] Make sure that the DNS Forwarder/Resolver is actually capable of accepting queries on localhost before using it as a DNS server. --- etc/inc/system.inc | 4 +++- usr/local/www/services_dnsmasq.php | 2 ++ usr/local/www/services_unbound.php | 2 ++ usr/local/www/system.php | 2 +- 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/etc/inc/system.inc b/etc/inc/system.inc index 0e78128483..80f6f32aaf 100644 --- a/etc/inc/system.inc +++ b/etc/inc/system.inc @@ -103,7 +103,9 @@ function system_resolvconf_generate($dynupdate = false) { if($syscfg['domain']) $resolvconf = "domain {$syscfg['domain']}\n"; - if ((isset($config['dnsmasq']['enable']) || isset($config['unbound']['enable'])) && !isset($config['system']['dnslocalhost'])) + if (((isset($config['dnsmasq']['enable']) && (empty($config['dnsmasq']['interface']) || in_array("lo0", explode(",", $config['dnsmasq']['interface'])))) + || (isset($config['unbound']['enable'])) && (empty($config['unbound']['active_interface']) || in_array("lo0", explode(",", $config['unbound']['active_interface'])))) + && !isset($config['system']['dnslocalhost'])) $resolvconf .= "nameserver 127.0.0.1\n"; if (isset($syscfg['dnsallowoverride'])) { diff --git a/usr/local/www/services_dnsmasq.php b/usr/local/www/services_dnsmasq.php index 75c1a8e471..4033911e9f 100644 --- a/usr/local/www/services_dnsmasq.php +++ b/usr/local/www/services_dnsmasq.php @@ -116,6 +116,8 @@ if ($_POST) { // Relaod filter (we might need to sync to CARP hosts) filter_configure(); + /* Update resolv.conf in case the interface bindings exclude localhost. */ + system_resolvconf_generate(); if ($retval == 0) clear_subsystem_dirty('hosts'); diff --git a/usr/local/www/services_unbound.php b/usr/local/www/services_unbound.php index a6a61aabdd..08a2e6e554 100644 --- a/usr/local/www/services_unbound.php +++ b/usr/local/www/services_unbound.php @@ -110,6 +110,8 @@ if ($_POST) { $savemsg = get_std_save_message($retval); if ($retval == 0) clear_subsystem_dirty('unbound'); + /* Update resolv.conf in case the interface bindings exclude localhost. */ + system_resolvconf_generate(); } } diff --git a/usr/local/www/system.php b/usr/local/www/system.php index be5446e6e0..a5e2b1703f 100644 --- a/usr/local/www/system.php +++ b/usr/local/www/system.php @@ -402,7 +402,7 @@ include("head.inc");
-