#curl -O https://raw.githubusercontent.com/Angristan/openvpn-install/master/openvpn-install.sh
Welcome to the OpenVPN installer! The git repository is available at: https://github.com/angristan/openvpn-install I need to ask you a few questions before starting the setup. You can leave the default options and just press enter if you are ok with them. I need to know the IPv4 address of the network interface you want OpenVPN listening to. Unless your server is behind NAT, it should be your public IPv4 address. IP address: 172.21.169.208 (内網IP) It seems this server is behind NAT. What is its public IPv4 address or hostname? We need it for the clients to connect to the server. Public IPv4 address or hostname: 4X.X4.XX.175 (外網IP) Checking for IPv6 connectivity... Your host does not appear to have IPv6 connectivity. Do you want to enable IPv6 support (NAT)? [y/n]: n (不支援IPv6) What port do you want OpenVPN to listen to? 1) Default: 1194 2) Custom 3) Random [49152-65535] Port choice [1-3]: 2 (使用自定Port) Custom port [1-65535]: 443 What protocol do you want OpenVPN to use? UDP is faster. Unless it is not available, you shouldn't use TCP. 1) UDP 2) TCP Protocol [1-2]: 2 (使用TCP) What DNS resolvers do you want to use with the VPN? 1) Current system resolvers (from /etc/resolv.conf) 2) Self-hosted DNS Resolver (Unbound) 3) Cloudflare (Anycast: worldwide) 4) Quad9 (Anycast: worldwide) 5) Quad9 uncensored (Anycast: worldwide) 6) FDN (France) 7) DNS.WATCH (Germany) 8) OpenDNS (Anycast: worldwide) 9) Google (Anycast: worldwide) 10) Yandex Basic (Russia) 11) AdGuard DNS (Russia) DNS [1-10]: 3 (使用DNS) Do you want to use compression? It is not recommended since the VORACLE attack make use of it. Enable compression? [y/n]: y (是否壓縮) Choose which compression algorithm you want to use: 1) LZ4 (more efficient) 2) LZ0 Compression algorithm [1-2]: 1 (壓縮演算法) Do you want to customize encryption settings? Unless you know what you're doing, you should stick with the default parameters provided by the script. Note that whatever you choose, all the choices presented in the script are safe. (Unlike OpenVPN's defaults) See https://github.com/angristan/openvpn-install#security-and-encryption to learn more. Customize encryption settings? [y/n]: n (加密設定是否要調整) Okay, that was all I needed. We are ready to setup your OpenVPN server now. You will be able to generate a client at the end of the installation. Press any key to continue...
b.VPN後所有Internet流量全部經過openvpn主機 (Route All Traffic)
Tell me a name for the client. Use one word only, no special characters. Client name: fred (建立fred帳戶) Do you want to protect the configuration file with a password? (e.g. encrypt the private key with a password) 1) Add a passwordless client 2) Use a password for the client Select an option [1-2]: 1 (是否需要密碼登入)
Client fred added, the configuration file is available at /root/fred.ovpn. Download the .ovpn file and import it in your OpenVPN client. If you want to add more clients, you simply need to run this script another time!
#openvpn --config /root/fred.ovpn --resolv-retry infinite