Follow these steps in order to install OpenVPN 3 Client on Linux for Debian and Ubuntu:

Open the Terminal by pressing:

ctrl + alt + T

Type the following command into the Terminal:

sudo apt install apt-transport-https

This is done to ensure that your apt supports the https transport. Enter the root password as prompted.

Type the following command into the Terminal:

sudo wget https://swupdate.openvpn.net/repos/openvpn-repo-pkg-key.pub

This will install the OpenVPN repository key used by the OpenVPN 3 Linux packages.

Type the following command into the Terminal:

sudo apt-key add openvpn-repo-pkg-key.pub

Type the following command into the Terminal:

sudo wget -O /etc/apt/sources.list.d/openvpn3.list https://swupdate.openvpn.net/community/openvpn3/repos/openvpn3-jammy.list

Type the following command into the Terminal:

sudo apt update

Type the following command into the Terminal:

sudo apt install openvpn3

This will finally install the OpenVPN 3 package.

How to use OpenVPN 3 Linux

Using openvpn2

For users familiar with the classic OpenVPN 2.x command line, the openvpn2 front-end aims to be fairly close to old behavior.

$ openvpn2 --config ${MY_CONFIGURATION_FILE}

Replace ${MY_CONFIGURATION_FILE} with the OpenVPN configuration file you want to use.

If this configuration includes the –daemon option, the VPN session will be started in the background and the user is given the command line back again. To further manage this VPN session, the openvpn3 session-manage command line interface must be used.

Without –daemon the console will be filled with log data from the VPN session and the session can be disconnected via a simple CTRL-C in the terminal.

For more information, see openvpn2 –help, openvpn3 session-manage –help as well as the ​openvpn2 and ​openvpn3-session-manage man pages.

Using openvpn3

For more advanced usage, the openvpn3 command line offers a lot more features. Configuration profiles in OpenVPN 3 Linux are managed by a ​Configuration Manager before the VPN session is started via the ​Session Manager. The openvpn3 utility gives access to the features these manager services provides.

Starting a one-shot configuration profile

A “one-shot configuration profile” means that the configuration file is parsed, loaded and deleted from the the configuration manage as soon as the VPN session has been attempted started. No configuration file is available for re-use after this approach. This is achieved by giving the configuration file to the openvpn3 session-start command directly.

$ openvpn3 session-start --config ${MY_CONFIGURATION_FILE}

Importing a configuration file for re-use and starting a VPN session
Using this approach, an imported configuration file can be used several times and access to the configuration file itself is not needed to start VPN tunnels. By default, configuration profiles imported are only available to the user who imported the configuration file. But OpenVPN 3 Linux also provides an Access Control List feature via ​openvpn3 config-acl to grant access to specific or all users on the system.

$ openvpn3 config-import --config ${MY_CONFIGURATION_FILE}

This loads the configuration profile and stores it in memory-only. That means, if the system is rebooted, the configuration profile is not preserved. If the –persistent argument is added to the command line above, the configuration profile will be saved to disk in a directory only accessible by the openvpn user. Whenever the ​Configuration Manager is started, configuration files imported with –persistent will be automatically loaded as well.

To list all available configuration profiles, run this command:

$ openvpn3 configs-list

A configuration file typically contains generic options to be able to connect to a specific server, regardless of the device itself. OpenVPN 3 Linux also supports setting more host-specific settings on a configuration profile as well. This is handled via the ​openvpn3 config-manage interface. Any settings here will also be preserved across boots if the configuration profile was imported with the –persistent argument.

Starting a new VPN session from an imported configuration profile
When a configuration profile is available via openvpn3 configs-list, it can easily be started via openvpn3 session-start using the configuration profile name (typically the filename used during the import)

$ openvpn3 session-start --config ${CONFIGURATION_PROFILE_NAME}

or it is possible to use the D-Bus path to the configuration profile:

$ openvpn3 session-start --config-path /net/openvpn/v3/configuration/openvpn.ovpn

In either of these cases is it necessarily to have access to the configuration profile on disk. As long as configuration profiles are available via openvpn3 configs-list, all needed to start a VPN session should be present.

Managing a running VPN session
Once a VPN session has started, it should be seen in ​openvpn3 sessions-list:

$ openvpn3 sessions-list

Using the openvpn3 session-manage there are a few things which can be done, but most typically it is the –disconnect or –restart alternatives which is most commonly used.

