Simple Guide to install OpenVPN on CentOS, Ubuntu (& their derivatives)
Last updated on March 12th, 2018 at 07:22 pm
OpenVPN is an open source application that allows us to create a SSL based virtual private network (VPN) that supports both site-to-site & client-to-site tunnels. It allows us to connect to a remote location as if we are in the same network as remote location.
In this tutorial, we will discuss how to install OpenVPN on CentOS. But this same process can also be used to install OpenVPN on Debian & Ubuntu as well. For this tutorial, we will be using a script that will automate the whole process to install OpenVPN. We will start by discussing the pre-requisites to install OpenVPN.
(Recommended Read: Create your own personal Cloud: Install OwnCloud )
- For CentOS, we need to have EPEL repository installedon our system as there are some dependencies that are available with EPEL repo only. Install EPEL repo with the following command onto your system,
$ sudo rpm -Uvh https://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/e/epel-release-7-11.noarch.rpm
RHEL/CentOS 6 (64 Bit)
$ sudo rpm -Uvh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
RHEL/CentOS 6 (32 Bit)
$ sudo rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
- For Ubuntu, Debian , we will not need extra repository as all the dependencies can be resolved with default repos only.
Note:- The process mentioned below will be same to install OpenVPN on CentOS, Debian & Ubuntu.
As mentioned above, we will be using a script to automate the procedure to install OpenVPN. So , open terminal & execute the following command to download the script onto the system,
$ wget https://git.io/vpn -O openvpn.sh
Now provide it execute permissions,
$ chmod +x openvpn.sh
Note:- Before we execute the script, make sure that we have logged in as user ‘root’.
Now start the installation by executing the script,
Setup will now start , follow the on-screen instructions as we need to provide some information needed by setup to continue,
1- As soon as the script runs, we will be asked to provide the IP address for network interface that OpenVPN will listen to, for us its 10.20.30.100,
2- Next it will ask for protocol type we want to use, we have kept is default but you can also choose ‘tcp’ by pressing ‘2’,
3- Next, we will be asked to enter the port number for OpenVPN, we are also keeping it default i.e. 1194. You can change it, if needed,
4- Next, we need to select the DNS that we will be using with OpenVPN, we have selected ‘Google’ for our server,
5- Next provide the name for client certificate, it should be a single letter word with no special character,
6- Setup will now continue & will take some time to complete,
7- On the last step, we will be asked to provide an External IP address. Mention if you have one, otherwise just press enter for the setup to complete.
8- Our setup is now complete & our client certificates have been created. We will need this certificate as this certificates needs to copied onto all client machine that will connect to OpenVPN server.
Copy the created certificate to client system using the following command (run command from OpenVPN server),
$ scp –rv /root/Nodes.ovpn [email protected]:/root/
Here, 10.20.30.200 is the IP address of the client that will connect to OpenVPN.
Now login to the client system & install OpenVPN with the following command,
$ sudo yum install openvpn
Note:- We might need to enable EPEL repo on client system as well for OpenVPN installation.
For Ubuntu, run the following command,
$ sudo apt-get install openvpn
Now the client system is ready to be connected to openvp, open the terminal & execute the following command to start using OpenVPN,
$ openvpn –config /root/Nodes.ovpn
Congratulations, you have successfully installed & connected to OpenVPN.
With this we end our tutorial on how to install OpenVPN on CentOS, Ubuntu. Please do send in your queries to us,using the comment box below.