diff options
Diffstat (limited to 'etc')
-rw-r--r-- | etc/inc/interfaces.inc | 15 | ||||
-rw-r--r-- | etc/inc/pfsense-utils.inc | 8 | ||||
-rw-r--r-- | etc/inc/system.inc | 50 | ||||
-rw-r--r-- | etc/inc/xmlparse.inc | 4 |
4 files changed, 57 insertions, 20 deletions
diff --git a/etc/inc/interfaces.inc b/etc/inc/interfaces.inc index 9fb01fe..ff79abf 100644 --- a/etc/inc/interfaces.inc +++ b/etc/inc/interfaces.inc @@ -859,21 +859,6 @@ function interfaces_wan_configure() { mwexec("/sbin/ifconfig " . escapeshellarg($wancfg['if']) . " " . escapeshellarg($wancfg['ipaddr'] . "/" . $wancfg['subnet'])); } - /* install default route */ - mwexec("/sbin/route delete default"); - - $dont_add_route = false; - /* if OLSRD is enabled, allow WAN to house DHCP. */ - if($config['installedpackages']['olsrd']) { - foreach($config['installedpackages']['olsrd']['config'] as $olsrd) { - if($olsrd['enabledyngw'] == "on") { - $dont_add_route = true; - } - } - } - - if($dont_add_route == false) - mwexec("/sbin/route add default " . escapeshellarg($config['interfaces']['wan']['gateway'])); /* resync pf (done automatically for DHCP/PPPoE/PPTP) */ filter_configure(); diff --git a/etc/inc/pfsense-utils.inc b/etc/inc/pfsense-utils.inc index 51e3489..a6a3d1f 100644 --- a/etc/inc/pfsense-utils.inc +++ b/etc/inc/pfsense-utils.inc @@ -3380,7 +3380,13 @@ function get_interface_gateway($interface) { $gw = file_get_contents("{$g['tmp_path']}/{$realif}_router"); $gw = rtrim($gw); } else { - $gw = $config['interfaces'][$interface]['gateway']; + foreach($config['gateways']['gateway_item'] as $gateway) { + if($gateway['name'] == $gateway['name']) { + $gatewayip = $gateway['gateway']; + $interfacegw = $gateway['interface']; + } + } + $gw = $gatewayip; } /* if wan is requested, return it */ if($interface == "wan") diff --git a/etc/inc/system.inc b/etc/inc/system.inc index 3561e11..c055874 100644 --- a/etc/inc/system.inc +++ b/etc/inc/system.inc @@ -251,6 +251,46 @@ function system_routing_configure() { unlink("{$g['vardb_path']}/routes.db"); } + /* if list */ + $iflist = array("lan", "wan"); + for ($i = 1; isset($config['interfaces']['opt' . $i]['enable']); $i++) + $iflist['opt' . $i] = "opt{$i}"; + + $dont_remove_route = false; + foreach ($iflist as $ifent => $ifname) { + /* do not process interfaces that will end up with gateways */ + if($config['interfaces'][$ifname]['ipaddr'] == "dhcp" or + $config['interfaces'][$ifname]['ipaddr'] == "bigpond" or + $config['interfaces'][$ifname]['ipaddr'] == "pppoe" or + $config['interfaces'][$ifname]['ipaddr'] == "pptp") + $dont_remove_route = true; + } + + if($dont_remove_route == false) { + /* remove default route */ + mwexec("/sbin/route delete default"); + } + + $dont_add_route = false; + /* if OLSRD is enabled, allow WAN to house DHCP. */ + if($config['installedpackages']['olsrd']) { + foreach($config['installedpackages']['olsrd']['config'] as $olsrd) { + if($olsrd['enabledyngw'] == "on") { + $dont_add_route = true; + } + } + } + + if($dont_add_route == false) { + foreach($config['gateways']['gateway_item'] as $gateway) { + if(isset($gateway['defaultgw'])) { + $gatewayip = $gateway['gateway']; + $interfacegw = $gateway['interface']; + } + } + mwexec("/sbin/route add default " . escapeshellarg($gatewayip)); + } + if (is_array($config['staticroutes']['route'])) { $fd = fopen("{$g['vardb_path']}/routes.db", "w"); @@ -260,12 +300,18 @@ function system_routing_configure() { } foreach ($config['staticroutes']['route'] as $rtent) { + foreach($config['gateways']['gateway_item'] as $gateway) { + if($rtent['gateway'] == $gateway['name']) { + $gatewayip = $gateway['gateway']; + $interfacegw = $gateway['interface']; + } + } if(isset($rtent['interfacegateway'])) { mwexec("/sbin/route add " . escapeshellarg($rtent['network']) . - " -iface " . escapeshellarg(convert_friendly_interface_to_real_interface_name($rtent['interface']))); + " -iface " . escapeshellarg(convert_friendly_interface_to_real_interface_name($interfacegw))); } else { mwexec("/sbin/route add " . escapeshellarg($rtent['network']) . - " " . escapeshellarg($rtent['gateway'])); + " " . escapeshellarg($gatewayip)); } /* record route so it can be easily removed later (if necessary) */ fwrite($fd, $rtent['network'] . "\n"); diff --git a/etc/inc/xmlparse.inc b/etc/inc/xmlparse.inc index 0008458..73e35dc 100644 --- a/etc/inc/xmlparse.inc +++ b/etc/inc/xmlparse.inc @@ -36,7 +36,7 @@ function listtags() { "earlyshellcmd encryption-algorithm-option field fieldname hash-algorithm-option " . "hosts group interface_array item key lbpool menu mobilekey mount onetoone option package passthrumac priv proxyarpnet " . "queue pages pipe route row rule schedule service servernat servers serversdisabled earlyshellcmd shellcmd staticmap subqueue " . - "timerange tunnel user vip virtual_server vlan winsserver ntpserver wolentry widget depends_on_package"); + "timerange tunnel user vip virtual_server vlan winsserver ntpserver wolentry widget depends_on_package gateway_item"); return $ret; } @@ -259,4 +259,4 @@ function dump_xml_config_raw($arr, $rootobj) { return $xmlconfig; } -?>
\ No newline at end of file +?> |