本教程將向您展示如何在 Debian 9 Stretch 上安裝 OpenVPN。對於那些不知道的人,OpenVPN 是一種廣泛使用的開源應用程序,用於在不安全的公共 Internet 上創建安全的虛擬專用網絡。 OpenVPN 是一種 SSL VPN 解決方案,可通過 Internet 安全地排出系統連接。 OpenVPN 採用客戶端-服務器結構。連接到虛擬專用網絡的所有設備的行為就像它們連接到局域網一樣。 通過 VPN 隧道發送的數據包使用 256 位 AES 加密進行加密,以防止數據被盜。
本文假設您至少具有 Linux 的基本知識,知道如何使用 shell,最重要的是,將您的網站託管在您的 VPS 上。安裝非常簡單,假設您在 root 帳戶下運行。如果沒有,您需要添加一個’。sudo
‘向命令獲取root權限。 我們將引導您在 Debian 9 (Stretch) 服務器上安裝 OpenVPN。
在 Debian 9 Stretch 上安裝 OpenVPN
步驟1。在安裝軟件之前,運行以下命令以確保您的系統是最新的很重要。 apt-get
終端命令:
apt-get update apt-get upgrade
步驟 2. 在 Debian 9 上安裝 OpenVPN。
注意:本教程使用 IP 地址。例如,公網 IP 為 216.58.197.67。
首先,下載 Debian 的 OpenVPN Road Warriors 安裝程序。
wget https://git.io/vpn -O openvpn-install.sh
下載後,運行 OpenVPN-install.sh 腳本來安裝和配置 OpenVPN 服務器。
bash openvpn-install.sh
系統將提示您輸入 IP 地址、端口等。請務必將 IP 地址更改為公共 IP 地址。
Welcome to this quick OpenVPN "road warrior" installer 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 First I need to know the IPv4 address of the network interface you want OpenVPN listening to. IP address: 216.58.197.67 Which protocol do you want for OpenVPN connections? 1) UDP (recommended) 2) TCP Protocol [1-2]: 1 What port do you want OpenVPN listening to? Port: 1194 Which DNS do you want to use with the VPN? 1) Current system resolvers 2) Google 3) OpenDNS 4) NTT 5) Hurricane Electric 6) Verisign DNS [1-6]: 2 Finally, tell me your name for the client certificate Please, use one word only, no special characters Client name: idroot-openvpn Okay, that was all I needed. We are ready to setup your OpenVPN server now Press any key to continue...
至此,OpenVPN 服務器已準備就緒。現在您可以看到防火牆規則。
cat /etc/rc.local
樣本輸出:
#!/bin/sh -e iptables -I FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT iptables -I FORWARD -s 10.8.0.0/24 -j ACCEPT iptables -I INPUT -p udp --dport 1194 -j ACCEPT iptables -t nat -A POSTROUTING -s 10.8.0.0/24 ! -d 10.8.0.0/24 -j SNAT --to 139.59.105.37 exit 0
然後啟用並啟動 OpenVPN 服務。
## start service ## systemctl start [email protected] ## stop service ## systemctl stop [email protected] ## check status ## systemctl status [email protected]
您現在可以下載 ovpn 配置文件。該文件用於連接服務器。 您可以使用 SCP 命令執行此操作。
scp [email protected]:~/idroot-openvpn.ovpn /home/godet/Desktop
恭喜! OpenVPN 現已成功安裝。感謝您使用本教程在您的 Debian 9 Stretch 服務器上安裝 OpenVPN。我們鼓勵您查看更多幫助和有用信息。 OpenVPN官網..