How to setup OpenVPN on Ubuntu 20.04?

Overview

OpenVPN is a popular, open-source, and rapid VPN (Virtual Private Network) creation tool. The OpenVPN protocol secures VPN tunnels with TLS/SSL authentication, credentials, and certificates, and, for an extra cost, MAC address encryption and multi-factor authorization, and the TCP and UDP are used for communication.

A variety of software and hardware is compatible with it. It has a customer-centric design, as with most VPN protocols. Linux-based hardware powers the OpenVPN access server, while clients can be installed on Windows, macOS, other Linux systems, and mobile operating systems including Windows, Android, and iOS.

The OpenVPN class can be used by clients that want to create an outgoing VPN connection using OpenVPN Connect or other free, open-source software that is compatible with OpenVPN.

In this tutorial, you will learn how to set up an OpenVPN on Ubuntu version 20.04 and connect VPN clients from various Linux distributions.

Prerequisites

  • Ubuntu 22.04-equipped system

  • A regular root user

  • Internet connection

Get Started

Step 1: Ubuntu OpenVPN Server Configuration

We'll be utilizing a script that enables you to quickly set up your very own secure OpenVPN server.

Be aware that the script will automatically detect the private IP address of your server before downloading and running it.

  • Use the wget command to find your server's public IP address.

wget -qO - icanhazip.com
  • By using curl command-line tool, acquire the installer script now, and then use the chmod command to execute the script.

curl -O https://raw.githubusercontent.com/angristan/openvpn-install/master/openvpn-install.sh
chmod +x openvpn-install.sh

This script will prompt you with some questions when it runs for the very first time, read them thoroughly, and then provide responses based on your preferences to configure your OpenVPN server.

After the VPN installation is finished, a system configuration file will be created under the currently active working directory. This is the file that you will use to set up your OpenVPN client according to the instructions in the following section.

  • Next, verify that the OpenVPN services are operational by using the following systemctl command to ascertain their status.

systemctl status openvpn
  • Use the ss command as demonstrated to verify that the OpenVPN service is running and responding on the port that you told the script to use.

ss -tupln | grep openvpn
  • If you inspect your network interfaces using the IP command, you can confirm that a new interface for a VPN tunnel has been created.

ip add

Step 2: Verifying OpenVPN status on Ubuntu

  • The client machine should be configured to install the OpenVPN software as shown.

apt install openvpn
  • Use the following command to install the network-manager-openvpn package.

apt install network-manager-openvpn
  • Launch the OpenVPN service after installing the aforementioned packages, configure it to start automatically when the system boots, and verify that it is active.

systemctl start openvpn
systemctl enable openvpn
systemctl status openvpn

Conclusion

Your OpenVPN server should be operating a fully functional virtual private network at this point.

Last updated