【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了。
相关推荐
Solar202518 分钟前
机械制造业TOB企业获客软件选型指南:从挑战到解决方案的深度解析
java·大数据·服务器·架构·云计算
橘子真甜~20 分钟前
Reids命令原理与应用5 - Redis 主从同步与高可用集群
运维·网络·数据库·redis·缓存·redis集群·redis高可用
陈让然33 分钟前
WSL2 ubuntu18.04扩容
linux·运维·ubuntu
HIT_Weston1 小时前
94、【Ubuntu】【Hugo】搭建私人博客:面包屑(二)
linux·运维·ubuntu
hui2593031 小时前
RH134 第八章 管理存储堆栈
linux·运维·服务器
每日出拳老爷子1 小时前
【客户端方案】Electron / 原生客户端在内网会议中的取舍与坑点
服务器·electron·远程工作·流媒体·视音频
乾元1 小时前
10 个可复制的企业级项目:从需求到交付的 AI 网络工程模板(深度实战版)
运维·网络·人工智能·网络协议·安全
遇见火星2 小时前
Linux 命令篇:df、du、fdisk 磁盘管理
linux·运维·服务器·df·du·fdisk
噎住佩奇2 小时前
正则表达式(Regex)入门
运维·正则表达式