Back to Home

We configure two simultaneous VPN connections in Linux (for access to the Internet and for access to local ISP resources)

linux for all · linux · vpn · routing · ubuntu

We configure two simultaneous VPN connections in Linux (for access to the Internet and for access to local ISP resources)

    Having connected to a new provider providing access to the network via VPN, I had to deal with a bunch of mans and faxes on the topic of raising two simultaneously working VPN connections in lines. I raised it in ubunt 9.10 and decided to somehow compile the info into one I hope an understandable fact.

    This FAQ will be useful for those who want to configure two simultaneous VPN connections for a local and external network.


    First you need to download a package that will provide support for the connection protocol we need, for this we will enter in the terminal:

    sudo apt-get install pptp-linux

    After the package is installed, go write the connection config to the / etc / ppp / peers folder, for this we need admin rights (if they are not already), for convenience I will write a standard terminal input with the necessary rights in the nano terminal editor to the connection configuration file that is created:

    sudo nano / etc / ppp / peers / connection_name1

    Where connection_name1 is the name of the connection being created ( You can name it as you like).
    Next, enter the connection data into the editing window:

    pty “pptp vpn.isp.ru --nolaunchpppd”
    user “your login”
    password “your password”
    unit 0
    nodeflate
    nobsdcomp
    noauth
    replacedefaultroute
    defaultroute
    persist
    maxfail 0


    Where vpn.isp.ru- vpn-server for access to the Internet of your provider, and login and password for access to the Internet.
    Press ctrl + x , then confirm the save with the Y key .
    So, the first config is ready, then we write the second one for the local connection:

    sudo nano / etc / ppp / peers / connection_name2

    Where, again, you can create your own name =)
    There we write:

    pty "pptp vpnx.isp.ru --nolaunchpppd"
    user " your login "
    password" your password "
    unit 1
    lock
    nodeflate
    nobsdcomp
    noauth
    persist
    maxfail 0


    Where is vpnx.isp.ru- vpn-server for access to the local environment of your provider, and login and password also for local access.
    Save the whole thing ctrl + x , then the Y .

    Configs are ready.
    Now configure autorun and routing to LAN.
    To do this, edit / etc / network / interfaces :

    auto lo
    iface lo inet loopback

    auto eth0
    iface eth0 inet dhcp
    'up route add -net 10.0.0.0 netmask 255.0.0.0 gw 10.66.6.1

    auto connection_name1
    iface connection_name1 inet ppp
    provider connection_name1

    auto connection_name2
    iface connection_name2 inet ppp
    provider connection_name2


    Here you can enter routes for accessing resources directly through an existing connection (without VPN). I commented out an example of such a route, so when adding a route you will have to remove the " ' " symbol from this config.
    Where in place 10.66.6.1 should be your local gateway.
    Next, let's write route scripts for connection_name2 .
    We need to create /etc/ppp/ip-up.d/route
    We write in the terminal:

    sudo nano /etc/ppp/ip-up.d/route

    We write in the opened editor routes like:

    #! / Bin / sh
    ip route add 10.200 .0.0 / 16 dev ppp1


    Where ppp1 - link to connection connection_name2
    Click+ x ctrl , then confirm the settings key the Y .

    Then we make this script executable, for this we write in the terminal:

    sudo chmod + x /etc/ppp/ip-up.d/route

    Next you need to create a script to delete routes.
    Write in a terminal:

    sudo nano /etc/ppp/ip-down.d/route

    write in the opened editor:

    ! # / Bin directory / sh
    the ip route the add default gw dev eth0


    We press ctrl + x , then confirm the settings key the Y .

    Then we make this script executable, for this we write in the terminal:

    sudo chmod + x /etc/ppp/ip-down.d/route

    Everything, now we write the network restart command in the terminal:

    sudo /etc/init.d/networking restart

    And now the Internet is configured, routes are registered. The ultimate goal is achieved.
    I hope I haven’t forgotten anything.

    Read Next