I have multiple VPN connections which use the same gateway IP (I do not have the ability to change this as it is out of my control). These VPNs all provide access to different networks, and the networks are at least one or two hops upstream, so a gateway IP is required in all cases. With Linux, to route to the networks, I can simply do:
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
etc.
Linux will then place the traffic for each destination network onto the correct interfaces, headed for the correct gateway, so it doesn't matter that the gateway IP is the same for each interface.
My question is, how can I achieve this in OpenBSD? I have tried and failed. My findings are that for a particular destination, I can either:
- specify an interface (if the destination is directly reachable on that link - which it isn't in my case)
- specify a gateway IP because the destination is not directly on link
But I can't figure out how to specify both.
Use the -ifp modifier to route. From the man page:
So something like this works:
If your destination routes are overlapping then you can use pf and route labels to match, or routing domains.