落雨宸的时光机
316 字
2 分钟
仅 IP、无域名、无证书部署 NetBird 官方 Relay
2026-03-15
...

References:

netbird/issues/3640

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

  1. 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"
    
  2. 删掉 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/
作者
落雨宸
发布于
2026-03-15
许可协议
CC BY-NC-SA 4.0


Loading Comment Component...