Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I often work remotely. I use the Network Manager to set up my VPN connection, which has worked pretty well. The VPN I have set up currently using the Password with Certificates (TLS) type. What I want to do is only route certain traffic through the VPN, and all other traffic over the normal local internet connection.
Is this possible?

Just to help explain my situation I will give an example of the type of connections I usually have to make with the VPN network. We have an "intranet" web site set up on our work network, so this web site is only accessible to me when I use VPN, but is accessed the same way I access other sites, like Google or askubuntu.com. I often connect to a desktop computer over the VPN connection via remote desktop, where I enter the name )IP Address) of the desktop computer, username, and password. I connect to a MySQL server using MySQL Workbench, where you enter an IP address, username and password. I often connect to linux servers using SSH.

For all of the above connections I need the VPN. However I also do some normal web surfing, as well as connecting to resources outside of the work network (Gmail, Stack Overflow, Gaming, etc.). For these connections I wish not to access via the VPN connection because these connections do not need my VPN, the VPN just makes this much slower.

I have tried the technique describe in this link: http://darrenwatt.com/split-tunnel-ubuntu/

This did not seem to work for me. Specifically, I couldn't connect to the "intranet" site after checking the "Use this connection only for resource on its network" check box and connection the VPN.

Does anyone know how I can selectively route traffic through the VPN? Does this make sense?

Thanks!!

share|improve this question

1 Answer 1

I don't know how this work with NM but I write script

#!/bin/bash
function routeadd {
    route add -host xxx.xxx.xxx.xxx dev ppp0
    route add -net xxx.xxx.xxx.xxx/xx dev ppp0
}
function makepptp {
   echo pty \"pptp xxx.xxx.xxx.xxx --nolaunchpppd\" >> /etc/ppp/peers/vpn;
   echo remotename PPTP >> /etc/ppp/peers/vpn;
   echo require-mppe-128 >> /etc/ppp/peers/vpn;
   echo file /etc/ppp/options.pptp >> /etc/ppp/peers/vpn;
   echo ipparam vpn >> /etc/ppp/peers/vpn;
pppd call vpn &
}
if [ -a /etc/ppp/chap-secrets ];
        then
        rm /etc/ppp/chap-secrets
    echo $1 PPTP $2 '*' >> /etc/ppp/chap-secrets;
else
    echo $1 PPTP $2 '*' >> /etc/ppp/chap-secrets;
fi

if [ -e /etc/ppp/peers/vpn ];
    then
    rm /etc/ppp/peers/vpn;
    echo name $1 >> /etc/ppp/peers/vpn;
    makepptp;
    sleep 8;
    routeadd;
else
    echo name $1 >> /etc/ppp/peers/vpn;
    makepptp;
    sleep 8;
    routeadd;
fi

Usage:

sudo /path_to_script/vpn username password

note: set execute permision to script

Traffic is routed via vpn only if you add route, anything else go default gw.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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