0

I subscribe to a VPN service that allows up to 6 simultaneous OpenVPN connections to their servers located in various geographic locations.

I'd like to have 2 OpenVPN connections open on my local Linux machine at the same time:

  • 1 connection to their New York server
  • 1 connection to their Los Angeles server

The problem is that this provider often pushes both connections the exact same local IPv4 address (usually something like 10.5.0.X). This situation creates a routing conflict that causes one of the OpenVPN connections to be unusable.

How can I override an assigned, conflicting local IP address and request (or choose one) that is not conflicting?

Example client config:

client
dev tun
proto tcp
remote xxx.xxx.xxx 443
cipher AES-256-CBC
resolv-retry 5
nobind
persist-key
persist-tun
comp-lzo
verb 3
route-noexec
ping 10
ping-restart 60
sndbuf 524288
rcvbuf 524288
auth-user-pass /path/to/creds.txt
ca xxx.crt
crl-verify xxx.pem
tls-cipher TLS-DHE-RSA-WITH-AES-256-GCM-SHA384:TLS-DHE-RSA-WITH-AES-256-CBC-SHA
script-security 2
remote-cert-tls server
route-up /path/to/vpnroute.sh

vpnroute.sh script (copied from this answer):

#!/bin/sh
RULE_EXIST=$(/sbin/ip rule list | grep "from ${ifconfig_local}" | wc -l)
if [ $RULE_EXIST -ne 0 ]; then
  # conflicting rule detected, remove the original rule
  /sbin/ip rule del from "${ifconfig_local}" lookup "${dev}"
fi
/sbin/ip rule add from "${ifconfig_local}" lookup "${dev}"
/sbin/ip route add default via "${route_vpn_gateway}" dev "${dev}" table "${dev}"

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.