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