Portal Home > Knowledgebase > VPS Hosting and Dedicated Servers > OpenVPN install on CentOS VPS or Dedicated Server


OpenVPN install on CentOS VPS or Dedicated Server




* Login to your VPS shell.......... Open the terminal console....

* Download the packets

#wget http://openvpn.net/release/openvpn-2.0.9.tar.gz
#wget http://openvpn.net/release/lzo-1.08-4.rf.src.rpm

* Install and build

#yum install rpm-build
#yum install autoconf.noarch
#yum install zlib-devel
#yum install pam-devel
#yum install openssl-devel

* Install with rpm

#rpmbuild --rebuild lzo-1.08-4.rf.src.rpm
#rpm -Uvh /usr/src/redhat/RPMS/i386/lzo-*.rpm
#rpmbuild -tb openvpn-2.0.9.tar.gz
#rpm -Uvh /usr/src/redhat/RPMS/i386/openvpn-2.0.9-1.i386.rpm

* Copy configuration file to /etc/openvpn folder

#cp -r /usr/share/doc/openvpn-2.0.9/easy-rsa/ /etc/openvpn/
#cp /usr/share/doc/openvpn-2.0.9/sample-config-files/server.conf /etc/openvpn/

* Building certificate (to /etc/openvpn/easy-rsa/2.0 directory)

#cd /etc/openvpn/easy-rsa/2.0
#source ./vars
#./vars
#./clean-all
#./build-ca

"Common Name" must be filled...

* Build key server

#./build-key-server server

"Common Name" must be filled... Please insert : server

* Build Diffie Hellman

#./build-dh

* Build certificate for client (exp. cert for : client)

#./build-key client

"Common Name" must be filled... Please insert like same cert : client

    * Copy that certificate to /etc/openvpn/keys

#cp /etc/openvpn/easy-rsa/2.0/keys /etc/openvpn/keys -R

* OpenVPN server configuration (in /etc/openvpn/server.conf)

local 123.123.123.123 #--your ip here
port 53
proto udp
dev tun
ca /etc/openvpn/keys/ca.crt
cert /etc/openvpn/keys/server.crt
key /etc/openvpn/keys/server.key
dh /etc/openvpn/keys/dh1024.pem
server 10.9.0.0 255.255.255.0
ifconfig-pool-persist ipp.txt
push "redirect-gateway def1"
push "dhcp-option DNS 208.67.222.222"
push "dhcp-option DNS 208.67.220.220"
keepalive 5 30
comp-lzo
persist-key
persist-tun
status server-tcp.log
verb 3

Save as server.conf in /etc/openvpn/ folder

* Start your OpenVPN with this command

#service openvpn start
or
#openvpn /etc/openvpn/server.conf

* Enabling forwarding packet for redirect gateway

#echo 1 > /proc/sys/net/ipv4/ip_forward

* Edit NAT table for MASQUERADING

For VPS :
#iptables -t nat -A POSTROUTING -s 10.9.0.0/24 -j SNAT --to 123.123.123.123

For Dedicated Server :
#iptables -t nat -A POSTROUTING -s 10.9.0.0/24 -o eth0 -j MASQUERADE

IP must be same with your IP tun0 in your VPS

* Download OpenVPN configuration for client

Download ca.crt, client.crt and client. key from /etc/openvpn/keys folder. Save that 3 file to C:\program files\openvpn\config\

* OpenVPN configuration for client

client
dev tun
proto udp
remote 123.123.123.123 #-- your ip here
resolv-retry infinite
nobind
persist-key
persist-tun
ca ca.crt
cert client.crt
key client.key
comp-lzo
verb 3

Save as client.ovpn in C:\program files\openvpn\config\ folder

Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article

Also Read

* Minimum sign up periods for cPanel Web Hosting plans: Mini - 3mo., Pro - 1mo., Biz - 1mo., cPanel Reseller Hosting, Linux VPS, Windows VPS, Managed cPanel VPS and Dedicated Servers - 1mo. secret link
Accepted payments: Credit/Debit Card, Paypal, Payza, Skrill, WebMoney, CashU, Ukash, paysafecard, Bitcoin, Perfect Money, SolidTrust Pay, OKPay, EgoPay, Western Union/MG, Wire Transfer and more.