本教程展示瞭如何在 AlmaLinux 8 上安裝 OpenVPN 服務器。對於那些不熟悉的人,OpenVPN 是一個強大、安全的 IP 網絡隧道,通過單個 UDP 或 TCP 端口使用 OpenSSL 庫的所有加密、身份驗證和授權功能。靈活的開源 VPN 軟件。 VPN 可讓您安全地連接到公共的、不安全的網絡,例如機場或酒店的 Wi-Fi 網絡。企業和企業用戶通常需要某種 VPN 才能訪問其辦公室託管的服務。
本文假設您至少具有 Linux 的基本知識,知道如何使用 shell,最重要的是,您在自己的 VPS 上託管您的網站。 假設您在 root 帳戶下運行,安裝非常簡單。sudo
‘ 到命令以獲得 root 權限。 我們將逐步向您展示如何在 AlmaLinux 8 上安裝 OpenVPN。 對於 CentOS 和 Rocky Linux,您可以按照相同的步驟進行操作。
在 AlmaLinux 8 上安裝 OpenVPN 服務器
步驟1。首先,確保您的系統是最新的。
sudo dnf update sudo dnf install epel-release
步驟 2. 在 AlmaLinux 8 上安裝 OpenVPN 服務器。
安裝 OpenVPN 服務器很容易。通過運行以下命令從 GitHub 頁面下載安裝程序 OpenVPN:
curl -O https://raw.githubusercontent.com/angristan/openvpn-install/master/openvpn-install.sh
下載文件後,使其可執行並運行它。
chmod +x openvpn-install.sh ./openvpn-install.sh
該腳本以一系列問題開始安裝過程,然後是提示和用戶響應。
然後添加一個新客戶端,您將看到以下輸出屏幕,您需要在其中定義客戶端名稱。
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... Tell me a name for the client. The name must consist of alphanumeric character. It may also include an underscore or a dash. Client name: meilanamaria
接下來將詢問您是否要使用密碼保護配置文件。
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 meilanamaria added. The configuration file has been written to /home/user/idroot.ovpn. Download the .ovpn file and import it in your OpenVPN client.
步驟 3. 將客戶端連接到 OpenVPN 服務器
安裝成功後,下載 .ovpn 客戶端文件。 如果您使用的是 OpenVPN 客戶端的 shell 版本(無 GUI),請在指定 .ovpn 客戶端配置文件的文件名和位置的終端中運行 OpenVPN。
openvpn meilanamaria.ovpn
步驟 4. 配置您的防火牆。
AlmaLinux 帶有一個在首次啟動時運行的活動防火牆,因此為了能夠連接到您的 OpenVPN 服務器,您需要添加防火牆規則以允許 OpenVPN 連接到您的服務器。
sudo firewall-cmd --zone=trusted --add-service=openvpn sudo firewall-cmd --zone=trusted --permanent --add-service=openvpn sudo firewall-cmd --add-masquerade sudo firewall-cmd --permanent --add-masquerade sudo firewall-cmd --zone=trusted --permanent --add-port=1194/udp sudo firewall-cmd --reload
恭喜! 您已成功安裝 OpenVPN。感謝您使用本教程在您的 AlmaLinux 8 系統上安裝 OpenVPN 服務器。如需更多幫助或有用信息,我們建議您查看 OpenVPN官網.