Setting up OVPN tunnel – CentOS6

If you aren’t signed in as root you’ll need to put sudo before all of these commands.

Step one is to install ovpn on both devices.

yum install openvpn easyrsa

Then on one device go to your ovpn folder (in this case /etc/openvpn/) and run the line below, where example is the name of the tunnel you’re creating:

openvpn --genkey --secret example.key

Then copy that newly generated file onto the other device.

The next step is to set up the config file. this will be different depending on how you want to set it up, but below is an example config that will work on CentOS 6.

#this is an example conf file.
 dev example

#in the line below first you put the local internal IP you're setting this up on, then the remote internal IP you're connecting to
 
 ifconfig XXX.XXX.XXX.XXX XXX.XXX.XXX.XXX
 no-replay

#The port can be any port, I'd suggest not using common ones

 port 19999
 proto udp

#This is the remote public IP address

 remote XXX.XXX.XXX.XXX
 script-security 2
 up /etc/sysconfig/network-scripts/ifup-routes
 secret example.key
 resolv-retry infinite
 ping-timer-rem
 comp-lzo
 persist-key
 persist-tun
 user nobody
 group nogroup
 daemon
 verb 3
 passtos

Save this in the /etc/openvpn/ directory and then start ovpn.

Then you have to add the routes in on both ends unless you want to just be able to access the gateway.

service openvpn start

That should be enough to get the connection working. If pings still fail check your firewall logs and see if they’re getting caught there.