# 0、准备编译环境
yum install -y gcc-c++
# 1、安装lzo压缩模块
wget http://www.oberhumer.com/opensource/lzo/download/lzo-2.10.tar.gz
tar xf lzo-2.10.tar.gz
cd lzo-2.10
./configure
make && make install
# 2、安装openvpn
yum install -y openssl* pam-devel
wget https://swupdate.openvpn.org/community/releases/openvpn-2.5.6.tar.gz
tar xf openvpn-2.5.6.tar.gz
cd openvpn-2.5.6
./configure --prefix=/opt/openvpn-2.5.6
make && make install
#3、开启路由转发
echo "net.ipv4.ip_forward = 1" >> /etc/sysctl.conf
sysctl -p
#4、开启地址伪装
iptables -t nat -A POSTROUTING -j MASQUERADE
#5、创建目录
ln -s /opt/openvpn-2.5.6 /opt/openvpn
mkdir -p /opt/openvpn/conf/server
mkdir -p /opt/openvpn/logs/server
#6、启动openvpn
/opt/openvpn/sbin/openvpn --daemon --config /opt/openvpn/conf/server/server.conf --writepid /opt/openvpn/logs/openvpn.pid