$ openvpn3 session-manage --config ${CONFIGURATION_PROFILE_NAME} --restart

This disconnects and re-connects to the server again, re-establishing the connection. The ${CONFIGURATION_PROFILE_NAME} is the configuration name as displayed in openvpn3 sessions-list. It is also possible to use the D-Bus path to the session as well:

$ openvpn3 session-manage --session-path /net/openvpn/v3/sessions/….. --disconnect

This command above will disconnect a running session. Once this operation has completed, it will be removed from the openvpn3 sessions-list overview.

It is also possible to retrieve real-time tunnel statistics from running sessions:

$ openvpn3 session-stats --config ${CONFIGURATION_PROFILE_NAME}
$ openvpn3 session-stats --session-path /net/openvpn/v3/sessions/…..

And to retrieve real-time log events as they occur, run the ​openvpn3 log command line below:

$ openvpn3 log --config ${CONFIGURATION_PROFILE_NAME}

This might be quite silent, as it does not provide any log events from the past. Issue an openvpn3 session-manage –restart from a different terminal, and log events will occur. You may want to boost the log-level with –log-level 6. Valid log levels are from 0 to 6, where 6 is the most verbose.

Note that the maximum log level is configured centrally. If you don’t get more output with higher log levels increase maximum log level first with ​openvpn3-admin (note that this command needs to be executed as root):

# openvpn3-admin log-service --log-level 6

VPN sessions are also owned by the user which started it. But the ​Session Manager also provides its own Access Control List feature via ​openvpn3 session-acl.

TECH-PREVIEW: OpenVPN Data Channel Offload – kernel module support
As of v11_beta, the OpenVPN 3 Linux client ships with Data Channel Offload (DCO) support. This is only supported on a selected list of Linux distributions, please see the distribution table earlier on this page for details.

To enable it, first install the kmod-ovpn-dco package from the software repositories described on this page.

Ubuntu preparation

# apt install kmod-ovpn-dco
Fedora preparation
# yum install kmod-ovpn-dco

Enable DCO on a VPN configuration profile
Now the OpenVPN configuration file must be pre-imported and the DCO mode must be activated:

$ openvpn3 config-import --config CONFIG_FILE --name CONFIG_NAME --persistent
$ openvpn3 config-manage --show --config CONFIG_NAME --dco true

And now a VPN session with DCO activated can be started as any normal VPN session:

$ openvpn3 session-start --config CONFIG_NAME

Start a VPN session directly with DCO enabled

Using the openvpn2 command line:

$ openvpn2 --config CONFIG_FILE --enable-dco

Using the openvpn3 command line:

$ openvpn3 session-start --config CONFIG_NAME --dco true

If the configuration profile is pre-imported and configured to use DCO by default, you can temporarily disable that by adding –dco false instead.

Create a bash script.

nano openvpn_connect.sh

#!/bin/bash
openvpn3 session-start --config configfile.ovpn

Make it executable:

chmod +x openvpn_connect.sh

Execute from command line:

./openvpn_connect.sh

Installing and configuring an OpenVPN server manually is not a simple task from my experience. For this reason, we will be using a script that lets you set up your own secure OpenVPN server in a matter of seconds.

Before downloading and running the script, note that the script will auto-detect your server’s private IP address. But you need to take note of your server public IP address especially if it is running behind NAT.

To find out your server’s public IP address, run the following wget command or dig command.

wget -qO - icanhazip.com

Or Dig.

Install DNSUtils

apt install dnsutils 
dig +short myip.opendns.com @resolver1.opendns.com

Now lets run the script (https://github.com/Nyr/openvpn-install)

wget https://git.io/vpn -O openvpn-install.sh && bash openvpn-install.sh

Output:

Welcome to this OpenVPN road warrior installer!

This server is behind NAT. What is the public IPv4 address or hostname?
Public IPv4 address / hostname [233.xxx.xxx.112]:

Which protocol should OpenVPN use?
   1) UDP (recommended)
   2) TCP
Protocol [1]: 1

What port should OpenVPN listen to?
Port [1194]:

Select a DNS server for the clients:
   1) Current system resolvers
   2) Google
   3) 1.1.1.1
   4) OpenDNS
   5) Quad9
   6) AdGuard
DNS server [1]: 3

Enter a name for the first client:
Name [client]: user1

