Routing traffic to a local LAN address when reachable, otherwise using WireGuard VPN
0
votes
1
answer
397
views
I have a WireGuard VPN set up that uses the 10.20.30.0/24 IP range. I want to configure routing on my laptop so that traffic to 10.20.30.xy is routed through 192.168.99.xy whenever the latter is reachable on the local network. If the local address isn’t reachable, I want the traffic to be routed through the WireGuard tunnel as usual.
I understand that I can get about 80% of the way there by using a script triggered by NetworkManager whenever I connect to the local network. The script would simply add the necessary routes using:
Is there a simple way to handle this automatically, accounting for local network reachability? I’m also wondering if there might be a solution using OSPF or another dynamic routing protocol that could automatically detect reachability and adjust the routing accordingly.
EDIT: I am not opposed to making a /32 route for each of my devices (there aren't that many of them). I can also adjust my network topology - making a new prefix for switched devices would definitely be an option for me.
Asked by Jan Buchar
(101 rep)
Oct 5, 2024, 12:11 PM
Last activity: Oct 10, 2024, 03:09 PM
Last activity: Oct 10, 2024, 03:09 PM