Under Unity, Network Manger has a check box available for every connection that configures the automatic use of a VPN when the connection is active:

Picture of Connection setting in ubuntu 16.06 Unity

Is there a way to obtain an option like this in Ubuntu GNOME 16.04? (which uses GNOME 3.18). As the connection setting page lacks this option: enter image description here

  • Welcome to Ask Ubuntu! This answer suggests that they both share the same NetworkManager. Could you please double-check? In case they are different, could you also include a screenshot of the NetworkManager under Ubuntu GNOME? – Andrea Lazzarotto Aug 7 '16 at 10:46
  • @AndreaLazzarotto thanks! I provided the screen-shot. I will try vpnautoconnect that was suggested in This Question to see if it works. But I wonder if the setting could be activated in Network Manger itself since as you said it is the same Network Manger in both flavors. – S.Mohsen sh Aug 7 '16 at 11:08
  • This capability still appears to be missing in Ubuntu 17.04. I'm unclear why it would have been removed. After searching for a solution and finding very little, it seems odd that more people don't use VPNs and prefer the autoconnect feature. – Rsync Oct 9 '17 at 23:17
  • Provided that your system has a /etc/NetworkManager/system-connections directory populated with connection profiles and ya don't mind editing configs, then might be worth checking the answer I posted elsewhere on the topic of auto-connecting to a VPN for a given network interface. – S0AndS0 May 20 '19 at 22:25

I found the answer to this. Oddly, you have to open Network Manager manually (as opposed to using the panel or Settings.

So in Terminal type nm-connection-editor. After doing so, the window that opens will have the options in the OPs first image.

This works for me in 16.04 and 17.04. Hopefully, they will integrate the various network managers in upcoming versions of GNOME.

  • This works for me in 18.04 as well - thanks! It was not immediately clear where those settings were. – JohnnyCoder May 25 '18 at 14:30
  • Works also for Debian 9 Stretch. Thank you! – Christian Toffolo Nov 24 '18 at 10:14

I solved the problem with a script in


This folder contains scripts that are called in alphabetical order by the network manager every time there is a change in Network status. This has the advantage (different from another solution that I saw) that your VPN is not just activated at boot/startup, but also at resume after suspend/sleep.

For this to work you need a VPN connection that is already set up in your Network Manager, which I assume you have, otherwise you would not have asked the question.

  1. First Step: I followed the advice of this (German) page (https://wiki.ubuntuusers.de/NetworkManager/Dispatcher/). I opened and named a new script 02VPN1

    sudo YOURTEXTEDITOR /etc/NetworkManager/dispatcher.d/02VPN1

and wrote:

    if [ "$2" = "up" ]; then
       sleep "3s"
       nmcli con up id "${VPN_CONNECTION_NAME}"

The NAME_OF_YOUR_VPN_CONNECTION is the name of the connection file NAME_OF_YOUR_VPN_CONNECTION.conf that you used to set the connection up that you want to auto-connect to.

The condition if [ "$2" = "up" ] means that the VPN connection is only automatically connected to when you start the network connection (your Internet Connection); once the VPN service runs, you can disable it or choose another VPN.

If you only and every time want to run this VPN without the ability to disable it, you can write the script without this If-condition:

    sleep "3s"
    nmcli con up id "${VPN_CONNECTION_NAME}"

You can only set this file up as root, so it is owned by root without you doing anything in addition. That's how it should be.

Finally: Make this file executable, otherwise the script won't run. In Terminal:

    sudo chmod +x  /etc/NetworkManager/dispatcher.d/02VPN1
  1. Second Step (DIFFERENT from the instructions in the above link; I used the advice from here: https://ubuntuforums.org/showthread.php?t=2193559&p=12990193#post12990193

This process is run by root, and root does not yet have access to the password that you use for your VPN. Do the following: Open the file NAME_OF_YOUR_VPN_CONNECTION in /etc/NetworkManager/system-connections as root. Open a Terminal and do:

    sudo YOURTEXTEDITOR /etc/NetworkManager/system-connections/NAME_OF_YOUR_VPN_CONNECTION

a) Change the line




b) At the bottom, add


Save and close the file.

  1. Now restart your Network Manager. Terminal:

    systemctl restart NetworkManager

to initialize the new settings. You should be done.

I did this yesterday, and as far as I can see it works fine. No guarantees!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.