OpenVPN installation is ready to begin.
Press any key to continue...
Hit:1 http://cdn-aws.deb.debian.org/debian bullseye InRelease
Hit:2 http://cdn-aws.deb.debian.org/debian bullseye-updates InRelease
Hit:3 http://cdn-aws.deb.debian.org/debian bullseye-backports InRelease
Hit:4 http://security.debian.org/debian-security bullseye-security InRelease
Reading package lists... Done
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
ca-certificates is already the newest version (20210119).
openssl is already the newest version (1.1.1n-0+deb11u3).
openssl set to manually installed.
Suggested packages:
  resolvconf openvpn-systemd-resolved
Recommended packages:
  easy-rsa
The following NEW packages will be installed:
  liblzo2-2 libpkcs11-helper1 openvpn
0 upgraded, 3 newly installed, 0 to remove and 0 not upgraded.
Need to get 703 kB of archives.
After this operation, 1990 kB of additional disk space will be used.
Get:1 http://cdn-aws.deb.debian.org/debian bullseye/main amd64 liblzo2-2 amd64 2.10-2 [56.9 kB]
Get:2 http://cdn-aws.deb.debian.org/debian bullseye/main amd64 libpkcs11-helper1 amd64 1.27-1 [                                                                                                                                              47.5 kB]
Get:3 http://cdn-aws.deb.debian.org/debian bullseye/main amd64 openvpn amd64 2.5.1-3 [599 kB]
Fetched 703 kB in 0s (23.7 MB/s)
Preconfiguring packages ...
Selecting previously unselected package liblzo2-2:amd64.
(Reading database ... 30816 files and directories currently installed.)
Preparing to unpack .../liblzo2-2_2.10-2_amd64.deb ...
Unpacking liblzo2-2:amd64 (2.10-2) ...
Selecting previously unselected package libpkcs11-helper1:amd64.
Preparing to unpack .../libpkcs11-helper1_1.27-1_amd64.deb ...
Unpacking libpkcs11-helper1:amd64 (1.27-1) ...
Selecting previously unselected package openvpn.
Preparing to unpack .../openvpn_2.5.1-3_amd64.deb ...
Unpacking openvpn (2.5.1-3) ...
Setting up liblzo2-2:amd64 (2.10-2) ...
Setting up libpkcs11-helper1:amd64 (1.27-1) ...
Setting up openvpn (2.5.1-3) ...
Created symlink /etc/systemd/system/multi-user.target.wants/openvpn.service → /lib/systemd/syst                                                                                                                                              em/openvpn.service.
Processing triggers for man-db (2.9.4-2) ...
Processing triggers for libc-bin (2.31-13+deb11u5) ...
..........................+++++
...............+++++
Generating a RSA private key
....................+++++
.....................................................+++++
writing new private key to '/etc/openvpn/server/easy-rsa/pki/685ac808/temp.d98e14bd'
-----
Using configuration from /etc/openvpn/server/easy-rsa/pki/685ac808/temp.ac88dfea
Check that the request matches the signature
Signature ok
The Subject's Distinguished Name is as follows
commonName            :ASN.1 12:'server'
Certificate is to be certified until Nov 14 00:34:28 2032 GMT (3650 days)

Write out database with 1 new entries
Data Base Updated
Generating a RSA private key
.................................+++++
..........................+++++
writing new private key to '/etc/openvpn/server/easy-rsa/pki/3e0fbb2b/temp.3a3753f7'
-----
Using configuration from /etc/openvpn/server/easy-rsa/pki/3e0fbb2b/temp.863607a1
Check that the request matches the signature
Signature ok
The Subject's Distinguished Name is as follows
commonName            :ASN.1 12:'user1'
Certificate is to be certified until Nov 14 00:34:29 2032 GMT (3650 days)

Write out database with 1 new entries
Data Base Updated
Using configuration from /etc/openvpn/server/easy-rsa/pki/e0fdb7ad/temp.8b5b7aba
2022-11-17 00:34:29 WARNING: Using --genkey --secret filename is DEPRECATED.  Use --genkey secr                                                                                                                                              et filename instead.
Created symlink /etc/systemd/system/multi-user.target.wants/openvpn-iptables.service → /etc/sys                                                                                                                                              temd/system/openvpn-iptables.service.
Created symlink /etc/systemd/system/multi-user.target.wants/openvpn-server@server.service → /li                                                                                                                                              b/systemd/system/openvpn-server@.service.

Finished!

The client configuration is available in: /root/user1.ovpn
New clients can be added by running this script again.

Now that the server is installed, download openVPN.

Download the OPVN file and connect.