Initially my routing table looks like this

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface         UG    600    0        0 wlp3s0     U     1000   0        0 wlp3s0   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         UG    600    0        0 wlp3s0
X.X.X.X UH    50     0        0 vpn0
X.X.X.X 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[1079]: <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
  • ip addr flush dev vpn0 should be useful. – Rui F Ribeiro Jan 6 at 0:15
  • It removes all automatically added routes but still can't add default route manually. – DimaRUS Jan 6 at 14:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.