Red hat linux Web Hosting

How to install, setup and configure an OpenVPN Service on CentOS 5

In this tutorial, we will learn how to install, setup and configure an OpenVPN Service on CentOS 5 as well as configuring the firewall to allow vpn traffic. Clients configuration will be done in the linked article, available at the bottom of this tutorial.

Topology used in this scenario:

Installation:

1) To begin, we need to make sure we have the RPMForge repository installed and activated.

2) If you have SELinux enabled and enforcing, you will need to run this:

3) Install OpenVPN via yum. This will make sure that the following package are installed: openvpn, lzo, pkcs11-helper

4) Copy the easy-rsa directory from the template to your /etc/openvpn (please change the version number according to your version of openvpn)

**PLEASE NOTE** if the above command brings up an error such as below, then please follow the following steps to download and copy over easy-rsa as its not included in the new build OpenVPN 2.3.1:

cannot stat /usr/share/doc/openvpn-2.2.2/easy-rsa/': No such file or directory

Download easy-rsa from below:

Extract the package:

5) Change permissions

6) Edit the configuration file /etc/openvpn/easy-rsa/2.0/vars with your favorite editor such as nano or vi, and change the values at the complete bottom to correspond with your own informations and make sure you save a copie somewhere. (from KEY_COUNTRY up to KEY_OU)

7) Source the configuration file vars with the following command and clean-all

8) Once we reach this step, openvpn has been installed and initially configured. Now we have to build our CA Certificate, our Server Certificate and our Client Certificate.

9) Start by building the CA Certificate with the command:

This step will ask your information for the CA Certificate Authority that we are creating, if we configured the vars configuration file in step 6, the default values provided between ‘[‘ and ‘]’ for each value should be fine. Otherwise change accordingly.

10) It is time now to create the Server Certificate with our newly created CA Authority Certificate. Run the following command (and replace server.hostname.com with your server hostname):

This will print a summary of the certificate to be created and ask you to confirm that you want to “Sign the certificate” which you will say YES ot ‘y’
Finally, it will ask you to confirm to commit the change, which again, you will say YES or ‘y’

11) Now we have to edit our main configuration file at /etc/openvpn/openvpn.conf with our favorite editor such as nano or vi`,
(change server.hostname.com for the value used while building the server certificate at step 10)

12) Create the directory to hold our created keys and certificates, make it private and move them into it:

13) Create the DH and move it.

14) Make sure that the OpenVPN Service start at boot time

15) That it! The OpenVPN Service is now ready to be executed.

16) For the Firewall configuration, you need to run the following commands:

We still have to create the client certificate and configure the client to connect to our OpenVPN Service.

How to install OpenVPN on Windows 7 using Certificates

 

o install OpenVPN on Windows 7, go on the OpenVPN website, in the community downloads, and download the Windows Installer.

Once it is downloaded, do not run it just yet. Open the download location, right click on the file and choose properties. Go to the compatibility tab and set it compatibility to Windows Vista SP1 and tick the checkbox at the bottom that say ‘Run this program as an administrator’, Click OK which will close this dialog

Finally, right click on the Windows Installer file for the OpenVPN installation package and choose ‘Run as an Administrator’

Proceed with standard installation and accept any popup about signed or unsigned drivers if there is any.

Tutorial topology


Client Certificates file:

The client certificate, the client key and the CA certificate must be copied into the client computer, especially in the OpenVPN config folder, located at:

To generate the client abc certificate and key, and that you have followed our tutorial on how to setup the openvpn service on CentOS, you can run the following command and then copie (not move), the generated client certificate and key, with the CA cert to the OpenVPN config folder, stated above:


Client Configuration file:

By default the file do not exist, so open a new notepad, and save it at this location:

Then copy the following configuration inside and save the file:

Leave a Reply

Your email address will not be published. Required fields are marked *