How To Install OpenVPN on Ubuntu 16.04 LTS

Install OpenVPN on Ubuntu 16.04 LTS

In this tutorial we will show you how to install OpenVPN on Ubuntu 16.04 LTS. For those of you who didn’t know, OpenVPN is an open source application which is widely used to create secure virtual private networks over the unsecured public Internet. OpenVPN is an SSL VPN solution which drains your system connection securely through the Internet. OpenVPN functions in the client server structure. All the devices connected to a virtual private network act as if they’re linked to your local area network. The packets sent through the VPN tunnel are encrypted with 256 bit AES encryption making data theft impossible.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo’ to the commands to get root privileges. I will show you through the step by step installation OpenVPN open source virtual private network on a Ubuntu 16.04 (Xenial Xerus) server.

Install OpenVPN on Ubuntu 16.04 LTS

Step 1. First make sure that all your system packages are up-to-date by running these following apt-get commands in the terminal.

Step 2. Installing OpenVPN on Ubuntu 16.04.

Install OpenVPN using following command:

Step 3. Setting Certificate Authority.

The OpenVPN server uses certificates to encrypt traffic between the server and various clients. Thus, we need to set up a certificate authority (CA) on the VPS to create and manage these certificates:

We’ll be editing some variables toward the end of the file:

Change them according to your needs:

If there aren’t any errors, you’ll see the following output:

Now we can clean up the environment and then build up our CA:

Congratulation…..New RSA key will be created, and you’ll be asked to confirm the details you entered into the vars file earlier. Just hit Enter to confirm.

Step 4. Generating a server key and certificate.

Run the command below in the current directory:

We will also need to create a Diffie-Hellman file. Creation of this file will depends on the length of the key. For this default we will use 2048 bit key but you can always change it by editing the vars file in the easy-rsa folder:

Finally, you need to generate an HMAC signature to strengthen the certificate:

Step 5. Create the client public/private keys.

This process will create a single client key and certificate:

Step 6. Configure the OpenVPN server.

We will now configure the OpenVPN server:

Next, extract a sample OpenVPN configuration to the default location:

Now edits to the configuration file:

Paste the configurations below (you may change the values of port etc.):

Save the file and enable and start the OpenVPN service:

Step 7. Configure Iptables for OpenVPN.

We will need to enter some iptable rules to enable internet on the client machine:

Congratulation’s! You have successfully installed OpenVPN. Thanks for using this tutorial for installing OpenVPN server on Ubuntu 16.04 LTS  (Xenial Xerus) system. For additional help or useful information, we recommend you to check the official OpenVPN web site.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get a best deal!