Server (IP
1.2.3.4, VPN Subnet 10.8.0.0 / 255.255.255.0)
Install OpenVPN
yum install openvpn
Generate Certificates (by using easy-rsa)
cd
/usr/share/openvpn/easy-rsa/2.0/
#Setup parameters for certificate key generation
vi vars
source ./vars
#Clean all generated certificates and keys
./clean-all
#Generate server certificate
./build-ca
#Generate server key
./build-key-sever server
#Generate client key
./build-key client1
#Generate Diffie Hellman parameters
./build-dh
#Copy keys and certificates to openvpn conf folder (*crt: certificates;
*key: private keys)
cd keys
cp -a ca.crt server.crt server.key dh1024.pem /etc/openvpn/
Create configuration
#copy sampel conf file to openvpn
conf folder
cp -a /usr/share/doc/openvpn-x.x.x/sample-config-files/server.conf
/etc/openvpn/
#Edit conf file
vi /etc/openvpn/server.conf
#Server IP
local 1.2.3.4
#Listen port
port 1194
#protocol tcp or udp (default)
proto tcp
#tunnel tun (default) or tap
dev tun
#SSL/TLS Certificate
ca ca.crt
#Certificate
cert server.crt
#Private key
key server.key
#Diffie hellman
dh dh1024.pem
#VPN subnet, comment out for
bridge mode
server 10.8.0.0 255.255.255.0
#Persistent assignment and log
filename
ifconfig-pool-persist ipp.txt
#bridge mode(10.8.0.4/255.25.255.0:
ip and nm of bridge interface; ip pool 10.8.0.50 ~ 10.8.0.100)
;server-bridge 10.8.0.4 255.255.255.0 10.8.0.50 10.8.0.100
#DHCP-proxy (use Server-side DHCP
server to assign client IP)
;server-bridge
#enable compression
comp-lzo
#Maximum number of concurrently
connected clients
;max-clients 100
#Server status
status openvpn-status.log
#Log
log-append
#verbosity
verb 3
#Start OpenVPN Service
service openvpn@server.service
Client
#Download ca.crt, client.crt, client.key from Server
cp -a ca.crt client1.crt client.key MyClient
#Copy sample client conf to folder
cp -a /usr/share/doc/openvpn-x.x.x/sample-config-files/client.conf MyClient
#Modify client conf (Linux) / ovpn file (windows)
#
vi client.conf
dev tun
proto tcp
remote 1.2.3.4 1194
ca ca.crt
cert client1.crt
key client1.key
#Execute client with .conf file
openvpn xxx.conf
#Execute client with .ovpn file
<Right-click ovpn file and
select “Start OpenVPN on this config file” in Windows>