Sign up ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

I have to connect to two OpenVPN servers at once. How do I configure NetworkManager to connect as a client to both?

           -- <OpenVPN1> -- <Resource 1>
<laptop> -
           -- <OpenVPN2> -- <Resource 2>
share|improve this question
This looks like a duplicate of… –  msbrown Dec 20 '13 at 15:30
Yes, it looks so. And the answer there worked for me. Instead of opening the Network Manager, open System Settings -> Network. Multiple VPNs can be checked ON. –  Ferdinand Prantl May 31 '14 at 11:44

1 Answer 1

up vote 1 down vote accepted

I think it is impossible using only Network Manager. But you can use a little trick:

First export your OpenVPN2 settings from Network Manager to some file, say ovpn2.conf.

Find your OpenVPN1 connection UUID:

nmcli con

Write script below, and put it under /etc/NetworkManager/dispatcher.d/, say two_vpn


interface=$1 status=$2
case $status in
      if [ $VPN_UUID == $CONNECTION_UUID ]; then
        # connect your second OpenVPN2 using .conf file:
        openvpn --config $CONF_FILE

  down| vpn-down)
      if [ $VPN_UUID == $CONNECTION_UUID ]; then
        # close your second OpenVPN2
        pid=$(ps -ef | grep "[o]penvpn --config $CONF_FILE" | awk '{ print $2 }')
        kill $pid > /dev/null 2>&1

Don't forget to give chmod +x /etc/NetworkManager/dispatcher.d/two_vpn

That's it, now you only need to connect OpenVPN1, and OpenVPN2 will connect automatically. Also if you close OpenVPN1, OpenVPN2 will close.

Please let me know if something goes wrong, because I did not test script

share|improve this answer

Your Answer


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.