summaryrefslogtreecommitdiffstats
path: root/etc/inc
diff options
context:
space:
mode:
authorBill Marquette <billm@pfsense.org>2005-03-08 07:14:42 +0000
committerBill Marquette <billm@pfsense.org>2005-03-08 07:14:42 +0000
commit186a42b0a09c842badb24b9a6ea9f4497ee017a1 (patch)
treef44afe311b41204a1e6c66a297464d6da374d080 /etc/inc
parent908ee21828bc8391d291fecb624e1dfda2fac1e3 (diff)
downloadpfsense-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
Diffstat (limited to 'etc/inc')
-rw-r--r--etc/inc/system.inc18
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)
OpenPOWER on IntegriCloud