【Zerotier】自建PLANET服务器内网地址连接

之前已经完成了【Zerotier】通过docker自建PLANET服务器,但是遇到一个问题,因为各种原因,内网里面的ZeroTier Client无法通过PLANET服务器的公网地址连接,愁怀了这下。在经过多方测试验证后,可以采取重新生成一个PLANET文件来解决,具体方法如下:

环境:Ubuntu 22.04

  1. 安装编译组件
bash 复制代码
apt install gcc g++ -y
  1. 下载源码
bash 复制代码
git clone https://github.com/zerotier/ZeroTierOne
  1. 修改源码
    找到ZeroTierOne/attic/world/mkworld.cpp并打开,仿照mkworld.cpp原来的代码,将我们自定义的Planet服务器添加进去。注意,需要删除或注释掉原来的Planet服务器,再增加自己的服务器,否则后续执行我们编译的可执行程序时程序会崩溃。
bash 复制代码
// =========================================================================
// EDIT BELOW HERE

std::vector<World::Root> roots;

const uint64_t id = ZT_WORLD_ID_EARTH;
const uint64_t ts = 1567191349589ULL; // August 30th, 2019

// Test.com
roots.push_back(World::Root());
roots.back().identity = Identity("填写identity.public里的字符串");
roots.back().stableEndpoints.push_back(InetAddress("服务器内网ip地址/通讯端口"));

// END WORLD DEFINITION
// =========================================================================

如果是按照之前的安装的,identity.public的位置可以通过以下去找到:

bash 复制代码
root@X-01:/home/x# docker volume inspect zerotier-one
[
    {
        "CreatedAt": "2023-12-13T13:56:21+08:00",
        "Driver": "local",
        "Labels": {
            "com.docker.volume.anonymous": ""
        },
        "Mountpoint": "/var/lib/docker/volumes/zerotier-one/_data",
        "Name": "zerotier-one",
        "Options": null,
        "Scope": "local"
    }
]
root@X-01:/home/x# cat /var/lib/docker/volumes/zerotier-one/_data/identity.public
1316eeb56a:0:2e5ced97a6c0fd1256c4a2acd4db4bb89c2a21029cd4902252552ec5e7c67b6e14da2f3d7d11bf27d317e970a1992ddc186e48960814796a1e1fdcc6d72a1dcc
root@X-01:/home/x#
  1. 编译配置文件
bash 复制代码
 cd ./ZeroTierOne/attic/world/
 source ./build.sh
 ./mkworld
 mv ./world.bin ./planet
  1. 替换客户端中PLANET文件,重启服务,内网设备即可通过内网地址去连接PLANET了。
相关推荐
m0_7482540935 分钟前
2025最新华为云国际版注册图文流程-不用绑定海外信用卡注册
服务器·数据库·华为云
MUY099044 分钟前
应用控制技术、内容审计技术、AAA服务器技术
运维·服务器
楠奕1 小时前
elasticsearch8.12.0安装分词
运维·jenkins
Sadsvit1 小时前
源码编译安装LAMP架构并部署WordPress(CentOS 7)
linux·运维·服务器·架构·centos
java资料站1 小时前
Jenkins
运维·jenkins
苦学编程的谢2 小时前
Linux
linux·运维·服务器
G_H_S_3_2 小时前
【网络运维】Linux 文本处理利器:sed 命令
linux·运维·网络·操作文本
拾心212 小时前
【运维进阶】Linux 正则表达式
linux·运维·正则表达式
xcs194053 小时前
AI 自动化编程 trae 体验 页面添加富编辑器
运维·自动化·编辑器
Gss7773 小时前
源代码编译安装lamp
linux·运维·服务器