Initially my routing table looks like this
Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 192.168.1.1 0.0.0.0 UG 600 0 0 wlp3s0 169.254.0.0 0.0.0.0 255.255.0.0 U 1000 0 0 wlp3s0 192.168.1.0 0.0.0.0 255.255.255.0 U 600 0 0 wlp3s0
After I connect to company's network using VPN, server pushes some routes and table looks like this
Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 192.168.1.1 0.0.0.0 UG 600 0 0 wlp3s0 X.X.X.X 0.0.0.0 255.255.255.255 UH 50 0 0 vpn0 X.X.X.X 0.0.0.0 255.255.255.255 UH 50 0 0 vpn0 ........ and so on .....
I want to default all traffic via VPN and issue following commands
sudo route del default sudo route add default dev vpn0
they complete with no errors and in kern.log I see the following:
Jan 5 22:04:45 thinkpad NetworkManager: <info> [1546715085.3821] policy: set 'vpn0' (vpn0) as default for IPv4 routing and DNS
But no default route appears in table and ping says Network unreachable.
If I tick the option "ignore automatically obtained routes" finally after connection I get default route via vpn0. But I can't delete it (sudo route del default vpn0 in various combinations makes no sense).
The idea is that I want to route traffic via VPN or via WiFi on the fly and without disconnection. And wonder why I can't.
PS: I've tried all of this using ip route with the same effect
OpenVPN and kernel I have:
network-manager-openvpn/xenial-updates,now 1.1.93-1ubuntu1.1 amd64 [installed] openvpn/xenial-updates,xenial-security,now 2.3.10-1ubuntu2.1 amd64 [installed] Linux thinkpad 4.4.0-53-generic #74-Ubuntu SMP Fri Dec 2 15:59:10 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux