docs: add NetBird as SSH whitelist alternative + StrongHotpink-VM case

External VM 141.11.93.252 had SSH locked to specific source IPs
(tailscale0, HiNet WAN, one other). Mac couldn't reach it from
other ISPs. Solved by joining the VM to our NetBird mesh and adding
an iptables ACCEPT rule for wt0:22.

Run into the same Tailscale kernel-mode iptables-legacy collision
already documented in peer-deployment-ops.md — systemd oneshot
workaround fixed it.

Doc now describes both the temporary ProxyJump solution and the
permanent mesh-membership solution, plus a config strategy of
retiring per-IP whitelists in favor of a single wt0 ACCEPT rule.
This commit is contained in:
2026-04-18 23:02:27 +08:00
parent b6138095f0
commit dcbaa1b41d

View File

@@ -78,3 +78,67 @@ netbird ssh ct100.netbird.selfhosted
- **Dashboard "SSH Access" disabled 跟你 SSH 得不得進去沒關係** — 前者是 NetBird 自己的通道功能,後者是你一般用的 SSH
- 家用環境通常**不需要啟用** NetBird SSH用原生 OpenSSH 就夠
- 有需要再開,兩種不衝突,可以並存
## 實務應用:用 NetBird 取代 SSH 源 IP 白名單
### 情境
遠端 VM 的 SSH (port 22) 被 iptables 白名單限制只有特定源 IP 能進:
```
ACCEPT tailscale0 * 0.0.0.0/0 tcp dpt:22 /* via Tailscale */
ACCEPT * * 211.23.141.206 tcp dpt:22 /* specific IP */
ACCEPT * * 125.229.110.50 tcp dpt:22 /* HiNet WAN */
DROP * * 0.0.0.0/0 tcp dpt:22 /* drop everything else */
```
你的 Mac 從咖啡店連不到,因為當下 ISP 出口 IP 不在白名單。
### 兩個解法對比
**A. 暫時跳板**(不改遠端 VM
```
ssh -J root@<whitelisted-peer>.netbird.selfhosted root@141.11.93.252
```
Mac → NetBird → 家裡有白名單的 peer → 借它的公網 IP → VM。原生 OpenSSH 的 `ProxyJump`,跟 NetBird 的 SSH Access 功能無關。
**B. 把 VM 加進 NetBird mesh**(長期治本):
1. 在 VM 部署 NetBird client 容器(見 `peer-deployment-ops.md`
2. 在 VM 的 iptables 加一條鏡像 tailscale0 的規則:
```
iptables -I INPUT <位置> -i wt0 -p tcp --dport 22 -j ACCEPT \
-m comment --comment "Allow SSH from NetBird interface"
```
插入點在「DROP all other SSH」那條之前
3. 之後 Mac / iPhone / 任何 NetBird peer 都能直接 SSH 到 VM**不用再跳板**
### 本部署的實例StrongHotpink-VM2026-04-18
`141.11.93.252` 這台 VM 原本 SSH port 22 只認 `tailscale0` + `211.23.141.206` + HiNet。Mac 從另一個 ISP 連不到。採用方案 B
- NetBird IP `100.71.121.88`FQDN `stronghotpink-vm.netbird.selfhosted`
- 加 `iptables -I INPUT <位置> -i wt0 -p tcp --dport 22 -j ACCEPT`
- 踩到同一個 **Tailscale kernel-mode iptables-legacy 衝突**(見 `peer-deployment-ops.md`),加 systemd oneshot 解決
- `auto_groups=[servers]` 直接進正確 grouppolicy 自動套用
結果Mac 直接 `ssh root@stronghotpink-vm.netbird.selfhosted` 即可進入RTT ~175ms走 Relay跨區 P2P 不易打通但不影響 SSH
### 配置策略建議
遠端 VM 的 SSH 白名單**保留 NetBird interface 這條**、**砍掉固定 IP 白名單**
```diff
ACCEPT tailscale0 * tcp dpt:22
+ ACCEPT wt0 * tcp dpt:22
- ACCEPT * * 211.23.141.206 tcp dpt:22 ← 砍掉
- ACCEPT * * 125.229.110.50 tcp dpt:22 ← 砍掉
DROP * * 0.0.0.0/0 tcp dpt:22
```
好處:
- 不用再維護公網 IP 白名單HiNet 動態 IP 變了就斷線)
- SSH 強制走 overlay 網路,減少暴露面
- 新加入的 NetBird peer增加新裝置自動取得存取權不用改防火牆