<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>安装部署 on vpn</title>
    <link>https://cncfstack.com/p/vpn/docs/ops/</link>
    <description>Recent content in 安装部署 on vpn</description>
    <generator>Hugo</generator>
    <language>en</language>
    <atom:link href="https://cncfstack.com/p/vpn/docs/ops/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>OpenVPN服务端安装</title>
      <link>https://cncfstack.com/p/vpn/docs/ops/vpn-install3/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://cncfstack.com/p/vpn/docs/ops/vpn-install3/</guid>
      <description>&lt;h1 id=&#34;vpn软件下载&#34;&gt;vpn软件下载&lt;a class=&#34;td-heading-self-link&#34; href=&#34;#vpn%e8%bd%af%e4%bb%b6%e4%b8%8b%e8%bd%bd&#34; aria-label=&#34;Heading self-link&#34;&gt;&lt;/a&gt;&lt;/h1&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;https://github.com/OpenVPN/openvpn/releases/download/v2.6.14/openvpn-2.6.14.tar.gz&#xA;https://github.com/OpenVPN/easy-rsa/releases/download/v3.2.4/EasyRSA-3.2.4.tgz&#xA;&#xA;https://file.cncfstack.com/github.com/OpenVPN/easy-rsa/releases/download/v3.2.4/EasyRSA-3.2.4.tgz&#xA;https://file.cncfstack.com/github.com/OpenVPN/openvpn/releases/download/v2.6.14/openvpn-2.6.14.tar.gz&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;h1 id=&#34;依赖软件包安装&#34;&gt;依赖软件包安装&lt;a class=&#34;td-heading-self-link&#34; href=&#34;#%e4%be%9d%e8%b5%96%e8%bd%af%e4%bb%b6%e5%8c%85%e5%ae%89%e8%a3%85&#34; aria-label=&#34;Heading self-link&#34;&gt;&lt;/a&gt;&lt;/h1&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;yum install -y openssl-devel lzo lzo-devel pam pam-devel automake pkgconfig  autoconf libtool  libnl3-devel  libcap-ng-devel pkg-config  lz4-devel lz4-libs&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;h1 id=&#34;编译安装openvpn&#34;&gt;编译安装openVPN&lt;a class=&#34;td-heading-self-link&#34; href=&#34;#%e7%bc%96%e8%af%91%e5%ae%89%e8%a3%85openvpn&#34; aria-label=&#34;Heading self-link&#34;&gt;&lt;/a&gt;&lt;/h1&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;tar xf openvpn-2.6.14.tar.gz &amp;amp;&amp;amp; cd openvpn-2.4.6&#xA;autoreconf -i -v -f&#xA;./configure --prefix=/usr/local/openvpn/&#xA;make&#xA;make install&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;h1 id=&#34;初始化准备&#34;&gt;初始化准备&lt;a class=&#34;td-heading-self-link&#34; href=&#34;#%e5%88%9d%e5%a7%8b%e5%8c%96%e5%87%86%e5%a4%87&#34; aria-label=&#34;Heading self-link&#34;&gt;&lt;/a&gt;&lt;/h1&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;mkdir -p /usr/local/openvpn/etc/pki&#xA;echo &amp;#39;net.ipv4.ip_forward = 1&amp;#39; &amp;gt;&amp;gt; /etc/sysctl.conf&#xA;sysctl -p&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;h1 id=&#34;安装easyrsa&#34;&gt;安装EasyRSA&lt;a class=&#34;td-heading-self-link&#34; href=&#34;#%e5%ae%89%e8%a3%85easyrsa&#34; aria-label=&#34;Heading self-link&#34;&gt;&lt;/a&gt;&lt;/h1&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;tar xf EasyRSA-3.2.4.tgz -C /usr/local/openvpn&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;h1 id=&#34;创建vars变量文件&#34;&gt;创建vars变量文件&lt;a class=&#34;td-heading-self-link&#34; href=&#34;#%e5%88%9b%e5%bb%bavars%e5%8f%98%e9%87%8f%e6%96%87%e4%bb%b6&#34; aria-label=&#34;Heading self-link&#34;&gt;&lt;/a&gt;&lt;/h1&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;cd /usr/local/openvpn/EasyRSA-*&#xA;&#xA;cat &amp;gt; vars &amp;lt;&amp;lt;EOF&#xA;set_var EASYRSA_REQ_COUNTRY &amp;#34;CN&amp;#34;&#xA;set_var EASYRSA_REQ_PROVINCE &amp;#34;ZheJiang&amp;#34;&#xA;set_var EASYRSA_REQ_CITY &amp;#34;HangZhou&amp;#34;&#xA;set_var EASYRSA_REQ_ORG &amp;#34;OpenVPN CA&amp;#34;&#xA;set_var EASYRSA_REQ_EMAIL &amp;#34;zhaowenyu@cncfstack.com&amp;#34;&#xA;set_var EASYRSA_REQ_OU &amp;#34;MyVPN&amp;#34;&#xA;EOF&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;h1 id=&#34;初始化证书目录&#34;&gt;初始化证书目录&lt;a class=&#34;td-heading-self-link&#34; href=&#34;#%e5%88%9d%e5%a7%8b%e5%8c%96%e8%af%81%e4%b9%a6%e7%9b%ae%e5%bd%95&#34; aria-label=&#34;Heading self-link&#34;&gt;&lt;/a&gt;&lt;/h1&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;./easyrsa init-pki&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;h1 id=&#34;创建ca证书&#34;&gt;创建ca证书&lt;a class=&#34;td-heading-self-link&#34; href=&#34;#%e5%88%9b%e5%bb%baca%e8%af%81%e4%b9%a6&#34; aria-label=&#34;Heading self-link&#34;&gt;&lt;/a&gt;&lt;/h1&gt;&#xA;&lt;p&gt;在创建CA证书，为防止私钥丢失后非法获取私钥内容，&lt;code&gt;pass phrase&lt;/code&gt;需要输入2次私钥加密的密码。在使用CA签发证书时，需要使用ca证书加密密码。&lt;/p&gt;</description>
    </item>
    <item>
      <title>使用网易脚本搭建</title>
      <link>https://cncfstack.com/p/vpn/docs/ops/vpn-install-163/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://cncfstack.com/p/vpn/docs/ops/vpn-install-163/</guid>
      <description>&lt;p&gt;&lt;a href=&#34;https://www.163yun.com/help/documents/125681593272684544&#34;&gt;https://www.163yun.com/help/documents/125681593272684544&lt;/a&gt;&lt;/p&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;&#xA;#!/bin/bash&#xA;# OpenVPN road warrior installer for Debian, Ubuntu and CentOS&#xA;&#xA;# This script will work on Debian, Ubuntu, CentOS and probably other distros&#xA;# of the same families, although no support is offered for them. It isn&amp;#39;t&#xA;# bulletproof but it will probably work if you simply want to setup a VPN on&#xA;# your Debian/Ubuntu/CentOS box. It has been designed to be as unobtrusive and&#xA;# universal as possible.&#xA;&#xA;&#xA;# Detect Debian users running the script with &amp;#34;sh&amp;#34; instead of bash&#xA;if readlink /proc/$$/exe | grep -qs &amp;#34;dash&amp;#34;; then&#xA;    echo &amp;#34;This script needs to be run with bash, not sh&amp;#34;&#xA;    exit 1&#xA;fi&#xA;&#xA;if [[ &amp;#34;$EUID&amp;#34; -ne 0 ]]; then&#xA;    echo &amp;#34;Sorry, you need to run this as root&amp;#34;&#xA;    exit 2&#xA;fi&#xA;&#xA;if [[ ! -e /dev/net/tun ]]; then&#xA;    echo &amp;#34;The TUN device is not available&#xA;You need to enable TUN before running this script&amp;#34;&#xA;    exit 3&#xA;fi&#xA;&#xA;if grep -qs &amp;#34;CentOS release 5&amp;#34; &amp;#34;/etc/redhat-release&amp;#34;; then&#xA;    echo &amp;#34;CentOS 5 is too old and not supported&amp;#34;&#xA;    exit 4&#xA;fi&#xA;if [[ -e /etc/debian_version ]]; then&#xA;    OS=debian&#xA;    GROUPNAME=nogroup&#xA;    RCLOCAL=&amp;#39;/etc/rc.local&amp;#39;&#xA;elif [[ -e /etc/centos-release || -e /etc/redhat-release ]]; then&#xA;    OS=centos&#xA;    GROUPNAME=nobody&#xA;    RCLOCAL=&amp;#39;/etc/rc.d/rc.local&amp;#39;&#xA;else&#xA;    echo &amp;#34;Looks like you aren&amp;#39;t running this installer on Debian, Ubuntu or CentOS&amp;#34;&#xA;    exit 5&#xA;fi&#xA;&#xA;newclient () {&#xA;    # Generates the custom client.ovpn&#xA;    cp /etc/openvpn/client-common.txt ~/$1.ovpn&#xA;    echo &amp;#34;&amp;lt;ca&amp;gt;&amp;#34; &amp;gt;&amp;gt; ~/$1.ovpn&#xA;    cat /etc/openvpn/easy-rsa/pki/ca.crt &amp;gt;&amp;gt; ~/$1.ovpn&#xA;    echo &amp;#34;&amp;lt;/ca&amp;gt;&amp;#34; &amp;gt;&amp;gt; ~/$1.ovpn&#xA;    echo &amp;#34;&amp;lt;cert&amp;gt;&amp;#34; &amp;gt;&amp;gt; ~/$1.ovpn&#xA;    cat /etc/openvpn/easy-rsa/pki/issued/$1.crt &amp;gt;&amp;gt; ~/$1.ovpn&#xA;    echo &amp;#34;&amp;lt;/cert&amp;gt;&amp;#34; &amp;gt;&amp;gt; ~/$1.ovpn&#xA;    echo &amp;#34;&amp;lt;key&amp;gt;&amp;#34; &amp;gt;&amp;gt; ~/$1.ovpn&#xA;    cat /etc/openvpn/easy-rsa/pki/private/$1.key &amp;gt;&amp;gt; ~/$1.ovpn&#xA;    echo &amp;#34;&amp;lt;/key&amp;gt;&amp;#34; &amp;gt;&amp;gt; ~/$1.ovpn&#xA;    echo &amp;#34;&amp;lt;tls-auth&amp;gt;&amp;#34; &amp;gt;&amp;gt; ~/$1.ovpn&#xA;    cat /etc/openvpn/ta.key &amp;gt;&amp;gt; ~/$1.ovpn&#xA;    echo &amp;#34;&amp;lt;/tls-auth&amp;gt;&amp;#34; &amp;gt;&amp;gt; ~/$1.ovpn&#xA;}&#xA;&#xA;# Try to get our IP from the system and fallback to the Internet.&#xA;# I do this to make the script compatible with NATed servers (lowendspirit.com)&#xA;# and to avoid getting an IPv6.&#xA;IP=$(ip addr | grep &amp;#39;inet&amp;#39; | grep -v inet6 | grep -vE &amp;#39;127\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}&amp;#39; | grep -o -E &amp;#39;[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}&amp;#39; | head -1)&#xA;VPCSUBNETDEFAULT=$(route -n | grep eth0 | grep 255.255| awk &amp;#39;{print $1,$3}&amp;#39; | tail -n 1| awk &amp;#39;{print $1}&amp;#39;)&#xA;VPCMASKDEFAULT=$(route -n | grep eth0 | grep 255.255| awk &amp;#39;{print $1,$3}&amp;#39; | tail -n 1| awk &amp;#39;{print $2}&amp;#39;)&#xA;&#xA;if [[ &amp;#34;$IP&amp;#34; = &amp;#34;&amp;#34; ]]; then&#xA;        IP=$(wget -4qO- &amp;#34;http://whatismyip.akamai.com/&amp;#34;)&#xA;fi&#xA;&#xA;if [[ -e /etc/openvpn/server.conf ]]; then&#xA;    while :&#xA;    do&#xA;    clear&#xA;        echo &amp;#34;Looks like OpenVPN is already installed&amp;#34;&#xA;        echo &amp;#34;&amp;#34;&#xA;        echo &amp;#34;What do you want to do?&amp;#34;&#xA;        echo &amp;#34;   1) Add a new user&amp;#34;&#xA;        echo &amp;#34;   2) Revoke an existing user&amp;#34;&#xA;        echo &amp;#34;   3) Remove OpenVPN&amp;#34;&#xA;        echo &amp;#34;   4) Exit&amp;#34;&#xA;        read -p &amp;#34;Select an option [1-4]: &amp;#34; option&#xA;        case $option in&#xA;            1)&#xA;            echo &amp;#34;&amp;#34;&#xA;            echo &amp;#34;Tell me a name for the client certificate&amp;#34;&#xA;            echo &amp;#34;Please, use one word only, no special characters&amp;#34;&#xA;            read -p &amp;#34;Client name: &amp;#34; -e -i netease-b CLIENT&#xA;            cd /etc/openvpn/easy-rsa/&#xA;            ./easyrsa build-client-full $CLIENT nopass&#xA;            # Generates the custom client.ovpn&#xA;            newclient &amp;#34;$CLIENT&amp;#34;&#xA;            echo &amp;#34;&amp;#34;&#xA;            echo &amp;#34;Client $CLIENT added, configuration is available at&amp;#34; ~/&amp;#34;$CLIENT.ovpn&amp;#34;&#xA;            exit&#xA;            ;;&#xA;            2)&#xA;            # This option could be documented a bit better and maybe even be simplimplified&#xA;            # ...but what can I say, I want some sleep too&#xA;            NUMBEROFCLIENTS=$(tail -n +2 /etc/openvpn/easy-rsa/pki/index.txt | grep -c &amp;#34;^V&amp;#34;)&#xA;            if [[ &amp;#34;$NUMBEROFCLIENTS&amp;#34; = &amp;#39;0&amp;#39; ]]; then&#xA;                echo &amp;#34;&amp;#34;&#xA;                echo &amp;#34;You have no existing clients!&amp;#34;&#xA;                exit 6&#xA;            fi&#xA;            echo &amp;#34;&amp;#34;&#xA;            echo &amp;#34;Select the existing client certificate you want to revoke&amp;#34;&#xA;            tail -n +2 /etc/openvpn/easy-rsa/pki/index.txt | grep &amp;#34;^V&amp;#34; | cut -d &amp;#39;=&amp;#39; -f 2 | nl -s &amp;#39;) &amp;#39;&#xA;            if [[ &amp;#34;$NUMBEROFCLIENTS&amp;#34; = &amp;#39;1&amp;#39; ]]; then&#xA;                read -p &amp;#34;Select one client [1]: &amp;#34; CLIENTNUMBER&#xA;            else&#xA;                read -p &amp;#34;Select one client [1-$NUMBEROFCLIENTS]: &amp;#34; CLIENTNUMBER&#xA;            fi&#xA;            CLIENT=$(tail -n +2 /etc/openvpn/easy-rsa/pki/index.txt | grep &amp;#34;^V&amp;#34; | cut -d &amp;#39;=&amp;#39; -f 2 | sed -n &amp;#34;$CLIENTNUMBER&amp;#34;p)&#xA;            cd /etc/openvpn/easy-rsa/&#xA;            ./easyrsa --batch revoke $CLIENT&#xA;            EASYRSA_CRL_DAYS=3650 ./easyrsa gen-crl&#xA;            rm -rf pki/reqs/$CLIENT.req&#xA;            rm -rf pki/private/$CLIENT.key&#xA;            rm -rf pki/issued/$CLIENT.crt&#xA;            rm -rf /etc/openvpn/crl.pem&#xA;            cp /etc/openvpn/easy-rsa/pki/crl.pem /etc/openvpn/crl.pem&#xA;            # CRL is read with each client connection, when OpenVPN is dropped to nobody&#xA;            chown nobody:$GROUPNAME /etc/openvpn/crl.pem&#xA;            echo &amp;#34;&amp;#34;&#xA;            echo &amp;#34;Certificate for client $CLIENT revoked&amp;#34;&#xA;            exit&#xA;            ;;&#xA;            3)&#xA;            echo &amp;#34;&amp;#34;&#xA;            read -p &amp;#34;Do you really want to remove OpenVPN? [y/n]: &amp;#34; -e -i n REMOVE&#xA;            if [[ &amp;#34;$REMOVE&amp;#34; = &amp;#39;y&amp;#39; ]]; then&#xA;                PORT=$(grep &amp;#39;^port &amp;#39; /etc/openvpn/server.conf | cut -d &amp;#34; &amp;#34; -f 2)&#xA;                PROTOCOL=$(grep &amp;#39;^proto &amp;#39; /etc/openvpn/server.conf | cut -d &amp;#34; &amp;#34; -f 2)&#xA;                if pgrep firewalld; then&#xA;                    IP=$(firewall-cmd --direct --get-rules ipv4 nat POSTROUTING | grep &amp;#39;\-s 10.8.0.0/24 &amp;#39;&amp;#34;&amp;#39;&amp;#34;&amp;#39;!&amp;#39;&amp;#34;&amp;#39;&amp;#34;&amp;#39; -d 10.8.0.0/24 -j SNAT --to &amp;#39; | cut -d &amp;#34; &amp;#34; -f 10)&#xA;                    # Using both permanent and not permanent rules to avoid a firewalld reload.&#xA;                    firewall-cmd --zone=public --remove-port=$PORT/$PROTOCOL&#xA;                    firewall-cmd --zone=trusted --remove-source=10.8.0.0/24&#xA;                    firewall-cmd --permanent --zone=public --remove-port=$PORT/$PROTOCOL&#xA;                    firewall-cmd --permanent --zone=trusted --remove-source=10.8.0.0/24&#xA;                    firewall-cmd --direct --remove-rule ipv4 nat POSTROUTING 0 -s 10.8.0.0/24 ! -d 10.8.0.0/24 -j SNAT --to $IP&#xA;                    firewall-cmd --permanent --direct --remove-rule ipv4 nat POSTROUTING 0 -s 10.8.0.0/24 ! -d 10.8.0.0/24 -j SNAT --to $IP&#xA;                else&#xA;                    IP=$(grep &amp;#39;iptables -t nat -A POSTROUTING -s 10.8.0.0/24 ! -d 10.8.0.0/24 -j SNAT --to &amp;#39; $RCLOCAL | cut -d &amp;#34; &amp;#34; -f 14)&#xA;                    iptables -t nat -D POSTROUTING -s 10.8.0.0/24 ! -d 10.8.0.0/24 -j SNAT --to $IP&#xA;                    sed -i &amp;#39;/iptables -t nat -A POSTROUTING -s 10.8.0.0\/24 ! -d 10.8.0.0\/24 -j SNAT --to /d&amp;#39; $RCLOCAL&#xA;                    if iptables -L -n | grep -qE &amp;#39;^ACCEPT&amp;#39;; then&#xA;                        iptables -D INPUT -p $PROTOCOL --dport $PORT -j ACCEPT&#xA;                        iptables -D FORWARD -s 10.8.0.0/24 -j ACCEPT&#xA;                        iptables -D FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT&#xA;                        sed -i &amp;#34;/iptables -I INPUT -p $PROTOCOL --dport $PORT -j ACCEPT/d&amp;#34; $RCLOCAL&#xA;                        sed -i &amp;#34;/iptables -I FORWARD -s 10.8.0.0\/24 -j ACCEPT/d&amp;#34; $RCLOCAL&#xA;                        sed -i &amp;#34;/iptables -I FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT/d&amp;#34; $RCLOCAL&#xA;                    fi&#xA;                fi&#xA;                if hash sestatus 2&amp;gt;/dev/null; then&#xA;                    if sestatus | grep &amp;#34;Current mode&amp;#34; | grep -qs &amp;#34;enforcing&amp;#34;; then&#xA;                        if [[ &amp;#34;$PORT&amp;#34; != &amp;#39;1194&amp;#39; || &amp;#34;$PROTOCOL&amp;#34; = &amp;#39;tcp&amp;#39; ]]; then&#xA;                            semanage port -d -t openvpn_port_t -p $PROTOCOL $PORT&#xA;                        fi&#xA;                    fi&#xA;                fi&#xA;                if [[ &amp;#34;$OS&amp;#34; = &amp;#39;debian&amp;#39; ]]; then&#xA;                    apt-get remove --purge -y openvpn&#xA;                else&#xA;                    yum remove openvpn -y&#xA;                fi&#xA;                rm -rf /etc/openvpn&#xA;                echo &amp;#34;&amp;#34;&#xA;                echo &amp;#34;OpenVPN removed!&amp;#34;&#xA;            else&#xA;                echo &amp;#34;&amp;#34;&#xA;                echo &amp;#34;Removal aborted!&amp;#34;&#xA;            fi&#xA;            exit&#xA;            ;;&#xA;            4) exit;;&#xA;        esac&#xA;    done&#xA;else&#xA;    clear&#xA;    echo &amp;#39;Welcome to this quick OpenVPN &amp;#34;road warrior&amp;#34; installer&amp;#39;&#xA;    echo &amp;#34;&amp;#34;&#xA;    # OpenVPN setup and first user creation&#xA;    echo &amp;#34;I need to ask you a few questions before starting the setup&amp;#34;&#xA;    echo &amp;#34;You can leave the default options and just press enter if you are ok with them&amp;#34;&#xA;    echo &amp;#34;&amp;#34;&#xA;    echo &amp;#34;First I need to know the IPv4 address of the network interface you want OpenVPN&amp;#34;&#xA;    echo &amp;#34;listening to.&amp;#34;&#xA;    read -p &amp;#34;IP address: &amp;#34; -e -i $IP IP&#xA;    echo &amp;#34;&amp;#34;    echo &amp;#34;Which protocol do you want for OpenVPN connections?&amp;#34;&#xA;&#xA;    echo &amp;#34;   1) UDP (recommended)&amp;#34;&#xA;    echo &amp;#34;   2) TCP&amp;#34;&#xA;    read -p &amp;#34;Protocol [1-2]: &amp;#34; -e -i 1 PROTOCOL&#xA;    case $PROTOCOL in&#xA;        1)&#xA;        PROTOCOL=udp&#xA;        ;;&#xA;        2)&#xA;        PROTOCOL=tcp&#xA;        ;;&#xA;    esac&#xA;    echo &amp;#34;&amp;#34;&#xA;    echo &amp;#34;What port do you want OpenVPN listening to?&amp;#34;&#xA;    read -p &amp;#34;Port: &amp;#34; -e -i 1194 PORT&#xA;    echo &amp;#34;&amp;#34;&#xA;    echo &amp;#34;what VPC subnet?&amp;#34;&#xA;    read -p &amp;#34;VPC subnet(E.g 172.16.0.0): &amp;#34; -e -i $VPCSUBNETDEFAULT  VPCSUBNET&#xA;    echo &amp;#34;&amp;#34;&#xA;    echo &amp;#34;what VPC mask?&amp;#34;&#xA;    read -p &amp;#34;VPC mask(E.g 255.255.0.0): &amp;#34; -e -i $VPCMASKDEFAULT  VPCMASK&#xA;    echo &amp;#34;&amp;#34;&#xA;    # echo &amp;#34;Which DNS do you want to use with the VPN?&amp;#34;&#xA;    # echo &amp;#34;   1) Current system resolvers&amp;#34;&#xA;    # echo &amp;#34;   2) Google&amp;#34;&#xA;    # echo &amp;#34;   3) OpenDNS&amp;#34;&#xA;    # echo &amp;#34;   4) NTT&amp;#34;&#xA;    # echo &amp;#34;   5) Hurricane Electric&amp;#34;&#xA;    # echo &amp;#34;   6) Verisign&amp;#34;&#xA;    # read -p &amp;#34;DNS [1-6]: &amp;#34; -e -i 1 DNS&#xA;    # echo &amp;#34;&amp;#34;&#xA;    echo &amp;#34;Finally, tell me your name for the client certificate&amp;#34;&#xA;    echo &amp;#34;Please, use one word only, no special characters&amp;#34;&#xA;    read -p &amp;#34;Client name: &amp;#34; -e -i netease-b CLIENT&#xA;    echo &amp;#34;&amp;#34;&#xA;    echo &amp;#34;Okay, that was all I needed. We are ready to setup your OpenVPN server now&amp;#34;&#xA;    read -n1 -r -p &amp;#34;Press any key to continue...&amp;#34;&#xA;    if [[ &amp;#34;$OS&amp;#34; = &amp;#39;debian&amp;#39; ]]; then&#xA;        apt-get update&#xA;        apt-get install openvpn iptables openssl ca-certificates -y&#xA;    else&#xA;        # Else, the distro is CentOS&#xA;        yum install epel-release -y&#xA;        yum install openvpn iptables openssl wget ca-certificates -y&#xA;    fi&#xA;    # An old version of easy-rsa was available by default in some openvpn packages&#xA;    if [[ -d /etc/openvpn/easy-rsa/ ]]; then&#xA;        rm -rf /etc/openvpn/easy-rsa/&#xA;    fi&#xA;    # Get easy-rsa&#xA;    wget -O ~/EasyRSA-3.0.4.tgz &amp;#34;https://nos-public.nos-eastchina1.126.net/EasyRSA-3.0.4.tgz&amp;#34;&#xA;    tar xzf ~/EasyRSA-3.0.4.tgz -C ~/&#xA;    mv ~/EasyRSA-3.0.4/ /etc/openvpn/&#xA;    mv /etc/openvpn/EasyRSA-3.0.4/ /etc/openvpn/easy-rsa/&#xA;    chown -R root:root /etc/openvpn/easy-rsa/&#xA;    rm -rf ~/EasyRSA-3.0.4.tgz&#xA;    cd /etc/openvpn/easy-rsa/&#xA;    # Create the PKI, set up the CA, the DH params and the server + client certificates&#xA;    ./easyrsa init-pki&#xA;    ./easyrsa --batch build-ca nopass&#xA;    ./easyrsa gen-dh&#xA;    ./easyrsa build-server-full server nopass&#xA;    ./easyrsa build-client-full $CLIENT nopass&#xA;    EASYRSA_CRL_DAYS=3650 ./easyrsa gen-crl&#xA;    # Move the stuff we need&#xA;    cp pki/ca.crt pki/private/ca.key pki/dh.pem pki/issued/server.crt pki/private/server.key pki/crl.pem /etc/openvpn&#xA;    # CRL is read with each client connection, when OpenVPN is dropped to nobody&#xA;    chown nobody:$GROUPNAME /etc/openvpn/crl.pem&#xA;    # Generate key for tls-auth&#xA;    openvpn --genkey --secret /etc/openvpn/ta.key&#xA;    # Generate server.conf&#xA;    echo &amp;#34;port $PORT&#xA;proto $PROTOCOL&#xA;dev tun&#xA;sndbuf 0&#xA;rcvbuf 0&#xA;ca ca.crt&#xA;cert server.crt&#xA;key server.key&#xA;dh dh.pem&#xA;auth SHA512&#xA;tls-auth ta.key 0&#xA;topology subnet&#xA;server 10.8.0.0 255.255.255.0&#xA;ifconfig-pool-persist ipp.txt&amp;#34; &amp;gt; /etc/openvpn/server.conf&#xA;    echo &amp;#34;push \&amp;#34;route $VPCSUBNET $VPCMASK vpn_gateway\&amp;#34;&amp;#34; &amp;gt;&amp;gt; /etc/openvpn/server.conf&#xA;    echo &amp;#34;keepalive 10 120&#xA;cipher AES-256-CBC&#xA;comp-lzo&#xA;user nobody&#xA;group $GROUPNAME&#xA;persist-key&#xA;duplicate-cn&#xA;max-clients 10&#xA;persist-tun&#xA;status openvpn-status.log&#xA;verb 3&#xA;crl-verify crl.pem&amp;#34; &amp;gt;&amp;gt; /etc/openvpn/server.conf&#xA;    # Enable net.ipv4.ip_forward for the system&#xA;    sed -i &amp;#39;/\&amp;lt;net.ipv4.ip_forward\&amp;gt;/c\net.ipv4.ip_forward=1&amp;#39; /etc/sysctl.conf&#xA;    if ! grep -q &amp;#34;\&amp;lt;net.ipv4.ip_forward\&amp;gt;&amp;#34; /etc/sysctl.conf; then&#xA;        echo &amp;#39;net.ipv4.ip_forward=1&amp;#39; &amp;gt;&amp;gt; /etc/sysctl.conf&#xA;    fi&#xA;    # Avoid an unneeded reboot&#xA;    echo 1 &amp;gt; /proc/sys/net/ipv4/ip_forward&#xA;    if pgrep firewalld; then&#xA;        # Using both permanent and not permanent rules to avoid a firewalld&#xA;        # reload.&#xA;        # We don&amp;#39;t use --add-service=openvpn because that would only work with&#xA;        # the default port and protocol.&#xA;        firewall-cmd --zone=public --add-port=$PORT/$PROTOCOL&#xA;        firewall-cmd --zone=trusted --add-source=10.8.0.0/24&#xA;        firewall-cmd --permanent --zone=public --add-port=$PORT/$PROTOCOL&#xA;        firewall-cmd --permanent --zone=trusted --add-source=10.8.0.0/24&#xA;        # Set NAT for the VPN subnet&#xA;        firewall-cmd --direct --add-rule ipv4 nat POSTROUTING 0 -s 10.8.0.0/24 ! -d 10.8.0.0/24 -j SNAT --to $IP&#xA;        firewall-cmd --permanent --direct --add-rule ipv4 nat POSTROUTING 0 -s 10.8.0.0/24 ! -d 10.8.0.0/24 -j SNAT --to $IP&#xA;    else&#xA;        # Needed to use rc.local with some systemd distros&#xA;        if [[ &amp;#34;$OS&amp;#34; = &amp;#39;debian&amp;#39; &amp;amp;&amp;amp; ! -e $RCLOCAL ]]; then&#xA;            echo &amp;#39;#!/bin/sh -e&#xA;exit 0&amp;#39; &amp;gt; $RCLOCAL&#xA;        fi&#xA;        chmod +x $RCLOCAL&#xA;        # Set NAT for the VPN subnet&#xA;        iptables -t nat -A POSTROUTING -s 10.8.0.0/24 ! -d 10.8.0.0/24 -j SNAT --to $IP&#xA;        sed -i &amp;#34;1 a\iptables -t nat -A POSTROUTING -s 10.8.0.0/24 ! -d 10.8.0.0/24 -j SNAT --to $IP&amp;#34; $RCLOCAL&#xA;        if iptables -L -n | grep -qE &amp;#39;^(REJECT|DROP)&amp;#39;; then&#xA;            # If iptables has at least one REJECT rule, we asume this is needed.&#xA;            # Not the best approach but I can&amp;#39;t think of other and this shouldn&amp;#39;t&#xA;            # cause problems.&#xA;            iptables -I INPUT -p $PROTOCOL --dport $PORT -j ACCEPT&#xA;            iptables -I FORWARD -s 10.8.0.0/24 -j ACCEPT&#xA;            iptables -I FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT&#xA;            sed -i &amp;#34;1 a\iptables -I INPUT -p $PROTOCOL --dport $PORT -j ACCEPT&amp;#34; $RCLOCAL&#xA;            sed -i &amp;#34;1 a\iptables -I FORWARD -s 10.8.0.0/24 -j ACCEPT&amp;#34; $RCLOCAL&#xA;            sed -i &amp;#34;1 a\iptables -I FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT&amp;#34; $RCLOCAL&#xA;        fi&#xA;    fi&#xA;    # If SELinux is enabled and a custom port or TCP was selected, we need this&#xA;    if hash sestatus 2&amp;gt;/dev/null; then&#xA;        if sestatus | grep &amp;#34;Current mode&amp;#34; | grep -qs &amp;#34;enforcing&amp;#34;; then&#xA;            if [[ &amp;#34;$PORT&amp;#34; != &amp;#39;1194&amp;#39; || &amp;#34;$PROTOCOL&amp;#34; = &amp;#39;tcp&amp;#39; ]]; then&#xA;                # semanage isn&amp;#39;t available in CentOS 6 by default&#xA;                if ! hash semanage 2&amp;gt;/dev/null; then&#xA;                    yum install policycoreutils-python -y&#xA;                fi&#xA;                semanage port -a -t openvpn_port_t -p $PROTOCOL $PORT&#xA;            fi&#xA;        fi&#xA;    fi&#xA;    # And finally, restart OpenVPN&#xA;    if [[ &amp;#34;$OS&amp;#34; = &amp;#39;debian&amp;#39; ]]; then&#xA;        # Little hack to check for systemd&#xA;        if pgrep systemd-journal; then&#xA;            systemctl restart openvpn@server.service&#xA;        else&#xA;            /etc/init.d/openvpn restart&#xA;        fi&#xA;    else&#xA;        if pgrep systemd-journal; then&#xA;            systemctl restart openvpn@server.service&#xA;            systemctl enable openvpn@server.service&#xA;        else&#xA;            service openvpn restart&#xA;            chkconfig openvpn on&#xA;        fi&#xA;    fi&#xA;    # Try to detect a NATed connection and ask about it to potential LowEndSpirit users&#xA;    EXTERNALIP=$(wget -4qO- &amp;#34;http://whatismyip.akamai.com/&amp;#34;)&#xA;    if [[ &amp;#34;$IP&amp;#34; != &amp;#34;$EXTERNALIP&amp;#34; ]]; then&#xA;        echo &amp;#34;&amp;#34;&#xA;        echo &amp;#34;Looks like your server is behind a NAT!&amp;#34;&#xA;        echo &amp;#34;&amp;#34;&#xA;        echo &amp;#34;If your server is NATed (e.g. LowEndSpirit), I need to know the external IP&amp;#34;&#xA;        echo &amp;#34;If that&amp;#39;s not the case, just ignore this and leave the next field blank&amp;#34;&#xA;        read -p &amp;#34;External IP: &amp;#34; -e -i $EXTERNALIP USEREXTERNALIP&#xA;        if [[ &amp;#34;$USEREXTERNALIP&amp;#34; != &amp;#34;&amp;#34; ]]; then&#xA;            IP=$USEREXTERNALIP&#xA;        fi&#xA;    fi&#xA;    # client-common.txt is created so we have a template to add further users later&#xA;    echo &amp;#34;client&#xA;dev tun&#xA;proto $PROTOCOL&#xA;sndbuf 0&#xA;rcvbuf 0&#xA;remote $IP $PORT&#xA;resolv-retry infinite&#xA;nobind&#xA;max-clients 10&#xA;persist-key&#xA;persist-tun&#xA;remote-cert-tls server&#xA;auth SHA512&#xA;cipher AES-256-CBC&#xA;comp-lzo&#xA;setenv opt block-outside-dns&#xA;key-direction 1&#xA;auth-nocache&#xA;verb 3&amp;#34; &amp;gt; /etc/openvpn/client-common.txt&#xA;    # Generates the custom client.ovpn&#xA;    newclient &amp;#34;$CLIENT&amp;#34;&#xA;    echo &amp;#34;&amp;#34;&#xA;    echo &amp;#34;Finished!&amp;#34;&#xA;    echo &amp;#34;&amp;#34;&#xA;    echo &amp;#34;Your client configuration is available at&amp;#34; ~/&amp;#34;$CLIENT.ovpn&amp;#34;&#xA;    echo &amp;#34;If you want to add more clients, you simply need to run this script again!&amp;#34;&#xA;fi&#xA;&lt;/code&gt;&lt;/pre&gt;</description>
    </item>
    <item>
      <title>安装软件包</title>
      <link>https://cncfstack.com/p/vpn/docs/ops/ops-install2/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://cncfstack.com/p/vpn/docs/ops/ops-install2/</guid>
      <description>&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;openssl openssl-devel lzo lzo-devel pam pam-devel automake pkgconfig makecache&#xA;yum -y install epel-release&#xA;yum -y install openvpn easy-rsa &#xA;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&lt;a href=&#34;https://www.163yun.com/help/documents/157215178789933056&#34;&gt;https://www.163yun.com/help/documents/157215178789933056&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&#34;https://openvpn.net/community-resources/how-to/#quick&#34;&gt;https://openvpn.net/community-resources/how-to/#quick&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&#34;https://qhh.me/2019/06/16/Cenos7-%E4%B8%8B%E6%90%AD%E5%BB%BA-OpenVPN-%E8%BF%87%E7%A8%8B%E8%AE%B0%E5%BD%95/&#34;&gt;https://qhh.me/2019/06/16/Cenos7-%E4%B8%8B%E6%90%AD%E5%BB%BA-OpenVPN-%E8%BF%87%E7%A8%8B%E8%AE%B0%E5%BD%95/&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;网易云部署方案&#xA;&lt;a href=&#34;https://www.163yun.com/help/documents/125681593272684544&#34;&gt;https://www.163yun.com/help/documents/125681593272684544&lt;/a&gt;&#xA;wget &lt;a href=&#34;https://nos-public.nos-eastchina1.126.net/vpn&#34;&gt;https://nos-public.nos-eastchina1.126.net/vpn&lt;/a&gt; -O openvpn-install.sh &amp;amp;&amp;amp; bash openvpn-install.sh&lt;/p&gt;&#xA;&lt;p&gt;官方安装脚本&#xA;&lt;a href=&#34;https://github.com/Angristan/OpenVPN-install&#34;&gt;https://github.com/Angristan/OpenVPN-install&lt;/a&gt;&lt;/p&gt;</description>
    </item>
    <item>
      <title>获取最新软件包</title>
      <link>https://cncfstack.com/p/vpn/docs/ops/vpn-install/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://cncfstack.com/p/vpn/docs/ops/vpn-install/</guid>
      <description>&lt;p&gt;openvpn提供了OpenVPN的核心&lt;/p&gt;&#xA;&lt;p&gt;easy-rsa包含了一些有用的密钥管理脚本&lt;/p&gt;&#xA;&lt;p&gt;dnsmasq是当我们的OpenVPN所在的主机将扮演客户端的路由器时会用到的域名服务器&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&#34;https://github.com/OpenVPN/openvpn/archive/v2.4.6.tar.gz&#34;&gt;https://github.com/OpenVPN/openvpn/archive/v2.4.6.tar.gz&lt;/a&gt;&#xA;&lt;a href=&#34;https://github.com/OpenVPN/easy-rsa/releases/download/v3.0.4/EasyRSA-3.0.4.tgz&#34;&gt;https://github.com/OpenVPN/easy-rsa/releases/download/v3.0.4/EasyRSA-3.0.4.tgz&lt;/a&gt;&lt;/p&gt;&#xA;&lt;h1 id=&#34;openvpn安装&#34;&gt;OpenVPN安装&lt;a class=&#34;td-heading-self-link&#34; href=&#34;#openvpn%e5%ae%89%e8%a3%85&#34; aria-label=&#34;Heading self-link&#34;&gt;&lt;/a&gt;&lt;/h1&gt;&#xA;&lt;p&gt;安装依赖&lt;/p&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;yum install lzo-devel autoconf pam-devel  automake libtool&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;编译安装&lt;/p&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;autoreconf -i -v -f&#xA;./configure --prefix=/usr/local/openvpn/&#xA;make&#xA;make install&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;h1 id=&#34;easyrsa-配置&#34;&gt;EasyRsa 配置&lt;a class=&#34;td-heading-self-link&#34; href=&#34;#easyrsa-%e9%85%8d%e7%bd%ae&#34; aria-label=&#34;Heading self-link&#34;&gt;&lt;/a&gt;&lt;/h1&gt;&#xA;&lt;h3 id=&#34;软件目录配置&#34;&gt;软件目录配置&lt;a class=&#34;td-heading-self-link&#34; href=&#34;#%e8%bd%af%e4%bb%b6%e7%9b%ae%e5%bd%95%e9%85%8d%e7%bd%ae&#34; aria-label=&#34;Heading self-link&#34;&gt;&lt;/a&gt;&lt;/h3&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;tar xf EasyRSA-3.0.4.tgz&#xA;mv EasyRSA-3.0.4.tgz /usr/local/openvpn/EasyRSA&#xA;cd /usr/local/openvpn/EasyRSA&#xA;cp vars.example vars&#xA;vim vars&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;h3 id=&#34;编辑vars文件&#34;&gt;编辑vars文件&lt;a class=&#34;td-heading-self-link&#34; href=&#34;#%e7%bc%96%e8%be%91vars%e6%96%87%e4%bb%b6&#34; aria-label=&#34;Heading self-link&#34;&gt;&lt;/a&gt;&lt;/h3&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;set_var EASYRSA_REQ_COUNTRY &amp;#34;CN&amp;#34;&#xA;set_var EASYRSA_REQ_PROVINCE &amp;#34;ZheJiang&amp;#34;&#xA;set_var EASYRSA_REQ_CITY &amp;#34;HangZhou&amp;#34;&#xA;set_var EASYRSA_REQ_ORG &amp;#34;test ORG&amp;#34;&#xA;set_var EASYRSA_REQ_EMAIL &amp;#34;admin@zhaowenyu.com&amp;#34;&#xA;set_var EASYRSA_REQ_OU &amp;#34;vinnyzhao&amp;#34;&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;h1 id=&#34;证书制作&#34;&gt;证书制作&lt;a class=&#34;td-heading-self-link&#34; href=&#34;#%e8%af%81%e4%b9%a6%e5%88%b6%e4%bd%9c&#34; aria-label=&#34;Heading self-link&#34;&gt;&lt;/a&gt;&lt;/h1&gt;&#xA;&lt;h3 id=&#34;自建ca认证体系&#34;&gt;自建CA认证体系&lt;a class=&#34;td-heading-self-link&#34; href=&#34;#%e8%87%aa%e5%bb%baca%e8%ae%a4%e8%af%81%e4%bd%93%e7%b3%bb&#34; aria-label=&#34;Heading self-link&#34;&gt;&lt;/a&gt;&lt;/h3&gt;&#xA;&lt;p&gt;1、初始化证书管理目录&#xA;进入/etc/openvpn/easy-rsa/easyrsa3/目录初始化：&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
