Project

General

Profile

« Previous | Next » 

Revision 44085a65

Added by Ermal Luçi over 10 years ago

Ticket #4254 Actually use proper variables allover to have correct route added

View differences:

etc/inc/vpn.inc
599 599
					}
600 600
					
601 601
					if (!empty($ifacesuse) && interface_has_gateway($vpninterface)) {
602
						$gatewayip = get_interface_gateway($ifacesuse);
603
						$interfaceip = get_interface_ip($ifacesuse);
604
						$subnet_bits = get_interface_subnet($ifacesuse);
602
						$gatewayip = get_interface_gateway($vpninterface);
603
						$interfaceip = get_interface_ip($vpninterface);
604
						$subnet_bits = get_interface_subnet($vpninterface);
605 605
						$subnet_ip = gen_subnetv4($interfaceip, $subnet_bits);
606 606
						/* if the remote gateway is in the local subnet, then don't add a route */
607
						if (!ip_in_subnet($rgip, "{$subnet_ip}/{$subnet_bits}")) {
607
						if (!ip_in_subnet($sourcehost, "{$subnet_ip}/{$subnet_bits}")) {
608 608
							if (is_ipaddrv4($gatewayip)) {
609 609
								// log_error("IPSEC interface is not WAN but {$ifacesuse}, adding static route for VPN endpoint {$rgip} via {$gatewayip}");
610
								mwexec("/sbin/route change -host {$rgip} {$gatewayip}", true);
610
								mwexec("/sbin/route change -host {$sourcehost} {$gatewayip}", true);
611 611
							}
612 612
						}
613 613
					}
......
621 621
						$vpninterface = convert_real_interface_to_friendly_interface_name($ifacesuse);
622 622
					}
623 623
					
624
					if (!empty($ifacesuse) && interface_has_gateway($ifacesuse)) {
625
						$gatewayip = get_interface_gateway_v6($ifacesuse);
626
						$interfaceip = get_interface_ipv6($ifacesuse);
627
						$subnet_bits = get_interface_subnetv6($ifacesuse);
624
					if (!empty($ifacesuse) && interface_has_gateway($vpninterface)) {
625
						$gatewayip = get_interface_gateway_v6($vpninterface);
626
						$interfaceip = get_interface_ipv6($vpninterface);
627
						$subnet_bits = get_interface_subnetv6($vpninterface);
628 628
						$subnet_ip = gen_subnetv6($interfaceip, $subnet_bits);
629 629
						/* if the remote gateway is in the local subnet, then don't add a route */
630
						if (!ip_in_subnet($rgip, "{$subnet_ip}/{$subnet_bits}")) {
630
						if (!ip_in_subnet($sourcehost, "{$subnet_ip}/{$subnet_bits}")) {
631 631
							if (is_ipaddrv6($gatewayip)) {
632 632
								// log_error("IPSEC interface is not WAN but {$ifacesuse}, adding static route for VPN endpoint {$rgip} via {$gatewayip}");
633
								mwexec("/sbin/route change -inet6 -host {$rgip} {$gatewayip}", true);
633
								mwexec("/sbin/route change -inet6 -host {$sourcehost} {$gatewayip}", true);
634 634
							}
635 635
						}
636 636
					}

Also available in: Unified diff