5/6/2019 How To Install OpenVPN on CentOS
([Link]
BLOG
VPS HOSTING (HTTPS://[Link]/EN/[Link])
TUTORIALS: How To..
DEDICATED SERVERS (HTTPS://[Link]/EN/[Link])
DOMAINS (HTTPS://[Link]/EN/[Link])
SSL (HTTPS://[Link]/EN/[Link])
ABOUT (HTTPS://[Link]/EN/[Link])
(HTTPS://[Link]/NL/HOW-TO-INSTALL-OPENVPN-ON-
[Link])
HOW TO INSTALL OPENVPN ON CENTOS
LINUX (6 AND 7)
[Last updated: 24 May 2019]
In this tutorial we explain how to install OpenVPN on your QuickServers virtual or dedicated server.
OpenVPN is an open source VPN application that lets you create and join a private network securely
over the internet.
Use promo code QRP10031 ([Link] and have
your OpenVPN virtual server for only EUR 1,50.
Step 1: Enable EPEL repository
On CentOS 6:
[Link] 1/7
5/6/2019 How To Install OpenVPN on CentOS
rpm -Uvh [Link]
On CentOS 7:
yum install epel-release
Step 2: Install and con gure OpenVPN
yum install -y openvpn easy-rsa
Copy the [Link] to /etc/openvpn as starting point for our own con g le.
cp /usr/share/doc/openvpn-*/sample/sample-con g- les/[Link] /etc/openvpn
Now, let's change the con guration le.
vi /etc/openvpn/[Link]
Uncomment the following lines and make them look like as below:
push "redirect-gateway def1 bypass-dhcp"
push "dhcp-option DNS [Link]"
push "dhcp-option DNS [Link]"
Step 3: Generate OpenVPN key and certi cates
Create a folder to store the key and certi cates in, copy the key generation script and [Link] with
this command:
mkdir -p /etc/openvpn/easy-rsa/keys && cp -rf /usr/share/easy-rsa/2.0/* /etc/openvpn/easy-rsa &&
cp /etc/openvpn/easy-rsa/[Link] /etc/openvpn/easy-rsa/[Link]
Now, we're going to open en change /etc/openvpn/easy-rsa/vars:
vi /etc/openvpn/easy-rsa/vars
Find (and uncomment when commented) these lines and change them with your own information.
export KEY_COUNTRY="NL"
export KEY_PROVINCE="FL"
export KEY_CITY="Amsterdam"
export KEY_ORG="QuickServers"
[Link] 2/7
5/6/2019 How To Install OpenVPN on CentOS
export KEY_EMAIL="admin@[Link]"
export KEY_OU="IT"
Change KEY_NAME to "server". Do not change it to something else since we use 'server' also in other
commands in this tutorial.
export KEY_NAME="server"
Change KEY_CN to a subdomain resolving to the IP address of your server.
export KEY_CN=[Link]
Now we're going to generate all keys and certi cates. As we specifed all variables already in
/etc/openvpn/easy-rsa/vars, just press ENTER on each question.
cd /etc/openvpn/easy-rsa && source ./vars && ./clean-all
./build-ca
./build-key-server server
./build-dh
cd /etc/openvpn/easy-rsa/keys && cp [Link] [Link] [Link] [Link] /etc/openvpn
cd /etc/openvpn/easy-rsa && ./build-key client
Step 4 for CentOS 6: Add iptables rule
Add this rule to allow VPN traf c go through. Change 'venet0' to your main network adapter name. In
most cases this is venet0 or eth0.
iptables -t nat -A POSTROUTING -s [Link]/24 -o venet0 -j MASQUERADE
Save the new rewall rule
service iptables save
Then we must enable IP forwarding in sysctl. Open [Link]:
[Link] 3/7
5/6/2019 How To Install OpenVPN on CentOS
vi /etc/[Link]
Locate the line 'net.ipv4.ip_forward = 0' and change it to:
net.ipv4.ip_forward = 1
Step 4 for CentOS 7: Install iptables-services and add iptables rule
Execute these commands:
yum install -y iptables-services
systemctl mask rewalld
systemctl enable iptables
systemctl stop rewalld
systemctl start iptables
iptables -- ush
Add this rule to allow VPN traf c go through. Change 'venet0' to your main network adapter name. In
most cases this is venet0 or eth0.
iptables -t nat -A POSTROUTING -s [Link]/24 -o venet0 -j MASQUERADE
Save the new rewall rule
iptables-save > /etc/syscon g/iptables
Then we must enable IP forwarding in sysctl. Open [Link]:
vi /etc/[Link]
Locate the line with net.ipv4.ip_forward = 0 and change it to:
net.ipv4.ip_forward = 1
Step 5: Start OpenVPN
Last command; start OpenVPN!
service network restart
service openvpn start
[Link] 4/7
Your OpenVPN server is now installed and running
5/6/2019 How To on your
Install CentOS
OpenVPN server.
on CentOS
And now?
You need to install the OpenVPN client on your PC or Mac.
Windows: [Link]
Mac: [Link]
And you need a [Link] le, which has this content:
client
dev tun
proto udp
remote [Link] 1194
resolv-retry in nite
nobind
persist-key
persist-tun
comp-lzo
verb 3
< ca>
-----BEGIN CERTIFICATE-----
MIIEtzCCA5+gAwIBAgIJAKdTKTrDcEmpMA0GCSqGSIb3DQEBCwUAMIGYMQswCQYD
VQQGEwJOTDELMAkGA1UECBMCRkwxDzANBgNVBAcTBkFsbWVyZTERMA8GA1UEChMI
-----END CERTIFICATE-----
< /ca>
< cert>
-----BEGIN CERTIFICATE-----
MIIE9TCCA92gAwIBAgIBAjANBgkqhkiG9w0BAQsFADCBmDELMAkGA1UEBhMCTkwx
CzAJBgNVBAgTAkZMMQ8wDQYDVQQHEwZBbG1lcmUxETAPBgNVBAoTCEVub3JtYWls
-----END CERTIFICATE-----
< /cert>
< key>
-----BEGIN PRIVATE KEY-----
MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQC7N5Bd12XYuDBz
lWmyaGsuRbf3k0gQuRwzO88pqSd rhEb036gfPIIv5SQrEPZ+2fLqbqQqg+weQS
-----END PRIVATE KEY-----
< /key>
Double click on this le to start OpenVPN.
[Link] 5/7
5/6/2019 How To Install OpenVPN on CentOS
SHARE
OTHER BLOG POSTS
HOW TO INSTALL OPENVPN ([Link])
HOW TO INSTALL VSFTPD ([Link])
HOW TO INSTALL REDIS ([Link])
HOW TO INSTALL BOXROOM ([Link])
HOW TO INSTALL CPANEL ([Link])
HOW TO INSTALL SOLR ([Link])
HOW TO INSTALL OWNCLOUD ([Link])
HOW TO INSTALL DIRECTADMIN ([Link])
HOW TO INSTALL PLESK ([Link])
HOW TO INSTALL MEMCACHED ([Link])
([Link]
Hosting
Cloud Servers ([Link]
Dedicated servers ([Link]
Big Storage Servers ([Link]
[Link] 6/7
5/6/2019 How To Install OpenVPN on CentOS
Services
Domains ([Link]
SSL certi cates ([Link] [Link])
Managed hosting ([Link]
QuickServers
Customer Area ([Link]
Sign Up ([Link]
Referral Program ([Link]
Language
English ([Link]
Nederlands ([Link]
[Link] 7/7