how to use openvpn on centos7

  1. server on centos7

    yum -y install openvpn iptables-services
    openvpn --genkey --secret static.key
    iptables -F
    iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o eth0 -j MASQUERADE
    service iptables save
    echo net.ipv4.ip_forward=1 >> /etc/sysctl.conf && sysctl -p
    openvpn --config server.opvn --deamon
    

    cat server.ovpn

    dev tun
    ifconfig 10.8.0.1 10.8.0.2
    secret static.key
    
  2. client on windows10

    gc client.ovpn

    remote myRemoteIp
    dev tun
    ifconfig 10.8.0.2 10.8.0.1
    secret static.key
    redirect-gateway def1
    dhcp-option DNS 10.8.0.1
    

references: