summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhil Davis <phil.davis@inf.org>2015-03-25 23:59:59 +0545
committerRenato Botelho <garga@FreeBSD.org>2015-03-26 11:23:38 -0300
commit11fd072b116ef663dbd652143f038475a5f351c9 (patch)
tree1f7338e8b464e588cd1a0eb53c70d45bbed1426f
parent6eb5191b7c92186e242481699f51cc8b4e55646c (diff)
downloadpfsense-11fd072b116ef663dbd652143f038475a5f351c9.zip
pfsense-11fd072b116ef663dbd652143f038475a5f351c9.tar.gz
Only list nameservers once in resolv.conf
I was on a test system and had an upstream DNS server IP specified in System-General Setup. WAN was setup with a static IP and a gateway to that upstream device. All good. Then I also checked "Allow DNS server list to be overridden by DHCP/PPP on WAN" and changed WAN to be DHCP. It received by DHCP the same DNS server IP that already happened to be in General Setup (and the same gateway IP - not the issue here). /var/etc/resolv.conf had the name server line twice with the same IP address - once from the DHCP acquired data, and once from the General Setup data. I don't think it broke anything, but it does look odd. This change makes sure that DNS servers from General Setup are only added to resolv.conf when they are not already there.
-rw-r--r--etc/inc/system.inc8
1 files changed, 5 insertions, 3 deletions
diff --git a/etc/inc/system.inc b/etc/inc/system.inc
index 06e7bbe..799b1c1 100644
--- a/etc/inc/system.inc
+++ b/etc/inc/system.inc
@@ -155,14 +155,16 @@ function system_resolvconf_generate($dynupdate = false) {
$resolvconf .= "nameserver $nameserver\n";
}
} else {
+ $ns = array();
// Do not create blank search/domain lines, it can break tools like dig.
if($syscfg['domain'])
$resolvconf .= "search {$syscfg['domain']}\n";
}
if (is_array($syscfg['dnsserver'])) {
- foreach ($syscfg['dnsserver'] as $ns) {
- if ($ns)
- $resolvconf .= "nameserver $ns\n";
+ foreach ($syscfg['dnsserver'] as $sys_dnsserver) {
+ if ($sys_dnsserver && (!in_array($sys_dnsserver, $ns)) {
+ $resolvconf .= "nameserver $sys_dnsserver\n";
+ }
}
}
OpenPOWER on IntegriCloud