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.

The same process (mentioned below) 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 )

Pre-requisites

  • 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,\

RHEL/CentOS 8

$ sudo dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm

RHEL/CentOS 7

$ 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.

 

Install OpenVPN

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,

$ ./openvpn.sh

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,

install OpenVPN

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’,

install OpenVPN

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,

install OpenVPN

4- Next, we need to select the DNS that we will be using with OpenVPN, we have selected ‘Google’ for our server,

install OpenVPN

5- Next provide the name for client certificate, it should be a single letter word with no special character,

install OpenVPN

6- Setup will now continue & will take some time to complete,

install OpenVPN

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.

install OpenVPN

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.

 

Configuring Clients

Copy the created certificate to client system using the following command (run command from OpenVPN server),

$ scp –rv /root/Nodes.ovpn root@10.20.30.200:/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

install OpenVPN

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.

If you think we have helped you or just want to support us, please consider these :-

Connect to us: Facebook | Twitter

Donate us some of you hard earned money: [paypal-donation]

Linux TechLab is thankful for your continued support.