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.

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,

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.

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

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 :-

4 Responses

Good tutorial. This script reduce the time to setup OpenVPN server. I have a question. My server is a DEbian, but my clients are W7 o W10. Can I use the same command openvpn –config /root/Nodes.ovpn to setup a Windows client? tanks