diff options
-rw-r--r-- | etc/inc/system.inc | 56 | ||||
-rwxr-xr-x | 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"); <tr> <td width="22%" valign="top" class="vncell">DNS servers</td> <td width="78%" class="vtable"> <p> + <?php + $multiwan = false; + foreach($config['interfaces'] as $int) + if($int['gateway']) + $multiwan = true; + ?> <input name="dns1" type="text" class="formfld unknown" id="dns1" size="20" value="<?=htmlspecialchars($pconfig['dns1']);?>"> + <?php + if($multiwan) { + echo "<select name='dns1gwint'>\n"; + foreach($ints as $int) { + if($config['interfaces'][$int]['gateway']) { + $selected = ""; + if($pconfig['dns1gwint'] == $int) + $selected = " SELECTED"; + echo "<option value='{$int}'{$selected}>{$int}></option>"; + } + } + echo "</select>"; + } + ?> <br> <input name="dns2" type="text" class="formfld unknown" id="dns22" size="20" value="<?=htmlspecialchars($pconfig['dns2']);?>"> + <?php + if($multiwan) { + echo "<select name='dns1gwint'>\n"; + foreach($ints as $int) { + if($config['interfaces'][$int]['gateway']) { + $selected = ""; + if($pconfig['dns1gwint'] == $int) + $selected = " SELECTED"; + echo "<option value='{$int}'{$selected}>{$int}></option>"; + } + } + echo "</select>"; + } + ?> <br> <span class="vexpl">IP addresses; these are also used for the DHCP service, DNS forwarder and for PPTP VPN clients<br> |