logo 2021

VPN - WireGuard 一鍵安裝及設置,包含除錯!

Edward
28/10/19
4

WireGuard 是比較新一代的 VPN 工具,在 Youtube 上看了網友做了 SS 、V2Ray、WireGuard 和 OPENVPN 的測試,出來的效果還是不錯的,WireGuard的位置在 OPENVPN 之上及SS 、V2Ray之下。但是基本上 OPENVPN 和 SS 在中國的防火牆下輕易地識穿,裝了 VPN 的外部翻牆 IP 基本都會被鎖,至於 V2Ray 和 WireGuard 來說中獎的機相對沒有那麼高。

個人試了不同的 VPN 軟件包,結果還是覺得 WireGuard 用起來比較順心,這一次使用的一鍵安裝包也是出自於 Github Angristan 的手筆,只需要幾步就可以搞定。

支持裝的 Linux 系統:

  • Ubuntu
  • Debian
  • Fedora
  • Centos
  • Arch Linux

STEP 1. (下載安裝包及設定可執行的權限)

curl -O https://raw.githubusercontent.com/angristan/wireguard-install/master/wireguard-install.sh
chmod +x wireguard-install.sh

STEP 2. (開始安裝)

./wireguard-install.sh

OK . 如果你沒有遇到問題的話,現在就可以下載第一個設定檔 xxxx.conf 到你的 WireGuard 客戶端後開始體驗!

 

小弟我自己在不同的雲端服務商測試安裝的時候(主要是Debian 9 @.@"),遇到了不少的問題,如果你也同樣遇到的話,歡迎繼續看下去!

問題一 : 下載完 .conf 檔案及載入了用戶端後卻不能連線

  • 檢查 Peer 的 Endpoint ,也即是你的服務端的公開 IP ,修改後應該可能解決。
  • 本身服務端 (VPS/SERVER) 的防火牆沒開放,上面的預設 Port 為 57431 。
  • 使用 AWS / GCP 的用戶要到他們的後台開放 IP 及 Port 。

 

問題二 : 如何生成新的客戶端文件

在 Linux 生成密匙

umask 077
wg genkey | tee privatekey | wg pubkey > publickey

整個直接貼到SSH上後按 ENTER,之後到 Root 目錄下載 client2 的文件即可

echo"
[Interface]
PrivateKey = $(cat privatekey)
Address = 10.0.0.3/24
DNS = 8.8.8.8
MTU = 1420

[Peer]
PublicKey = $(cat publickey)
Endpoint = xxx.xxx.xxx.xxx:57431
AllowedIPs = 0.0.0.0/0, ::0/0
PersistentKeepalive = 25" > client2.conf

其中 8.8.8.8 為 Google 的免費 DNS ,可使用別家的 。xxx.xxx.xxx.xxx 修改成你的服務器公開IP。

 

問題三 : 安裝時報錯,沒有完成整個過程。

可試試運行以下指令,應該可以解決很多問題 ;P

sudo apt-get update
sudo apt-get upgrade

更新完成後重新啟動服務器再進行安裝。

 

官方其他安裝方法:https://www.wireguard.com/install/

Leave a Reply

Your email address will not be published. Required fields are marked *

16 + 15 =

4 comments on “VPN - WireGuard 一鍵安裝及設置,包含除錯!”

  1. 您好,想請問WireGuard客戶端設定AllowedIPs=1.2.3.4後,ping 1.2.3.4有經過WireGuard的Server轉發。
    但不知為何,1.2.3.4 ping 客戶端卻ping不通,像是被drop掉了一般,請問您知道該如何解決嗎?

      1. 防火牆有開放端口。
        目前有3台VPS,三台都是公網IP
        Client IP: 1.1.1.1
        VPN IP : 2.2.2.2
        Other IP : 3.3.3.3

        已於2.2.2.2這台架好WG-Server,1.1.1.1這台設定AllowedIPs= 3.3.3.3,
        在1.1.1.1這台可以透過WG-Server(2.2.2.2)中轉連線至3.3.3.3,
        但是3.3.3.3這台卻無法主動連上1.1.1.1,
        1.1.1.1關閉WireGuard後,3.3.3.3才能連上1.1.1.1。

        查了一下2.2.2.2這台的路由表,開啟WireGuard後會增加幾條
        default via 172.31.1.1 dev eth0
        3.3.3.3 dev wg-client scope link
        172.31.1.1 dev eth0 scope link
        192.168.100.0/24 dev wg-client proto kernel scope link src 192.168.100.2

        把第二條刪除,3.3.3.3就能連上1.1.1.1,但1.1.1.1也無法透過WG-Server(2.2.2.2)中轉連線至3.3.3.3了。(等於關閉WG-Server...)

Error!
No 'Wpcc_Widget' widget registered in this installation.

新的網站UI還在努力中,有任何意見歡迎來郵!
Copyright © 2021 TheFinalX all rights reserved.
menu