Open vpn

-----

 INSTALL OPENVPN ON CENTOS LINUX (6 AND 7)

Step 1: Enable EPEL repository

On CentOS 6:

On CentOS 7:

Step 2: Install and configure OpenVPN

Copy the sample.conf to /etc/openvpn as starting point for our own config file.

Now, let's change the configuration file.

Uncomment the following lines and make them look like as below:

Step 3: Generate OpenVPN key and certificates

Create a folder to store the key and certificates in, copy the key generation script and openssl.cnf with this command:

Now, we're going to open en change /etc/openvpn/easy-rsa/vars:

Find (and uncomment when commented) these lines and change them with your own information.

Change KEY_NAME to "server". Do not change it to something else since we use 'server' also in other commands in this tutorial.

Change KEY_CN to a subdomain resolving to the IP address of your server.

Now we're going to generate all keys and certificates. As we specifed all variables already in /etc/openvpn/easy-rsa/vars, just press ENTER on each question.

Step 4 for CentOS 6: Add iptables rule

Add this rule to allow VPN traffic go through. Change 'venet0' to your main network adapter name. In most cases this is venet0 or eth0.

Save the new firewall rule

Then we must enable IP forwarding in sysctl. Open sysctl.conf:

Locate the line 'net.ipv4.ip_forward = 0' and change it to:

Step 4 for CentOS 7: Install iptables-services and add iptables rule

Execute these commands:

Add this rule to allow VPN traffic go through. Change 'venet0' to your main network adapter name. In most cases this is venet0 or eth0.

Save the new firewall rule

Then we must enable IP forwarding in sysctl. Open sysctl.conf:

Locate the line with net.ipv4.ip_forward = 0 and change it to:

Step 5: Start OpenVPN

Last command; start OpenVPN!

Your OpenVPN server is now installed and running on your CentOS server.

And now?

You need to install the OpenVPN client on your PC or Mac.

And you need a myvpn.ovpn file, which has this content:

Double click on this file to start OpenVPN.

-----------------------------

---