Sajid Ali
Sajid Ali
Linux & Windows Server Administrator | Cloud Architect: I possess 10 years of professional experience with administration of different hosting provider’s Linux and Windows based servers on a large production level.

How to Set Up and Configure OpenVPN Server and Client on Ubuntu 20.04 LTS.

So, in this guide you will learn how to Set Up and Configure OpenVPN Server and Client on Ubuntu 20.04 LTS.

Open source OpenVPN uses VPN technologies to secure and encrypt data sent over the internet. Its custom VPN protocol uses SSL/TLS for key exchange and released under the GNU GPL license.

OpenVPN is extremely popular and a full-featured SSL VPN (Virtual Private Network) software. It implements OSI layer 2 or 3 secure network extension using the SSL/TLS protocol.

This tutorial provides step-by-step instructions for configuring an OpenVPN Server and OpenVPN Client on Ubuntu 20.04 LTS Linux server.

Step 1 – Update your system:

First you have to install Ubuntu 20.04 update by executing following commands:

# apt update

# apt upgrade

Step 2 – Find and note down your IP address:

Use the ip command as shown below.

# ip a

# ip a show eht0

We can try the following dig command/host command to find out your public IP address from Linux command line:

# dig +short

# dig -4 TXT +short | awk -F'"' '{ print $2 }'

Step 3 – Configure OpenVPN Server and Client on Ubuntu 20.04 LTS

Use wget command in order to download the script.

wget -O

Note: If you want password authentication along with certificates? Try the following:

wget -O

Make sure you set up permissions using the chmod command:

# chmod +x

Execute the script to install the OpenVPN server on Ubuntu machine:

It will ask you series of questions and you have to select options as per your requirements. Please see the screenshot below.

# ./

Desktop or Mobile client configuration:

When VPN server configuration done, we can create a desktop client VPN configuration file. You will be prompted for a client name and then client configuration will be available on OpenVPN Server.

start/stop/restart OpenVPN server on Ubuntu server:

# systemctl status openvpn-server@server.service

# systemctl start openvpn-server@server.service

# systemctl stop openvpn-server@server.service

# systemctl restop openvpn-server@server.service

Step 4 – Connect an OpenVPN server using Ubuntu Client:

On your VPN server you will see a client configuration file called DesktopVPNClient.ovpn.

You will have to copy this file to your linux client machine using the scp command.

Install openvpn client on your ubuntu client machine.

# apt install openvpn

You can view the DesktopVPNClient.ovpn file in linux editor like vi or vim etc.

# vi DesktopVPNClient.ovpn

Now, copy the DeskptoVPNClient.ovpn in /etc/openvpn/client.conf

# cp DesktopVPNClient.ovpn  /etc/openvpn/client.conf

You can test the connectivity from the CLI.

# openvpn --client --config /etc/openvpn/client.conf

Our Linux client will automatically connect when computer restart using openvpn script/service:

# systemctl start openvpn@client

Step 5 – Verify connectivity between VPN Server and VPN Client.

Execute the following commands after connecting to OpenVPN server to your Linux client:

On VPN Client machine:

Check the interface detail on VPN Server machine.

# ip a

You will see tun0 interface with IP address.

Ping to the VPN server gateway.

# ping

If all goes well you will be able to see the ping reply and which means VPN server and VPN client connected successfully.

On VPN Server machine:

Check the interface detail on VPN Server machine.

# ip a

Make sure routing setup working.

#ip route

Step 6 – Add or remove OpenVPN client.

Log in to your Ubuntu Linux server and run the script again

# ./

You will see different options for add, revoke, remove or exit, chose options as per your need.

Select an option:

   1) Add a new client

   2) Revoke an existing client

   3) Remove OpenVPN

   4) Exit


Choose option # 1 to add a new VPN client/user and option # 2 to remove the existing VPN client and user. Let us add a new client/user called iphone:


Congratulations!! You successfully set up an OpenVPN server and OpenVPN client on Ubuntu 20.04 machine. For more detail please refer to the openvpn site.



Please enter your comment!
Please enter your name here

Latest articles

Join us on Facebook