0

I am connected to a VPN network through a pptp connection. The target network does not provide Internet access, thus I can't connect to it. How should I route my Internet traffic through my existing connection?

Below, are my existing routes

Destination     Gateway         Genmask         Flags Metric Ref   Use Iface
default         0.0.0.0         0.0.0.0         U     50     0        0 ppp0
default         _gateway        0.0.0.0         UG    20600  0        0 wlp4s0
link-local      0.0.0.0         255.255.0.0     U     1000   0        0 docker0
172.18.0.0      0.0.0.0         255.255.0.0     U     0      0        0 docker0
192.168.1.0     0.0.0.0         255.255.255.0   U     600    0        0 wlp4s0
_gateway        0.0.0.0         255.255.255.255 UH    600    0        0 wlp4s0
192.168.116.42  0.0.0.0         255.255.255.255 UH    50     0        0 ppp0
212.80.25.88    _gateway        255.255.255.255 UGH   0      0        0 wlp4s0
212.80.25.88    _gateway        255.255.255.255 UGH   600    0        0 wlp4s0
1

The answer is to setup a default route. I do this:

sudo ip route add default via 192.168.1.1 metric 40

where:

192.168.1.1 = local gateway (not VPN gateway)
metric 40 = Some metric that is lower than your existing default route

In simple steps:

  1. Without being on VPN use ip route and note the line beginning with default (proto, dhcp aren't important)
  2. Connect to VPN
  3. Use ip route add, then append the line you noted before, but make the metric lower than anything that may currently exist.

With this setup, I can access all intranet tools that would normally be available via a VPN, while diverting all internet traffic away from it.


Edit: I saw your updated routing table. 192.168.1.1 is probably the route you want, and metric 40 will work because it's lower than the default VPN route which is 50.

5
  • that metric does the trick. – Davood Falahati Aug 9 '20 at 20:42
  • Oops, I changed the routing and I have an access to internet. However, vpn network becomes inaccessible. – Davood Falahati Aug 9 '20 at 21:00
  • 1
    Do you know the IP range of your VPN stuff? Let's say it's 10.10.x.x. You could add a route with: sudo ip route add 10.10.0.0/16 via dev ppp0. Then anything within that IP range will be sent via your VPN. – Stewart Aug 10 '20 at 5:09
  • You can always ip route del X where X is the route printed when you type ip route – Stewart Aug 10 '20 at 5:10
  • your suggestion does the trick, but I made it in this way: sudo ip route add 10.10.0.0/16 dev ppp0 – Davood Falahati Dec 28 '20 at 6:35
2

Your VPN connection is overriding your default route (0.0.0.0/0), and most likely your DNS resolvers. You could suppress or override both those things and just have specific routes to the ranges you're interested in on the target network.

1
  • I have updated my question, would you please provide a more explicit solution? – Davood Falahati Aug 9 '20 at 18:51

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.