幫我們的粉絲專頁按個讚!
在 RouterOS 上建立 WireGuard VPN,並在 Windows 上進行連線
最近有從其他地方連線回到家中區網的需求,故撰寫此筆記
RouterOS 是什麼?
RouterOS 是一個由 MikroTik 開發的作業系統,專為路由器和網絡設備而設計
WireGuard 是什麼?
WireGuard 是一個簡單、快速且現代化的 VPN 實現,被廣泛部署並支援跨平台。傳統上,設定和部署 VPN 通常相當複雜,但 WireGuard 通過專注於其單一任務,並省略了密鑰分發和推送配置等步驟,大大簡化了這一過程
讓我們開始吧
在這邊我使用 RouterOS 7 版本以上的路由器作為 Server 端
接下來前往 WireGuard>WireGuard>add
先建立一個 WireGuard Interface,基本上填寫 Name 跟 Listen Port 即可,Private Key 跟 Public Key 留空讓他自行產生

按下OK,接者再次點開剛剛新增的那個 WireGuard Interface,這時會看到已經有產生出一組 Private Key 跟 Public Key,將 Public Key 複製存起來,待會會使用到

接下來前往 IP>Addresses>add
新增一個網段給這個 WireGuard Interface

接下來前往 IP>Firewall>Fliter Rules>add
新增一條規則,讓 WireGuard 服務可以通過 13231


接下來這邊以 Windows 版的 WireGuard 為例,開啟軟體後於左下角點選「新增隧道精靈」

這時候會產生一個空白的設定檔,下方的公鑰(Public Key)可以先記下來,等等會用到

接者將以下資訊帶入設定檔中
[interface]
PrivateKey = #建立空白設定檔時自動產生
Address = #連上後的內部IP
DNS = #使用 cLoudflare 的 1.1.1.1, 1.0.0.1
[Peer]
PublicKey = #剛剛在RouterOS產生的公鑰(Public Key)
AllowedIPs = #設定哪些IP網段要透過VPN連線,這邊設定所有流量
Endpoint = #伺服器IP:Port
PersistentKeepalive = #60秒

接下來回到 RouterOS,為剛剛新增的 WireGuard Interface 增加一個 Peer
前往 WireGuard>Peers>add,在 Public Key 填寫剛剛在 Windows 上設定檔產生的公鑰,Allowed Address 填寫剛剛設定檔寫的 192.168.88.21/32,Persistent Keepalive填寫1分鐘(60秒)

最後,在 Windows 上啟用 WireGuard 的 VPN 連線

聽說有隻叫做夜空藍喵の夜喵
這位編輯懶到什麼自我介紹也沒打...