1. 先到 https://my.zerotier.com 注册账号并创建网络获得网络ID
2. Openwrt 安装 Zerotier
opkg update
opkg install zerotier 3. 初始化 Zerotier(注意:执行初始化命令前,在zerotier官网管理页面不能有同一个局域网IP段的路由列表,否则会出现不能登陆路由器的问题)
mkdir -p /etc/zerotier
uci set zerotier.openwrt_network=zerotier
uci add_list zerotier.openwrt_network.join='你的网络ID'
uci set zerotier.openwrt_network.enabled='1'
uci set zerotier.openwrt_network.config_path='/etc/zerotier'
uci commit zerotier 4. 启动 Zerotier
/etc/init.d/zerotier enable # 设置自启
/etc/init.d/zerotier start 5. 配置接口
web界面,网络 -> 接口,添加新接口,设备选择 ztk***


防火墙可自定义,让系统自动创建
6. 配置防火墙


若是先创建防火墙,此处的涵盖网络则选择自定义,让系统自动创建接口
接口和防火墙必须对应起来
7. 重启路由器,启动后到 zerotier 管理页面查看是否已连接上,并记得勾选授权。
ping 下分配的ip,看是否可以ping通
如果使用自建moon服务器,初始化Zerotier的命令略有差异
mkdir -p /etc/zerotier
mkdir -p /etc/zerotier/moons.d
uci set zerotier.openwrt_network=zerotier
uci add_list zerotier.openwrt_network.join='你的网络ID'
uci set zerotier.openwrt_network.enabled='1'
uci set zerotier.openwrt_network.config_path='/etc/zerotier'
uci commit zerotier 然后将moon服务器将生成的0000000xxxx.moon复制到/etc/zerotier/moons.d
或者
直接使用命令添加
zerotier-cli orbit Moon节点ID Moon节点ID 这两个添加moon服务器的方法在moon的使用上无区别,看个人喜好。
前提条件:必须有一个公网 ip
1. 生成 moon 模板
cd /etc/zerotier
zerotier-idtool initmoon identity.public >> moon.json
## 如果没有 identity.public,可以用 identity.secret 2. 配置公网ip
vim moon.json 将 修改为服务器的 IP4 或 IP6 地址及端口:
"stableEndpoints": ["服务器IP地址/9993"] 3. 生成签名文件
zerotier-idtool genmoon moon.json 显示如下内容,表示执行成功: wrote 000000xxxxxxx.moon (signed world with timestamp xxxxxxxx)
4. moon 节点加入网络
执行以下命令:
mkdir moons.d
mv 000000xxxxxxx.moon moons.d/ 然后重启服务器 zerotier:
/etc/init.d/zerotier restart 5. 查看是否配置成功
zerotier-cli listmoons

Windows 配置
zerotier-cli.bat orbit moonId moonId 使用 zerotier-cli.bat listpeers 查看是否有moon节点

Androd 客户端
知乎大佬修改后的版本,支持配置 Moon(官方版不支持)
https://github.com/kaaass/ZerotierFix
加入网络后,点击右上角入轨,直接点击入轨,两个输入框都输入 Moon 节点的 id
例如 A 局域网有 abc三台设备,其中只有 a 加入Zerotier,
为使 Zerotier 中的 d 设备可以访问到 bc ,则需要配置 nat,实现异地组网。
a 可以是路由器或其它任意类型的设备。
假设 A 局域网的网段是 192.168.1.0/24,a 的虚拟ip 是 172.22.33.33,则只需要在后台添加路由
