How do I setup Ubuntu/Linux's Network manager to selectively route network traffic through the VPN?

18

19

I'm using Ubuntu 9.04 and I just noticed that ALL of my network traffic is being routed through my VPN. I would like the VPN to route only the traffic hitting servers on the VPN and then connect directly to anywhere else on the internet as needed. The VPN is PPTP VPN that is run using some sort of Microsoft stack.

Results from route command:

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
102-102-152-203 192.168.24.1    255.255.255.255 UGH   0      0        0 wlan0
192.168.24.0    *               255.255.255.0   U     2      0        0 wlan0
link-local      *               255.255.0.0     U     1000   0        0 wlan0
default         *               0.0.0.0         U     0      0        0 ppp0

Elijah

Posted 2009-07-20T21:45:28.957

Reputation: 465

You may be able to do something with your routing table.

Would you mind running 'route' from your command line when you're connected to the VPN and putting the output up here? – Mark Turner – 2009-07-20T22:00:49.420

Answers

19

For my Cisco Compatible VPN in Ubuntu 9.04 (VPNC), there is a check box to select.

Edit your connections, go to the VPN tab, and edit the VPN configuration.

Go to the IPv4 Settings tab, and in the bottom right is a button "Routes".

Click the button and check the box "Use this connection only for resources on its network"

As others have mentioned, there are text based configuration files one can alter instead of using the GUI. One nice thing about GUIs is that you don't have to memorize all the possible values or worry about spelling

pcapademic

Posted 2009-07-20T21:45:28.957

Reputation: 3 283

@cc4re seems to me that it is adding never-default=true to the [ipv4] section in ubuntu 18.04 – Tarick Welling – 2020-02-04T15:15:09.470

2can you give a reference of how to do it in command line - i mean "Use this connection only for resources on its network" – cc4re – 2014-01-11T07:11:55.640

10

Thanks to the advice in the above answers and a bit of searching on my own, I was able to find the answer to my own question.

First, I determined what ip address ranges were being used on the VPN, in my case 192.168.32.* and 192.168.16.*. Then I connected to my vpn normally and sshed to a server on the network. I ran route on that machine and got the gateway address and metric being used. Then I added routes for the two ip address ranges to the routes field in the IPv4 settings tab and clicked on "Use this connection only for resources on its network" and "Ignore automatically obtained routes". Then poof like magic it worked.

Thank you all for your help!

Elijah

Posted 2009-07-20T21:45:28.957

Reputation: 465

Thank you! I've been trying to do this for ages. I also had to set the "Method" to be "Automatic (VPN) addresses only", and left the DNS servers and search domain blank. – Timmmm – 2011-05-10T12:58:38.057

3

If you want to do a block edit, export or simply a backup the details are in this folder /etc/NetworkManager/system-connections/

To apply changes if any you should do

sudo NetworkManager stop
sudo NetworkManager start

Jaime Agudo

Posted 2009-07-20T21:45:28.957

Reputation: 143

0

I'm assuming the pptp software is setting your default route to ppp0.

You can either tweak your routes after your connection

or

you could try removing the 'defaultroute' directive from the pptp config file (possibly /etc/ppp/ppp.conf)

Mark Turner

Posted 2009-07-20T21:45:28.957

Reputation: 901