“A Virtual Private Network, or VPN, allows you to extend a private network across public networks. It improves your online security; to the example, if you are in a hotel and use the hotel’s internet connection for your business, there is a high probability that your data will be breached. VPN connections are private and encrypted, preventing unauthenticated access to your connection. Today in this tutorial we will go through all the steps required to set up OpenVPN Server on Ubuntu 22.04.”
OpenVPN is an open source application that is mainly used to access remote websites, establish secure connections and improve security through encryption, authentication and of course certification using the OpenSSL library. We will now set up OpenVPN on Ubuntu 22.04.
Step 1: Update the system packages
And it automatically updates your system’s packages.
Step 2: Install OpenVPN
Now you have to wait for a while and when you’re done you can go to step 3.
Step 3 Generate a static key to use for VPN tunnel encryption and start the VPN server
Note: You may have noticed the “&” at the end of the command above, and it’s meant to help you keep the OpenVPN process in the background so you don’t have to keep the terminal open.
Step 4: Check if you come true
Just type the following command and you will do it do0 with an IP address of 172.16.0.1
The output would be like this
Now we need to verify that UDP port 1194 is open for connections using the following command
And this would produce an output like this
Step 5: Configure Firewall
Use the following command to configure the firewall
And you will see the following output
The OpenVPN server is now able to receive incoming connections.
Now how will you connect the OpenVPN server from a remote client? Well, you need to follow the steps below.
Step 1: Install OpenVPN
Step 2: Transfer the OpenVPN static key file from the OpenVPN server to the client
First we need to transfer the file from the server to the client using a secure method of your choice, but we’ll use that SCP command like this
Note: This command must be issued from the client side and use your username.
Step 3: Establishing a VPN tunnel to the server
With the following command we can establish a VPN tunnel to the server, but You need to change the IP address according to the server you are connecting to
Have you noticed the AES-256-CBC cipher? Well, this is the most secure encryption and decryption of the data chain.
Step 4: Test if the connection was successful
When you’re done with step 3, you should be able to see the following message if the connection was successful.
Now let’s confirm the successful connection by pinging a host on the remote server using the following command
We’ll see something like that, but don’t worry if it’s different on your side
In this tutorial, we’ve gone through all the steps needed to receive incoming connections using OpenVPN, and we’ve also learned how to connect to an OpenVPN server from a remote client on Ubuntu. If you encounter a bug or issue please contact us as we are always happy to help our community.