Do you want to access the internet securely and safely while leveraging open and untrusted networks like Wi-Fi access points?. OpenVPN is a full-featured, open-source Secure Socket Layer (SSL) VPN solution that supports a wide range of configurations. By making use of Virtual Private Network (VPN), you can securely traverse untrusted networks securely as if you were within the LAN.
In this guide, I’ll show you an easy way to have OpenVPN Server installed on Ubuntu 18.04 and ready for clients to start using it. I know OpenVPN setup through a manual process can be challenging especially for new users not experienced with Linux and VPNs.
Install and Configure OpenVPN Server on Ubuntu 18.04 / Ubuntu 16.04
This method will work well with both Debian family distributions as well as Red Hat family. This guide is specific to Ubuntu 18.04 and Ubuntu 16.04, but the setup process will be similar for other distributions. It is a scripted way so anyone with basic Linux knowledge can follow along.
Before you start installing any package on your Ubuntu server, we always recommend making sure that all system packages are updated:
$ sudo apt-get update $ sudo apt-get upgrade
Installing and Configuring OpenVPN server on Ubuntu 18.04 / Ubuntu 16.04
Once you update the system, we can begin the installation and configuration of OpenVPN server on Ubuntu 18.04 / Ubuntu 16.04 system. We will use openvpn-install script which let you set up your own VPN server in no more than a minute, even if you haven’t used OpenVPN before. It has been designed to be as unobtrusive and universal as possible.
Follow below steps to have OpenVPN server installed and running:
Step 1: Install git
Install git by running the command:
$ sudo apt-get install git
Step 2: Clone openvpn-install repository
Now clone the
openvpn-install repository using git tool installed in Step one:
$ cd ~ $ git clone https://github.com/Nyr/openvpn-install.git Cloning into 'openvpn-install'... remote: Counting objects: 345, done. remote: Total 345 (delta 0), reused 0 (delta 0), pack-reused 345 Receiving objects: 100% (345/345), 99.15 KiB | 681.00 KiB/s, done. Resolving deltas: 100% (170/170), done.
Step 3: Change to
openvpn-install and run OpenVPN installer
cd to the directory
openvpn-install created by clone and run the installer script.
$ cd openvpn-install/ $ ls -1 LICENSE.txt README.md openvpn-install.sh $ chmod +x openvpn-install.sh $ sudo ./openvpn-install.sh
You will get a couple of prompts to change or confirm default settings for the installation
Welcome to this OpenVPN "road warrior" installer! I need to ask you a few questions before starting the setup. You can leave the default options and just press enter if you are ok with them. First, provide the IPv4 address of the network interface you want OpenVPN listening to. IP address: 192.168.10.2 Which protocol do you want for OpenVPN connections? 1) UDP (recommended) 2) TCP Protocol [1-2]: 1 What port do you want OpenVPN listening to? Port: 1194 Which DNS do you want to use with the VPN? 1) Current system resolvers 2) 184.108.40.206 3) Google 4) OpenDNS 5) Verisign DNS [1-5]: 1 Finally, tell me your name for the client certificate. Please, use one word only, no special characters. Client name: client Okay, that was all I needed. We are ready to set up your OpenVPN server now. Press any key to continue... <Enter>
<Enter> after answering all the questions to start the installation process: If the installation was successful, you should get a success message at the end:
Main OpenVPN server configuration file is,
/etc/openvpn/server.conf you are free to tune and tweak it to your liking.
tun0 virtual interface will be created during the setup process. This is used by OpenVPN clients subnet. Confirm its presence using:
The default subnet for this interface is.
10.8.0.0/24.OpenVPN server will be assigned
10.8.0.1 IP address:
To test this, use:
$ sudo apt-get install traceroute
Step 4: Generate OpenVPN user profile (.ovpn file)
After completing step 1 through 3, your VPN Server is ready for use. We need to generate VPN Profiles to be used by the users. The same script we used for the installation will be used for this. It manages the creation and revocation of user profiles.
From the output you can confirm the location of my profile,
/root/josphat.mutai.ovpn you need to copy this profile to the user. The location of the associated private key is also provided
Step 5: Connect to OpenVPN Server from the client
You can use the VPN client of your choice to configure OpenVPN client on your operating system. For those who want to use Official OpenVPN client, go to the downloads page and get the latest release then install it.
For Linux users, you can use NetworkManager and openvpn plugin to connect to OpenVPN server. Check my previous guide for how to: How to use nmcli to connect to OpenVPN Server on Linux