Ubuntu Tutorial – Today we will show you how to install OpenVPN Server on Ubuntu 16.04, Ubuntu 17.04 and all derivatives. OpenVPN is a free secure VPN service that has been widely used by millions of users around the world. Installing OpenVPN Server on Ubuntu based machine is very easy. Thanks to someone that provide the installation script that make it even easier to install OpenVPN Server on Linux.
Steps to install OpenVPN Server on Ubuntu 16.04
There are few steps to install OpenVPN Server. Please read them carefully. On this example, I am installing OpenVPN Server on an Amazon Lightsail machine with Ubuntu 16.04.2 Server installed. Make sure you have root access or sudo to the machine. Also make a note of the Ubuntu IP address.
- Update Ubuntu
- Install and configure firewall
- Download installation script
- Install OpenVPN Server
Step 1. Update Ubuntu
Whilst its an important part to make sure our system is up to date.
sudo apt update sudo apt upgrade
Step 2. Install and configure firewall (ufw)
Install ufw with the following command
sudo apt install ufw
Configure ufw to allow port 22, 443 and 80.
ubuntu@ip-172-26-4-114:~$ sudo ufw allow 22 Rules updated Rules updated (v6) ubuntu@ip-172-26-4-114:~$ sudo ufw allow 443 Rules updated Rules updated (v6) ubuntu@ip-172-26-4-114:~$ sudo ufw allow 80 Rules updated Rules updated (v6)
Enable ufw and check it status
ubuntu@ip-172-26-4-114:~$ sudo ufw enable Command may disrupt existing ssh connections. Proceed with operation (y|n)? y Firewall is active and enabled on system startup ubuntu@ip-172-26-4-114:~$ sudo ufw status Status: active To Action From -- ------ ---- Apache Full ALLOW Anywhere 22 ALLOW Anywhere 443 ALLOW Anywhere 80 ALLOW Anywhere Apache Full (v6) ALLOW Anywhere (v6) 22 (v6) ALLOW Anywhere (v6) 443 (v6) ALLOW Anywhere (v6) 80 (v6) ALLOW Anywhere (v6)
Step 2. Download installation script
wget https://git.io/vpn -O openvpn-install.sh
Step 3. Run the script and install OpenVPN Server
After running the script, the text based installation wizard will start. Answer some questions shown on your Terminal console.
sudo bash openvpn-install.sh
ubuntu@ip-172-26-4-114:~$ sudo bash openvpn-install.sh Welcome to this quick 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 I need to know the IPv4 address of the network interface you want OpenVPN listening to. IP address: 172.26.4.114 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) Google 3) OpenDNS 4) NTT 5) Hurricane Electric 6) Verisign DNS [1-6]: 3 Finally, tell me your name for the client certificate Please, use one word only, no special characters Client name: gamblisfx Okay, that was all I needed. We are ready to setup your OpenVPN server now Press any key to continue...
Then the installation should begin. Wait few moments until it completed. Once completed, you can now download the .ovpn and save it to your computer.
You will need this file in order to connect to your OpenVPN Server using OpenVPN Client.