How to add route to local network in Linux even if VPN is active

If you route all your traffic via a VPN on Linux, you will typically not be able to access local networks except for the network which you are directly connected to via L2.

In order to fix this, you can simply add a route, which typically takes precedence over the VPN route even with additional options.

The following example will add a route to (local network) via the gateway=local router we’re connected via L2 to (

sudo ip route add via