From e180a6e3cd100ae365037b5b1da08f1be473107f Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Sat, 8 Dec 2007 23:05:08 +0000 Subject: When multiple gateways are present (muliwan) show a dropdown box next to each dns server allowing the operator to select which gateway the dns server should use to resolve addresses. --- etc/inc/system.inc | 56 ++++++++++++++++++++++++++++------------------ usr/local/www/system.php | 58 +++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 89 insertions(+), 25 deletions(-) diff --git a/etc/inc/system.inc b/etc/inc/system.inc index a66ee08..63a0dc3 100644 --- a/etc/inc/system.inc +++ b/etc/inc/system.inc @@ -94,11 +94,11 @@ EOFF; } function system_resolvconf_generate($dynupdate = false) { - global $config, $g; - if(isset($config['system']['developerspew'])) { - $mt = microtime(); - echo "system_resolvconf_generate() being called $mt\n"; - } + global $config, $g; + if(isset($config['system']['developerspew'])) { + $mt = microtime(); + echo "system_resolvconf_generate() being called $mt\n"; + } $syscfg = $config['system']; @@ -113,33 +113,45 @@ function system_resolvconf_generate($dynupdate = false) { $havedns = false; if (isset($syscfg['dnsallowoverride'])) { - /* get dynamically assigned DNS servers (if any) */ - $ns = array_unique(get_nameservers()); - foreach($ns as $nameserver) { - if($nameserver) { - $resolvconf .= "nameserver $nameserver\n"; - $havedns = true; + /* get dynamically assigned DNS servers (if any) */ + $ns = array_unique(get_nameservers()); + foreach($ns as $nameserver) { + if($nameserver) { + $resolvconf .= "nameserver $nameserver\n"; + $havedns = true; + } } - } } if (!$havedns && is_array($syscfg['dnsserver'])) { - foreach ($syscfg['dnsserver'] as $ns) { - if ($ns) { - $resolvconf .= "nameserver $ns\n"; - $havedns = true; + foreach ($syscfg['dnsserver'] as $ns) { + if ($ns) { + $resolvconf .= "nameserver $ns\n"; + $havedns = true; + } } - } - } + } fwrite($fd, $resolvconf); fclose($fd); if (!$g['booting']) { - /* restart dhcpd (nameservers may have changed) */ - if (!$dynupdate) - services_dhcpd_configure(); + /* restart dhcpd (nameservers may have changed) */ + if (!$dynupdate) + services_dhcpd_configure(); } + /* setup static routes for dns servers */ + if($config['system']['dns1gwint']) { + $if = $config['system']['dns1gwint']; + $gw = $config['interfaces'][$if]['if']; + exec("route add {$syscfg['dnsserver'][0]} -gw {$gw}"); + } + if($config['system']['dns2gwint']) { + $if = $config['system']['dns2gwint']; + $gw = $config['interfaces'][$if]['if']; + exec("route add {$syscfg['dnsserver'][1]} -gw {$gw}"); + } + return 0; } @@ -1299,4 +1311,4 @@ function enable_watchdog() { } } -?> +?> \ No newline at end of file diff --git a/usr/local/www/system.php b/usr/local/www/system.php index 16f6a62..b8242ed 100755 --- a/usr/local/www/system.php +++ b/usr/local/www/system.php @@ -35,6 +35,9 @@ $pconfig['hostname'] = $config['system']['hostname']; $pconfig['domain'] = $config['system']['domain']; list($pconfig['dns1'],$pconfig['dns2']) = $config['system']['dnsserver']; +$pconfig['dns1gwint'] = $config['system']['dns1gwint']; +$pconfig['dns2gwint'] = $config['system']['dns2gwint']; + $pconfig['dnsallowoverride'] = isset($config['system']['dnsallowoverride']); $pconfig['webguiproto'] = $config['system']['webgui']['protocol']; if (!$pconfig['webguiproto']) @@ -78,6 +81,10 @@ if ($_POST) { $changecount++; + /* remove old static route if exists */ + exec("route delete {$pconfig['dns1']}"); + exec("route delete {$pconfig['dns2']}"); + unset($input_errors); $pconfig = $_POST; @@ -141,11 +148,22 @@ if ($_POST) { unset($config['system']['dnsallowoverride']); $config['system']['dnsallowoverride'] = $_POST['dnsallowoverride'] ? true : false; - if ($_POST['password']) { - $config['system']['password'] = crypt($_POST['password']); + + if ($_POST['password']) { + $config['system']['password'] = crypt($_POST['password']); update_changedesc("password changed via webConfigurator"); sync_webgui_passwords(); - } + } + + /* which interface should the dns servers resolve through? */ + if($_POST['dns1gwint']) + $config['system']['dns1gwint'] = $pconfig['dns1gwint']; + else + unset($config['system']['dns1gwint']); + if($_POST['dns2gwint']) + $config['system']['dns2gwint'] = $pconfig['dns2gwint']; + else + unset($config['system']['dns2gwint']); if ($changecount > 0) write_config($changedesc); @@ -207,9 +225,43 @@ include("head.inc"); DNS servers

+ + \n"; + foreach($ints as $int) { + if($config['interfaces'][$int]['gateway']) { + $selected = ""; + if($pconfig['dns1gwint'] == $int) + $selected = " SELECTED"; + echo ""; + } + } + echo ""; + } + ?>
+ \n"; + foreach($ints as $int) { + if($config['interfaces'][$int]['gateway']) { + $selected = ""; + if($pconfig['dns1gwint'] == $int) + $selected = " SELECTED"; + echo ""; + } + } + echo ""; + } + ?>
IP addresses; these are also used for the DHCP service, DNS forwarder and for PPTP VPN clients
-- cgit v1.1