Firstly
yum install gcc make rpm-build autoconf.noarch zlib-devel pam-devel openssl-devel -y
Now download LZO RPM and Configure RPMForge Repo. Use wget command:
wget http://openvpn.net/release/lzo-1.08-4.rf.src.rpm
Then build the rpm package using this command:
rpmbuild --rebuild lzo-1.08-4.rf.src.rpm
rpm -Uvh lzo-*.rpm
rpm -Uvh rpmforge-release*
Installing OpenVPN
Only for VPS based-on
OpenVZ virtualization (other skip this): please enable
TUN/TAP options in your VPS control panel (e.g: SolusVM)
Install by yum “yum install openvpn”
If we got the problem with “No package openvpn available”
Download rpmforge for your system from http://pkgs.repoforge.org/rpmforge-release/
Install rpmforge by rpm command
rpm -ivh rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm
After instlall rpmforge, now we can use yum to install openvpn
yum install openvpn
Now you need to change some files, copy directories, and generate the SSL keys for your server. Execute the following commands:
cp -R /usr/share/doc/openvpn-2.2.2/easy-rsa/ /etc/openvpn/
nano /etc/openvpn/easy-rsa/2.0/vars
edit this line
export KEY_CONFIG='$EASY_RSA/whichopensslcnf $EASY_RSA'
replace it with
export KEY_CONFIG=/etc/openvpn/easy-rsa/2.0/openssl-1.0.0.cnf
once done hit Control+O to save then Control+X to exit.
Create the certificate using these commands:
cd /etc/openvpn/easy-rsa/2.0
chmod 755 *
source ./vars
./vars
./clean-all
./build-ca
Common Name: your server hostname
./build-key-server server
./build-dh
nano -w /etc/openvpn/server.conf //put here your settings
port 1194 #- port
proto udp #- protocol
dev tun
tun-mtu 1500
tun-mtu-extra 32
mssfix 1450
reneg-sec 0
ca /etc/openvpn/easy-rsa/2.0/keys/ca.crt
cert /etc/openvpn/easy-rsa/2.0/keys/server.crt
key /etc/openvpn/easy-rsa/2.0/keys/server.key
dh /etc/openvpn/easy-rsa/2.0/keys/dh1024.pem
plugin /usr/share/openvpn/plugin/lib/openvpn-auth-pam.so /etc/pam.d/login #- Comment this line if you are using FreeRADIUS
#plugin /etc/openvpn/radiusplugin.so /etc/openvpn/radiusplugin.cnf #- Uncomment this line if you are using FreeRADIUS
client-cert-not-required
username-as-common-name
server 10.8.0.0 255.255.255.0
push "redirect-gateway def1"
push "dhcp-option DNS 8.8.8.8"
push "dhcp-option DNS 8.8.4.4"
keepalive 5 30
comp-lzo
persist-key
persist-tun
status 1194.log
verb 3
service openvpn start
chkconfig openvpn on
//add autostart
echo openvpn /etc/openvpn/server.conf >> /etc/rc.d/rc.local
You’ll also need to enable IP forwarding in the file /etc/sysctl.conf. Open it and edit “net.ipv4.ip_forward” line to 1:
Do not forget to replace 123.123.123.123 with your server IP.