After searching far and wide for a comprehensive answer and trying out multiple solutions which didn't work I am turning to the community.

I am using a VPN connection to access certain network resources (mainly testbeds) and they are all on the network range. However, when I connect to the VPN all of my traffic is routed trough the VPN and not just the requests to those ip addresses. My goal is to route traffic like Youtube, Google Play and so on over my internet and not over the VPN internet. Mainly because the speed is very bad going over the VPN.

I have tried checking the options in the network manager setting to use the VPN only for the resources on the network but this does not work.

I have also tried playing around with my routing tables but to no success.

I would appreciate any help in this regard. I am using Ubuntu 16.04 with Gnome. Here are some network stats:

netstat -rn
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface         U         0 0          0 ppp0         UG        0 0          0 enp4s0 UH        0 0          0 ppp0     U         0 0          0 enp4s0   U         0 0          0 enp4s0 UGH       0 0          0 enp4s0

1 Answer 1


I managed to solve it.

First I increased the metric of the default gateway route to 1 so that all my traffic goes trough that.

sudo ifmetric enp4s0 1

After that I added a new route for the 10.x.x.x subnetwork

sudo ip route add dev ppp0 metric 25

this now allows me to access all vpn network resources and use my local internet connection for everything else.

I also added a script into /etc/network/if-up.d/ that automatically does this every time I connect to the vpn.


if [ "$IFACE" = "ppp0" ]; then
     ifmetric enp4s0 1
     ip route add dev ppp0 metric 25

Where ppp0 is the interface name of my vpn connection. And the routing table in the end looks like this:

Kernel IP routing table

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface         UG    1      0        0 enp4s0         U     50     0        0 ppp0       U     25     0        0 ppp0 UH    50     0        0 ppp0     U     1      0        0 enp4s0   U     1      0        0 enp4s0 UGH   1      0        0 enp4s0
  • isn't there a UI-way of doing this?
    – Gewure
    Jun 9, 2018 at 13:43
  • Works perfect :) Dec 12, 2018 at 10:57
  • Although everything looks great, it works well only after running sudo ip route add via How could I add that to the if-up.d script, when the gateway address is always different ?
    – pLumo
    Apr 22, 2020 at 11:41

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.