Split tunneling through two VPNs simeltaneously

I want to run two OpenVPN client instances on an Ubuntu Server 14.04. I have both .conf files that can work independently (both are set to different interfaces - tun0 and tun1). I want to run both at the same time, and route traffic from one application into one VPN (Private Internet Access) and all other traffic into the other VPN (An OpenVPN server I have set up on another machine).

I've been doing some research but haven't found a way to make this work. If this helps, I've included my current routing table and one of the server .confs. OpenVPN starts them automatically on boot.

Private Internet Access .conf

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         10.160.1.5      128.0.0.0       UG    0      0        0 tun0
default         155.92.105.254  0.0.0.0         UG    0      0        0 eth0
10.160.1.1      10.160.1.5      255.255.255.255 UGH   0      0        0 tun0
10.160.1.5      *               255.255.255.255 UH    0      0        0 tun0
64-237-37-119.c 155.92.105.254  255.255.255.255 UGH   0      0        0 eth0
128.0.0.0       10.160.1.5      128.0.0.0       UG    0      0        0 tun0
155.92.104.0    *               255.255.254.0   U     0      0        0 eth0

Solution 1:

You need to add routes for your applications via the tunnels.

For example, if application A is at 10.70.82.5, and you want to route application A via Private Internet Access, you should run this command:

route add 10.70.82.5 gw "IP address of gateway at PIA"

Then, to route all other traffic via other VPN, you need to do two things:

  1. Route traffic to the other VPN server via your normal default gateway

    route add "IP address of other VPN server" gw 155.92.105.254

Here I assume this is your normal default gateway, based on your routing table in your post.

  1. Make a default route via other VPN server gateway

    route add default gw "Other VPN server gateway IP"

Remember that both OpenVPN servers need to do NAT in order for return packets to arrive correctly via the VPN.