From 1033de7481dacd83ee5a1a16078e89c7b4e9efd8 Mon Sep 17 00:00:00 2001 From: Ermal Date: Tue, 23 Mar 2010 21:13:32 +0000 Subject: Resolve problems with dns server setup when allow override is set. Also add static routes for all nameservers to be friendly with multiwan. --- etc/inc/system.inc | 18 +++++++----------- sbin/dhclient-script | 2 -- usr/local/sbin/ppp-linkdown | 4 ++-- usr/local/sbin/ppp-linkup | 13 ++++++++----- 4 files changed, 17 insertions(+), 20 deletions(-) diff --git a/etc/inc/system.inc b/etc/inc/system.inc index d5ff189..89ad72e 100644 --- a/etc/inc/system.inc +++ b/etc/inc/system.inc @@ -149,25 +149,21 @@ function get_nameservers() { $master_list = array(); // Read in dhclient nameservers - $dns_lists = split("\n", `ls /var/etc/nameserver_* 2>/dev/null`); - if(is_array($dns_lists)) { + $dns_lists = split("\n", `/bin/cat /var/etc/nameserver_* 2>/dev/null`); + if (is_array($dns_lists)) { foreach($dns_lists as $dns) { - if(!$dns) - continue; - $items = split("\n", file_get_contents($dns)); - foreach($items as $item) - if($item <> "") - $master_list[] = $item; + if(is_ipaddr($dns)) + $master_list[] = $item; } } // Read in any extra nameservers if(file_exists("/var/etc/nameservers.conf")) { - $dns = `cat /var/etc/nameservers.conf`; - $dns_s = split("\n", $dns); + $dns_lists = split("\n", `/bin/cat /var/etc/nameservers.conf`); if(is_array($dns_s)) foreach($dns_s as $dns) - $master_list[] = $dns; + if (is_ipaddr($dns)) + $master_list[] = $dns; } return $master_list; diff --git a/sbin/dhclient-script b/sbin/dhclient-script index d58d972..8d10af5 100755 --- a/sbin/dhclient-script +++ b/sbin/dhclient-script @@ -174,7 +174,6 @@ add_new_routes() { add_new_resolv_conf() { $LOGGER "Creating resolv.conf" - /bin/rm -f /var/etc/nameservers.conf if [ ! -f "/var/etc/nameserver_$interface" ]; then # Make sure file exists to avoid errors touch /var/etc/nameserver_$interface @@ -186,7 +185,6 @@ add_new_resolv_conf() { done rm -f /var/etc/nameserver_$interface for nameserver in $new_domain_name_servers; do - echo $nameserver >>/var/etc/nameservers.conf # Add a route to the nameserver out the correct interface # so that mulitple wans work correctly with multiple dns # also backup the nameserver for later route removal diff --git a/usr/local/sbin/ppp-linkdown b/usr/local/sbin/ppp-linkdown index 8bd7c89..c16e8ff 100755 --- a/usr/local/sbin/ppp-linkdown +++ b/usr/local/sbin/ppp-linkdown @@ -2,5 +2,5 @@ # delete the node just in case mpd cannot do that /usr/sbin/ngctl shutdown $1: - -rm -f /tmp/$1_router +/bin/rm -f /var/etc/nameserver_$1 +/bin/rm -f /tmp/$1_router diff --git a/usr/local/sbin/ppp-linkup b/usr/local/sbin/ppp-linkup index ff1157a..f850fa7 100755 --- a/usr/local/sbin/ppp-linkup +++ b/usr/local/sbin/ppp-linkup @@ -1,6 +1,6 @@ #!/bin/sh -rm -f /var/etc/nameservers.conf +rm -f /var/etc/nameserver_$1 # unset CGI environment variables so as not to confuse PHP unset CONTENT_TYPE GATEWAY_INTERFACE REMOTE_USER REMOTE_ADDR AUTH_TYPE @@ -9,11 +9,14 @@ unset SERVER_SOFTWARE HTTP_REFERER SERVER_PROTOCOL REQUEST_METHOD unset SERVER_PORT SCRIPT_NAME SERVER_NAME # write nameservers to file -if [ "$6" = "dns1" ]; then - /bin/echo $7 >> /var/etc/nameservers.conf +if [ "$6" = "dns1" ] + echo $7 >> /var/etc/nameserver_$1 + /sbin/route add $7 -if $1 fi -if [ "$8" = "dns2" ]; then - /bin/echo $9 >> /var/etc/nameservers.conf + +if [ "$8" = "dns1" ] + echo $9 >> /var/etc/nameserver_$1 + /sbin/route add $9 -if $1 fi # let the configuration system know that the ip has changed. -- cgit v1.1