MikroTik WireGuard VPN
2026-04-23 CCR1009 升級 RouterOS 7.15.3 + WireGuard server 設好,vampire iPhone 能透過 WG VPN 回家
MikroTik WireGuard VPN(2026-04-23 啟用)
硬體 + 版本
- 型號:CCR1009-7G-1C(企業版)
- RouterOS:7.15.3(stable,tile)
- 升級路徑:從 6.46.4 → 7.15.3,單次 reboot 升級,downtime ~1.5 分鐘
登入資訊
- 管理 IP:
192.168.88.1 - SSH / Winbox:
vampire / Iykou1FrEzCglFxk5x(2026-04-23 改強密碼) - 密碼檔備份:
~/jarvis/mikrotik-backup/password.txt(chmod 600) - Public DDNS:
84a207b6fc3b.sn.mynetname.net - Public IP:
1.164.34.175(動態會變,用 DDNS)
服務暴露限制(2026-04-23 安全修正)
- SSH / Winbox / WebFig 只允許
192.168.88.0/24, 10.77.0.0/24 - 公網打不到 admin 介面,只能從家裡 LAN 或 WireGuard VPN 進去
WireGuard Server
- Interface:
wg-home - Listen port:UDP
51820 - Server 公鑰:
UbZ+ZCld1F/Ca3WGz7TURd+COupTDB6bh3Y+rInmY2w= - VPN 網段:
10.77.0.0/24 - Server 在 VPN 網段的 IP:
10.77.0.1
Peer: vampire-iphone
- Allowed Address:
10.77.0.2/32 - iPhone config 存在:
/tmp/vampire-iphone-wg.conf - iPhone QR code:
/tmp/vampire-iphone-wg.png - ⚠️ 這些檔案包含私鑰,確認匯入後應該刪除
Firewall 設定
- input chain:allow UDP 51820(WireGuard handshake)
- forward chain:allow
in-interface=wg-home(VPN 進來的可以打 LAN)
用途
- iPhone 外網(4G/5G)→ WireGuard VPN 回家
- 連 Asterisk SIP(
192.168.88.10:5060)做真電話感對話 - 連 Jarvis voice server(
192.168.88.10:7860) - 連任何家裡 Mac Studio 上的服務
- 不用開 port 到公網、不用付錢
2026-04-23 03:13 狀態(vampire 要放假再處理)
- ✅ VPN handshake 成功(rx 25KB / tx 16KB)
- ✅ 在家 Wi-Fi 連 LAN 服務完全正常
- ❌ 4G CGNAT 擋 inbound — 中華電信 4G 雖然 Persistent keepalive=25 有設,但 server → iPhone 方向的 packet 被 drop
- Mac ping 10.77.0.2 = timeout
- MikroTik ping 10.77.0.2 = timeout
- 公網 bluefin.work 已經夠用跑單場景,VPN 暫時留著當在家 LAN-only 服務入口
放假後可試的路徑(debug CGNAT)
- 換 ISP 給的「公網 IP 方案」(中華電信 30 元/月)— 消除 CGNAT
- 換 WireGuard Endpoint 到 port 443(UDP 443,多數 carrier 不擋 443)
- 用 TCP 穿透(WireGuard 本身不支援 TCP,要加
wstunnel/udp2raw之類) - 改用 Tailscale(自帶 DERP relay 穿 CGNAT)
設定指令備份
/interface/wireguard/add name=wg-home listen-port=51820 mtu=1420
/ip/address/add address=10.77.0.1/24 interface=wg-home
/ip/firewall/filter/add chain=input protocol=udp dst-port=51820 action=accept comment="wireguard-in"
/ip/firewall/filter/add chain=forward in-interface=wg-home action=accept comment="wg-to-lan"
/ip/firewall/filter/move [find comment="wireguard-in"] 0
/ip/cloud/set ddns-enabled=yes
/interface/wireguard/peers/add interface=wg-home public-key="9tgqoR+DkuVIWyj/V0NWtCZinGGI4y5OLkuhuW24Hws=" allowed-address=10.77.0.2/32 comment="vampire-iphone"
備份
- 升級前 config 備份:
~/jarvis/mikrotik-backup/pre-upgrade-20260423.backup(29 KB)
How to apply
- vampire 提「VPN / WireGuard / 連回家 / 外網測試」→ 這條
- 家裡 Mac Studio 服務要外網測試時,iPhone 開 VPN 走
10.77.0.2直連192.168.88.10 - 要加更多裝置(電腦、平板)當 peer,用同樣流程產新 keypair