bao*_*7uo 9 routing route openbsd gateway
我有多个 VPN 连接使用相同的网关 IP(我无法更改它,因为它不受我的控制)。这些 VPN 都提供对不同网络的访问,并且网络至少在上游一两跳,因此在所有情况下都需要网关 IP。使用 Linux,要路由到网络,我可以简单地执行以下操作:
ip route add $destination_1 via $gateway_ip dev $interface_1
ip route add $destination_2 via $gateway_ip dev $interface_2
ip route add $destination_3 via $gateway_ip dev $interface_3
Run Code Online (Sandbox Code Playgroud)
等等。
然后 Linux 会将每个目标网络的流量放置到正确的接口上,前往正确的网关,因此每个接口的网关 IP 是否相同都没有关系。
我的问题是,如何在 OpenBSD 中实现这一目标?我尝试过但失败了。我的发现是,对于特定目的地,我可以:
但我不知道如何指定两者。
使用-ifp修饰符进行路由。从手册页:
In a change or add command where the destination and gateway are not
sufficient to specify the route, the -ifp or -ifa modifiers may be
used to determine the interface name or interface address.
Run Code Online (Sandbox Code Playgroud)
所以这样的事情是有效的:
# for arg in tun0 tun1 tun2; do ifconfig $arg 192.168.11.1/24; done
# route add 10/8 -iface 192.168.11.1 -ifp tun0
add net 10/8: gateway 192.168.11.1
# route add 172.16/12 -iface 192.168.11.1 -ifp tun1
add net 172.16/12: gateway 192.168.11.1
# route add 192.168.254/24 -iface 192.168.11.1 -ifp tun2
add net 192.168.254/24: gateway 192.168.11.1
# route show -inet
Routing tables
Internet:
Destination Gateway Flags Refs Use Mtu Prio
Iface
10/8 192.168.11.1 GS 0 0 - 8 tun0
localhost localhost UHl 0 22 32768 1 lo0
172.16/12 192.168.11.1 S 0 0 - 8 tun1
192.168.11.1 192.168.11.1 UHhl 1 4 - 1 tun0
[...my real routes omitted...]
192.168.254/24 192.168.11.1 S 0 0 - 8 tun2
Run Code Online (Sandbox Code Playgroud)
如果您的目标路由重叠,那么您可以使用pf和路由标签来匹配,或路由域。
归档时间: |
|
查看次数: |
1628 次 |
最近记录: |