mirror of
https://github.com/pfsense/pfsense.git
synced 2025-10-26 11:38:35 +00:00
Make the vpn configuration add static routes on interfaces other then WAN.
link_carp_interface_to_parent() now correctly returns parent interface instead of always WAN.
This commit is contained in:
parent
2f306bdbc6
commit
20fdc10f37
@ -1211,20 +1211,26 @@ function link_carp_interface_to_parent($interface) {
|
||||
global $config;
|
||||
if($interface == "") return;
|
||||
|
||||
$ifdescrs = array('wan', 'lan');
|
||||
$ifdescrs = array("wan" => "wan", "lan" => "lan");
|
||||
for ($j = 1; isset($config['interfaces']['opt' . $j]); $j++)
|
||||
$ifdescrs['opt' . $j] = "opt" . $j;
|
||||
|
||||
$carp_int = $interface;
|
||||
$carp_ip = find_interface_ip($interface);
|
||||
$carp_subnet = find_virtual_ip_netmask($carp_ip);
|
||||
$starting_ip = gen_subnet("{$carp_ip}", "{$carp_subnet}");
|
||||
$carp_ints = "";
|
||||
$num_carp_ints = find_number_of_created_carp_interfaces();
|
||||
|
||||
foreach ($ifdescrs as $ifdescr => $ifname) {
|
||||
$carp_int = $interface;
|
||||
$carp_ip = find_interface_ip($interface);
|
||||
$carp_subnet = find_virtual_ip_netmask($carp_ip);
|
||||
$starting_ip = gen_subnet("{$carp_ip}", "{$carp_subnet}");
|
||||
if(ip_in_subnet($starting_ip, "{$carp_ip}/{$carp_subnet}"))
|
||||
if(!stristr($carp_ints, $carp_int))
|
||||
if(interface_has_gateway($ifname)) {
|
||||
$interfaceip = $config['interfaces'][$ifname]['ipaddr'];
|
||||
$subnet_bits = $config['interfaces'][$ifname]['subnet'];
|
||||
$subnet_ip = gen_subnet("{$interfaceip}", "{$subnet_bits}");
|
||||
if(ip_in_subnet($carp_ip, "{$subnet_ip}/{$subnet_bits}")) {
|
||||
return $ifname;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $carp_ints;
|
||||
}
|
||||
|
||||
@ -245,8 +245,14 @@ function vpn_ipsec_configure($ipchg = false) {
|
||||
|
||||
if($tunnel['interface'] <> "wan") {
|
||||
/* static route needed? */
|
||||
if(strstr("carp", $tunnel['interface'])) {
|
||||
|
||||
if(preg_match("/^carp/i", $tunnel['interface'])) {
|
||||
/* add endpoint routes to correct gateway on interface */
|
||||
$parentinterface = link_carp_interface_to_parent($tunnel['interface']);
|
||||
$gatewayip = get_interface_gateway("$parentinterface");
|
||||
if($gatewayip) {
|
||||
log_error("IPSEC interface is not WAN but {$tunnel['interface']}, adding static route for VPN endpoint {$tunnel['remote-gateway']} via {$gatewayip}");
|
||||
mwexec("/sbin/route add -host {$tunnel['remote-gateway']} {$gatewayip}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user