Proton VPN 首頁

如何在 MikroTik 路由器上使用 WireGuard 設定 Proton VPN

閱讀
1 分鐘
類別
路由器

您可以在 MikroTik 路由器上設定 Proton VPN,這樣所有透過該路由器連線至網際網路的裝置都會受到 Proton VPN 的保護。

在本指南中,我們將向您說明如何在執行 RouterOS 7 的 MikroTik 路由器上使用 WireGuard VPN 協定。這需要 Proton VPN 帳號

如何在 MikroTik 路由器上設定 Proton VPN WireGuard® (更新)

1. 下載 WireGuard 組態檔案

使用任何文字編輯器將其開啟。

了解如何從 Proton VPN 下載 WireGuard 組態檔案

請注意,您無法使用已儲存的組態檔案。Proton VPN 從不儲存您的私有金鑰,因此已儲存的組態檔案中並未包含這些金鑰。您必須建立並下載新的組態檔案。

2. 開啟 MikroTik 組態面板

若要執行此操作,請開啟命令列 (在 Linux 和 macOS 上使用 Terminal,或在 Windows 上使用 PowerShell) 並輸入:

ssh user@192.168.88.1

閱讀更多關於在 MikroTik 上使用命令列的資訊(新視窗)

3. 建立新的 WireGuard 介面

使用命令列輸入以下文字,然後點擊 。若要尋找您的私有金鑰,請在步驟 1 下載的 WireGuard 組態檔案中尋找開頭為 PrivateKey= 的行。

/interface wireguard
add listen-port=13231 mtu=1420 name=wireguard-inet private-key=”您的私有金鑰”

接下來的所有步驟都將需要您在命令列中輸入命令。

4. 將 IP 位址加入您剛建立的介面:

/ip address
add address=10.2.0.2/30 interface=wireguard-inet network=10.2.0.0

5. 將 WireGuard 伺服器加入為對等端

加入來自 WireGuard 組態檔案的端點位址、端點連接埠和公開金鑰。尋找開頭為 PublicKey=Endpoint= 的行。

例如,如果組態顯示 Endpoint=103.107.197.2:51820,請輸入 endpoint-address=103.107.197.2 和 endpoint-port=51820

/interface wireguard peers
add allowed-address=0.0.0.0/0 endpoint-address=x.x.x.x endpoint-port=xxxxx interface=wireguard-inet persistent-keepalive=25s public-key="您的公開金鑰"

6. 啟用該介面的偽裝功能

注意:此設定假設您使用的是 MikroTik 預設的本機網路位址。如果您已變更此位址,請改將該位址用於 scr-address=

/ip firewall nat
add action=masquerade chain=srcnat out-interface=wireguard-inet src-address=192.168.88.0/24

7. 透過 WireGuard 重新導向所有網路流量

/ip route
add disabled=no distance=1 dst-address=0.0.0.0/1 gateway=10.2.0.1 pref-src="" routing-table=main scope=30 suppress-hw-offload=no target-scope=10
add disabled=no distance=1 dst-address=128.0.0.0/1 gateway=10.2.0.1 pref-src="" routing-table=main scope=30 suppress-hw-offload=no target-scope=10

8. 設定 DNS 設定

/ip dns
set servers=10.2.0.1
/ip dhcp-client
set 0 use-peer-dns=no

9. 透過主要供應商的閘道重新導向 WireGuard IP 位址

x.x.x.x 替換為 來自組態檔案的端點位址 (Endpoint=)。

/ip route
add disabled=no dst-address=x.x.x.x/32 gateway=[/ip dhcp-client get [find interface=ether1] gateway] routing-table=main suppress-hw-offload=no

如果無法正常運作,您需要將 gateway=[/ip dhcp-client get [find interface=ether1] gateway] 替換為 gateway=x.x.x.x,其中 x.x.x.x 是您自己的網際網路閘道位址。您的網際網路服務供應商 (ISP) 應該能夠提供此位址。

10. 重新啟動您的路由器

這樣就完成了!您的路由器現在應該會使用 Proton VPN 保護其提供的所有網際網路連線。