【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了。
相关推荐
LH_R13 小时前
OneTerm开源堡垒机实战(四):访问授权与安全管控
运维·后端·安全
Raymond运维13 小时前
MariaDB源码编译安装(二)
运维·数据库·mariadb
JuiceFS1 天前
从 MLPerf Storage v2.0 看 AI 训练中的存储性能与扩展能力
运维·后端
chen9451 天前
mysql 3节点mgr集群部署
运维·后端
LH_R2 天前
OneTerm开源堡垒机实战(三):功能扩展与效率提升
运维·后端·安全
dessler2 天前
Hadoop HDFS-高可用集群部署
linux·运维·hdfs
少妇的美梦2 天前
logstash教程
运维
chen9452 天前
k8s集群部署vector日志采集器
运维
chen9452 天前
aws ec2部署harbor,使用s3存储
运维
christine-rr3 天前
linux常用命令(4)——压缩命令
linux·服务器·redis