summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorErmal <eri@pfsense.org>2010-09-16 22:42:22 +0000
committerErmal <eri@pfsense.org>2010-09-16 22:42:22 +0000
commit86dcdfc9af338c8f76de0d6863ed058c4be74665 (patch)
tree5f20a71c089615a5ee37fb2e575a0546dbb46244
parent9d1f614cf5108062a991d405386aabb0739a02be (diff)
downloadpfsense-86dcdfc9af338c8f76de0d6863ed058c4be74665.zip
pfsense-86dcdfc9af338c8f76de0d6863ed058c4be74665.tar.gz
Add as a search domain the domains suggested by dhcp.
-rw-r--r--etc/inc/interfaces.inc2
-rw-r--r--etc/inc/system.inc24
-rwxr-xr-xsbin/dhclient-script2
3 files changed, 27 insertions, 1 deletions
diff --git a/etc/inc/interfaces.inc b/etc/inc/interfaces.inc
index 0f85aaa..ae8c299 100644
--- a/etc/inc/interfaces.inc
+++ b/etc/inc/interfaces.inc
@@ -886,6 +886,8 @@ function interface_bring_down($interface = "wan", $destroy = false) {
unlink_if_exists("{$g['tmp_path']}/{$realif}up");
unlink_if_exists("{$g['vardb_path']}/{$interface}ip");
unlink_if_exists("{$g['tmp_path']}/{$realif}_router");
+ unlink_if_exists("{$g['varetc_path']}/nameserver_{$realif}");
+ unlink_if_exists("{$g['varetc_path']}/searchdomain_{$realif}");
/* hostapd and wpa_supplicant do not need to be running when the interface is down.
* They will also use 100% CPU if running after the wireless clone gets deleted. */
diff --git a/etc/inc/system.inc b/etc/inc/system.inc
index d8c6042..964004d 100644
--- a/etc/inc/system.inc
+++ b/etc/inc/system.inc
@@ -99,6 +99,13 @@ function system_resolvconf_generate($dynupdate = false) {
if (isset($syscfg['dnsallowoverride'])) {
/* get dynamically assigned DNS servers (if any) */
+ $ns = array_unique(get_searchdomains());
+ foreach($ns as $searchserver) {
+ if($searchserver) {
+ $resolvconf .= "search {$searchserver}\n";
+ $havedns = true;
+ }
+ }
$ns = array_unique(get_nameservers());
foreach($ns as $nameserver) {
if($nameserver) {
@@ -146,6 +153,23 @@ function system_resolvconf_generate($dynupdate = false) {
return 0;
}
+function get_searchdomains() {
+ global $config, $g;
+
+ $master_list = array();
+
+ // Read in dhclient nameservers
+ $search_list = split("\n", `/bin/cat /var/etc/searchdomain_* 2>/dev/null`);
+ if (is_array($search_lists)) {
+ foreach($search_lists as $dns) {
+ if(is_hostname($dns))
+ $master_list[] = $dns;
+ }
+ }
+
+ return $master_list;
+}
+
function get_nameservers() {
global $config, $g;
$master_list = array();
diff --git a/sbin/dhclient-script b/sbin/dhclient-script
index f61715d..d9d55bb 100755
--- a/sbin/dhclient-script
+++ b/sbin/dhclient-script
@@ -175,7 +175,7 @@ add_new_resolv_conf() {
echo $nameserver >>/var/etc/nameserver_$interface
$ROUTE add $nameserver -iface $interface
done
- #echo $new_domain_name >/var/etc/defaultdomain.conf
+ echo $new_domain_name >/var/etc/searchdomain_$interface
/usr/local/sbin/pfSctl -c 'service reload dns'
fi
OpenPOWER on IntegriCloud