diff options
author | Bill Marquette <billm@pfsense.org> | 2005-03-08 07:14:42 +0000 |
---|---|---|
committer | Bill Marquette <billm@pfsense.org> | 2005-03-08 07:14:42 +0000 |
commit | 186a42b0a09c842badb24b9a6ea9f4497ee017a1 (patch) | |
tree | f44afe311b41204a1e6c66a297464d6da374d080 | |
parent | 908ee21828bc8391d291fecb624e1dfda2fac1e3 (diff) | |
download | pfsense-186a42b0a09c842badb24b9a6ea9f4497ee017a1.zip pfsense-186a42b0a09c842badb24b9a6ea9f4497ee017a1.tar.gz |
DHCP on wan interface should now work
dhclient is nice and creates /etc/resolv.conf, which we used to just blow away
-rw-r--r-- | etc/inc/system.inc | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/etc/inc/system.inc b/etc/inc/system.inc index ae9a3ea..ce1fb6d 100644 --- a/etc/inc/system.inc +++ b/etc/inc/system.inc @@ -36,9 +36,9 @@ function system_resolvconf_generate($dynupdate = false) { $syscfg = $config['system']; - $fd = fopen("{$g['varetc_path']}/resolv.conf", "w"); + $fd = fopen("{$g['varetc_path']}/resolv.conf.new", "w"); if (!$fd) { - printf("Error: cannot open resolv.conf in system_resolvconf_generate().\n"); + printf("Error: cannot open resolv.conf.new in system_resolvconf_generate().\n"); return 1; } @@ -47,7 +47,7 @@ function system_resolvconf_generate($dynupdate = false) { $havedns = false; if (isset($syscfg['dnsallowoverride'])) { - /* get dynamically assigned DNS servers (if any) */ + /* get dynamically assigned DNS servers for ppp (if any) */ $nfd = @fopen("{$g['varetc_path']}/nameservers.conf", "r"); if ($nfd) { while (!feof($nfd)) { @@ -60,6 +60,8 @@ function system_resolvconf_generate($dynupdate = false) { fclose($nfd); } } + + /* if we didn't get assigned DNS servers and have some set add 'em */ if (!$havedns && is_array($syscfg['dnsserver'])) { foreach ($syscfg['dnsserver'] as $ns) { if ($ns) @@ -71,6 +73,16 @@ function system_resolvconf_generate($dynupdate = false) { fwrite($fd, $resolvconf); fclose($fd); + /* If we now have DNS servers, overwrite resolv.conf */ + if ($havedns) { + if (file_exists("{$g['varetc_path']}/resolv.conf")) + unlink("{$g['varetc_path']}/resolv.conf"); + rename("{$g['varetc_path']}/resolv.conf.new", "{$g['varetc_path']}/resolv.conf"); + } else { + unlink("{$g['varetc_path']}/resolv.conf.new"); + } + + if (!$g['booting']) { /* restart dhcpd (nameservers may have changed) */ if (!$dynupdate) |