Netbird 组网搭建

官网文档:https://github.com/netbirdio/netbird

搞这个平台是因为之前遇到了很多网络链接上面的问题,在公司用家里虚拟化的 N 多个虚拟机测试时,很不方便。

还有就是在家连接公司的局域网时还要留个口子,总感觉很麻烦。现在用 Netbird 完全解决了这个问题

Netbird 自建平台

前置条件:

  • 一个拥有公网 IP 的 Linux 服务器;

  • Docker 与 docker-compose;

  • 开放 TCP 端口 80, 443, 33073, 10000(端口不可被占用);

  • 开放 UDP 端口 3478, 49152-65535

  • 配置好了 DNS 解析

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
mkdir netbird && cd netbird

# 前置安装软件
yum install jq && yum install curl
curl -o /etc/yum.repos.d/docker-ce.repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum install docker-ce-20.10.12 -y
systemctl enable docker && systemctl start docker
wget https://github.com/docker/compose/releases/download/1.28.6/docker-compose-Linux-x86_64
chmod +x docker-compose-Linux-x86_64
mv docker-compose-Linux-x86_64 /usr/local/sbin/docker-compose
docker-compose version

# 一键部署
export NETBIRD_DOMAIN=net.domain.com; curl -fsSL https://github.com/netbirdio/netbird/releases/latest/download/getting-started-with-zitadel.sh | bash

# 浏览器访问按照账号密码登陆即可

添加节点

官网文档:https://docs.netbird.io/how-to/getting-started#installation

Ubuntu/Debian
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# Add the repository
sudo apt-get update
sudo apt-get install ca-certificates curl gnupg -y
curl -sSL https://pkgs.netbird.io/debian/public.key | sudo gpg --dearmor --output /usr/share/keyrings/netbird-archive-keyring.gpg
echo 'deb [signed-by=/usr/share/keyrings/netbird-archive-keyring.gpg] https://pkgs.netbird.io/debian stable main' | sudo tee /etc/apt/sources.list.d/netbird.list

# Update APT's cache
sudo apt-get update

# Install the package
# for CLI only
sudo apt-get install netbird
# for GUI package
sudo apt-get install netbird-ui

# 在主页面添加一个 Setup Keys
# Run NetBird and log in the browser
netbird up --management-url https://net.yuanhome.space:443 --setup-key <SETUP KEY>
RPM/Red hat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# Add the repository
vim /etc/yum.repos.d/netbird.repo
[netbird]
name=netbird
baseurl=https://pkgs.netbird.io/yum/
enabled=1
gpgcheck=0
gpgkey=https://pkgs.netbird.io/yum/repodata/repomd.xml.key
repo_gpgcheck=1

# Install the package
# for CLI only
sudo yum install netbird
# for GUI package
sudo yum install netbird-ui

# 在主页面添加一个 Setup Keys
# Run NetBird and log in the browser
netbird up --management-url https://net.yuanhome.space:443 --setup-key <SETUP KEY>