0

I have an OpenVPN setup on an Ubuntu 16 system. I have two VPN connections, one is through a VPN provider, so all traffic to the net has to go through that one. We'll call this VPN1.

The second one is a private OpenVPN server, so I can connect to my home server outside of the house through that VPN. We'll call this VPN2.

What I'm trying to do is allow all internet traffic through VPN1, at the same time connect to VPN2 but only route VPN2 traffic through it (IP range 10.8.0.0/24), effectively allowing me to connect to it outside of the house.

I've tried putting all config for both connections in the same .conf file, no go, this try didn't even start it errored out. I've also tried running VPN2 as a process instead of service, while VPN1 was running, no go, this just didn't connect to VPN2 at all, 1 took precedence.

How would I go about connecting two VPN connections at once, started through service, and routing all internet traffic through the first connection?

EDIT

VPN1 Config:

client
dev tun
proto udp
remote us-east.vpndomain.com 1198
resolv-retry infinite
nobind
persist-key
persist-tun
cipher aes-128-cbc
auth sha1
tls-client
remote-cert-tls server
auth-user-pass auth.txt
comp-lzo
verb 1
reneg-sec 0
crl-verify crl.rsa.2048.pem
ca ca.rsa.2048.crt
disable-occ
redirect-gateway def1

VPN2 Config:

remote {privateVPN-IP}
comp-lzo
dev tun
auth-user-pass /etc/openvpn/ovpn.txt
ca /etc/openvpn/ca.crt
client

route 0.0.0.0 192.0.0.0 net_gateway
route 64.0.0.0 192.0.0.0 net_gateway
route 128.0.0.0 192.0.0.0 net_gateway
route 192.0.0.0 192.0.0.0 net_gateway

This is done as a service running openvpn from system start as daemon.

EDIT2

I've tested just now removing the bottom part of VPN2 config, the net_gateways. Strangely it works if I start VPN2 first, then start VPN1. But if VPN1 gets started first then VPN2 won't work.

Also, after a few minutes of both being open VPN1 seems to strangely shutdown with an AUTH failure error.

Right before it disconnects from VPN1 I get this error:

ERROR: Linux route add command failed: external program exited with error status: 2

8
  • First of all: What you want es entirely possible and easy to achieve. Difficulties may only arise with how you manage those OpenVPN connections (please elaborate how you’re currently doing it: services? Network Manager? Something else?) and with subtle configuration errors. Please provide both configuration files. If there are any embedded keys (big base64 blocks) absolutely remove them.
    – Daniel B
    Aug 29, 2018 at 16:58
  • Conf files posted as edits.
    – jfreak53
    Aug 30, 2018 at 1:17
  • Why are you trying to create your own redirect-gateway def2 in the VPN2 config? This would override VPN1 completely! // After connecting to both networks manually (openvpn --config ...) run ip addr and ip route and provide the output. // By service, do you mean the service that ships with the OpenVPN package in Ubuntu?
    – Daniel B
    Aug 30, 2018 at 11:23
  • systemd services, starts at boot for VPN1
    – jfreak53
    Aug 30, 2018 at 12:43
  • I'm sorry, but redirect-gateway def2 is not in VPN2 Config, redirect-gateway def1 is in VPN1 config.
    – jfreak53
    Aug 30, 2018 at 12:44

0

You must log in to answer this question.

Browse other questions tagged .