0. Prerequisites
Req. 1: Linux Distro with Gnome 40.x installed.
Everything written below have been tested on Pop!_OS with Gnome 40.5. Pop!_OS is Ubuntu derivative, which is in turn Debian derivative. All those use the apt package manager to install deb packages. You should be able to apply this tutorial to any other distro, barring the standard differences to a terminal commands used (i.e. due to different package manager).
Req. 2: Access to VPN that provides you with ovpn config file and ovpn file downloaded and ready to use.
1. Install OpenVPN
We will install openvpn2 as well as a support for OpenVPN for Gnome.
There are multiple applications that will allow you to setup OpenVPN connection. Major VPN providers often recommend their own applications, but those tools often integrate poorly with Gnome environment since they target a lot of OSes and devices. We will be using Gnome's build-in VPN configuration for the best possible experience.
OpenVPN as well is available in two different versions: openvpn2 and openvpn3. The latter is successor to the former, but is yet to see a wide adoption. You are welcome to experiment with openvpn3, but at the moment of writing most distros come with openvpn2 and we will be using that.
To install the openvpn client and a support for OpenVPN for Gnome execute following in the terminal:
apt update && apt install network-manager-openvpn network-manager-openvpn-gnome openvpn
Then, restart Gnome by either relogging or pressing alt+F2 and typing 'r'.
Check if you managed to install OpenVPN support successfully. Open Settings > Networks and press "plus" next to the VPN header. You should see window with list of supported VPN types and OpenVPN should be on the list.
2. Import your VPN configuration
From the "Add VPN" window, select "Import from the file..." and choose the ovpn file for your VPN.
You should see configuration window. Likely it will be missing credentials for connection, so input the user/password if required.
On the VPN tab, next to the password, you will have an icon. When you click it, it will reveal options to store password in different way. By default, password is stored only for current user. If you want to be able to automatically connect to the VPN, make it available to all users and save changes (see step 3 below for information on why is it necessary).
Try connecting to your VPN manually, to make sure that the connection works as expected.
3. Configure your VPN to auto connect
For some reasons, Gnome does not expose the option to auto connect to your VPN in the settings menu. The software supports it, but for some reason it is obfuscated. To be able to configure it with GUI we will use a tool called nm-connection-editor.
Let's start it from a terminal:
nm-connection-editor
You should see the following window:
It presents the list of all connections available to NetworkManager. Your VPN should be visible there as well.
3.1 Configure interface to autostart VPN
Open a connection (inteface) you are normally using to connect to the Internet. In my case this would be "Wired connection 1".
On the General tab, select "Automatically connect to VPN" and select your VPN from the list.
Now, every time you connect to this connection, the VPN should start automatically.
Make your VPN connect at boot
There is one more thing we need to do, if we want PC to connect to VPN automatically at boot.
Let's go back to the list of connections and open the VPN configuration.
On the VPN tab, next to the password, you will have an icon. When you click it, it will reveal options to store password in different way. By default, password is stored only for current user. Make it available to all users and save changes.
We need that, since we intend to auto connect to VPN on startup. Our user is not logged in yet. System will use one of its defined users to establish a connection. Failing to make this change will result in VPN not connecting, because NetworkManager will not be able to retrieve your credentials. Since we modified our connection to always start with VPN, failing to connect to VPN will result with lack of internet connection when you login.
4. Restart and Testing
Now you can restart your PC. When you log in, you should be already connected to the VPN.
5. Does not work? Try to find what went wrong!
I hope everything went splendidly and you are enjoying your seamless VPN connection right now.
However, if something went awry and your VPN still do not connect automatically, you can start your diagnostic by investigating the NetworkManager log.
To access it enter in a terminal:
journalctl -u NetworkManager
Entries that you are looking for will likely be at the bottom. You can get there quickly by pressing END key on your keyboard.
Output of the log can help you or someone on the Internet to diagnose what went wrong.
Top comments (0)