316 字
2 分钟
仅 IP、无域名、无证书部署 NetBird 官方 Relay
References:
1. Prologue
自建的 NetBird 是无法使用官方 Relay 的,需要另行搭建。而 官方文档 中给出的都是域名+证书的 Relay 搭建方式,没有纯 IP 的部署方法……吗?其实是有的,但是几乎没有人提到过。
官方的 rels:// 是 Secure 的链接,而实际上还有 rel:// 的 Insecure 链接。这在官方文档并未提及,但是它是可用的。
2. 部署 Relay
在你想要部署 Relay 的中转服务器上,写 docker-compose.yaml:
services:
relay:
image: netbirdio/relay:latest
restart: unless-stopped
network_mode: host
environment:
- NB_LOG_LEVEL=info
- NB_LISTEN_ADDRESS=:30030
- NB_EXPOSED_ADDRESS=rel://<IP>:30030
- NB_AUTH_SECRET=<YOUR_AUTH_SECRET>
- NB_ENABLE_STUN=true
- NB_STUN_PORTS=3478
logging:
driver: "json-file"
options:
max-size: "2m"
max-file: "2"
注意:
- 是
rel://,而不是rels://。 - 如果你要部署多台 Relay,请确保所有机器上的
<YOUR_AUTH_SECRET>相同! - 然后打开端口:30030, 3478/udp。
搞定!
国内服务器也可用~
3. 注册 Relay
在你的 Management 面板服务器上,修改 config.yaml:
- 在
servers:里面,添加:stuns: - uri: "stun:<IP>:3478" proto: "udp" - uri: "stun:stun.l.google.com:19302" proto: "udp" - uri: "stun:stun.freeswitch.org:3478" proto: "udp" - uri: "stun:stun.xten.com:3478" proto: "udp" relays: addresses: - "rel://<IP>:30030" secret: "<YOUR_AUTH_SECRET>" credentialsTTL: "24h" - 删掉
authSecret字段:因为添加 relay 字段后,内置 Relay 会自动失效。
重启 Management 服务器后,应该就能在所有节点的 netbird status -d 中看到你的 Relay 了。
Relays:
[stun:<IP>:3478] is Checking...
[stun:stun.l.google.com:19302] is Checking...
[stun:stun.freeswitch.org:3478] is Checking...
[stun:stun.xten.com:3478] is Checking...
[rel://<IP>:30030] is Available
仅 IP、无域名、无证书部署 NetBird 官方 Relay
https://blog.lzc256.com/posts/deploying-netbird-relay-servers-with-ip-only-insecurely/Loading Comment Component...
