diff options
author | Ermal <eri@pfsense.org> | 2010-08-19 17:44:01 +0000 |
---|---|---|
committer | Ermal <eri@pfsense.org> | 2010-08-19 17:44:01 +0000 |
commit | 1e1dd1f590db2470bae56583ec18603567469726 (patch) | |
tree | 8683d7d4d7a327616a11ab57cc9682d6a9645a59 /etc/inc/services.inc | |
parent | 003f291aac13c6e88aa6a2e150ee386405d113a1 (diff) | |
download | pfsense-1e1dd1f590db2470bae56583ec18603567469726.zip pfsense-1e1dd1f590db2470bae56583ec18603567469726.tar.gz |
Ticket #725. Add checking the routing table as a last resort to find the correct interface before falling back to the default one.
Diffstat (limited to 'etc/inc/services.inc')
-rw-r--r-- | etc/inc/services.inc | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/etc/inc/services.inc b/etc/inc/services.inc index de186d0..877368a 100644 --- a/etc/inc/services.inc +++ b/etc/inc/services.inc @@ -483,10 +483,9 @@ function services_dhcrelay_configure() { $dhcrelayenable = false; if(is_array($dhcrelaycfg)) { foreach ($dhcrelaycfg as $dhcrelayif => $dhcrelayifconf) { - if (isset($dhcrelayifconf['enable']) && - (($dhcrelayif == "lan") || + if (isset($dhcrelayifconf['enable']) || (isset($config['interfaces'][$dhcrelayif]['enable']) && - $config['interfaces'][$dhcrelayif]['if'] && (!link_interface_to_bridge($dhcrelayif))))) + (!link_interface_to_bridge($dhcrelayif)))) $dhcrelayenable = true; } } @@ -505,9 +504,8 @@ function services_dhcrelay_configure() { $ifcfg = $config['interfaces'][$dhcrelayif]; if (!isset($dhcrelayifconf['enable']) || - (($dhcrelayif != "lan") && - (!isset($ifcfg['enable']) || !$ifcfg['if'] || - link_interface_to_bridge($dhcrelayif)))) + (!isset($ifcfg['enable']) || + link_interface_to_bridge($dhcrelayif))) continue; $dhcrelayifs[] = get_real_interface($dhcrelayif); @@ -536,6 +534,23 @@ function services_dhcrelay_configure() { } if (!isset($destif)) { + /* Create a array from the existing route table */ + exec("/usr/bin/netstat -rnf inet", $route_str); + array_shift($route_str); + array_shift($route_str); + array_shift($route_str); + array_shift($route_str); + $route_arr = array(); + foreach($route_str as $routeline) { + $items = preg_split("/[ ]+/i", $routeline); + if (ip_in_subnet($$dhcrelaycfg['server'], $items[0])) { + $destif = trim($items[2]); + break; + } + } + } + + if (!isset($destif)) { if (is_array($config['gateways']['gateway_item'])) { foreach ($config['gateways']['gateway_item'] as $gateway) { if (isset($gateway['defaultgw'])) { |