I'm using network-manager-openvpn to connect to my university VPN. The VPN works when I just run openconnect -u username vpn.host.edu from the commandline (although it spews a lot of ip route error messages).

However, when starting the VPN through the NetworkManager GUI, the resulting routing table is messed up:

$ ip route
default via dev enxXXXXXXXXXXXX
default dev vpn0 proto static scope link metric 50 
default via dev enxXXXXXXXXXXXX proto dhcp metric 20100 

The first entry causes all traffic to still be routed through the local gateway. Consequently, e.g. name resolution with the VPN DNS servers fails and the VPN is unusable. When I remove the first routing table entry with ip route del default via dev enxXXXXXXXXXXXX, then everything starts working as intended.

All network settings for the VPN connection are set to "Automatic", so why is the VPN entry not the first default route?

P.S. I know that there are workarounds described in Network Manager does not set IP4.GATEWAY for OpenVPN connection and Network Manager does not set IP4.GATEWAY for OpenVPN connection - but I would like to fix this without having to run a shell command everytime.


1 Answer 1


Yes, as usual, I found the (more or less) solution 5 minutes after posting the question :-/

It seems like this bug is related: https://gitlab.gnome.org/GNOME/NetworkManager-openconnect/-/issues/33#note_889793

The linked comment suggests using a script in /etc/network/if-up.d/ to fix the routes, I'm using this for now.

# Hacky workaround bug in NM not setting the default routes.
if [ "$IFACE" = "vpn0" ]; then
  #ip route replace default via dev vpn0
  ip route del default via dev enxXXXXXXXXXXXX

I'd still like to see this fixed without hacky scripts, but apparently, it's a known bug.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.