Loading... Zerotier 是一款开源工具,可以用来构建点对点(P2P)虚拟网络。比如你的女友不让你去网吧玩游戏,这时候你就可以建立一个 Zerotier 点对点虚拟网络,把你和朋友的家的电脑都加入到这个虚拟网络中,然后你们就可以像在网吧里一样联机玩耍了。 Zerotier 的基本用法可以参考[NAS之旅第10期视频](https://tvtv.fun/pc-to-nas/10th.html),这里我们要分享的是如何自己搭建 Zerotier Moon,加速 Zerotier-One 的连接,让虚拟网络更稳定的运行。 ### Zerotier Moon 搭建步骤 这里我使用的是腾讯云的上海轻量服务器 带宽仅有6M,但是由于游戏互联需要的带宽也很低,6M足矣。 #### 第一步 在云服务器上安装 zerotier-one **方法一 更简单** ```shell $ curl -s https://install.zerotier.com | sudo bash ``` **方法二 更安全** > 要求系统中安装了 GPG ```shell $ curl -s 'https://raw.githubusercontent.com/zerotier/ZeroTierOne/master/doc/contact%40zerotier.com.gpg' | gpg --import && \ if z=$(curl -s 'https://install.zerotier.com/' | gpg); then echo "$z" | sudo bash; fi ``` #### 第二步 云服务器加入虚拟网络 执行命令,将云服务器加入到自己创建好的虚拟网络,将命令中的 `xxxxxxxx` 替换成实际的虚拟网络 ID。 ```shell $ sudo zerotier-cli join xxxxxxxx ``` #### 第三步 配置 Moon 进入 zerotier-one 程序所在的目录,默认为 `/var/lib/zerotier-one`。 ```shell $ cd /var/lib/zerotier-one ``` **生成 moon.json 配置文件** ```shell $ sudo zerotier-idtool initmoon identity.public >> moon.json ``` **编辑 moon.json 配置文件** ```shell $ sudo nano moon.json ``` 将配置文件中的 `"stableEndpoints": []` 修改成 `"stableEndpoints": ["ServerIP/9993"]`,将 `ServerIP` 替换成云服务器的公网IP。 **生成 .moon 文件** ```shell $ sudo zerotier-idtool genmoon moon.json ``` 将生成的 000000xxxxxxxxxx.moon 移动到 `moons.d` 目录 ```shell $ sudo mkdir moons.d $ sudo mv 000000xxxxxxxxxx.moon moons.d ``` > .moon 配置文件的名一般为`10个前导零`+`本机的节点ID` **重启 zerotier-one 服务** ```shell $ sudo systemctl restart zerotier-one ``` #### 使用 Moon 普通的 Zerotier 成员使用 Moon 有两种方法,第一种方法是使用 `zerotier-cli orbit` 命令直接添加 Moon 节点ID;第二种方法是在 zerotier-one 程序的根目录创建`moons.d`文件夹,将 `xxx.moon` 复制到该文件夹中,我们采用第一种方法: ##### Linux 系统下使用 Moon 将命令中的两组 `xxxxxxxxxx` 都替换成 moon 的节点ID。 ```shell $ sudo zerotier-cli orbit xxxxxxxxxx xxxxxxxxxx ``` 检查是否添加成功 ```shell $ sudo zerotier-cli listpeers ``` ##### Windows 系统下使用 Moon 以管理员身份打开 PowerShell,将命令中的两组 `xxxxxxxxxx` 都替换成 moon 的节点ID。 ```powershell PS C:\Windows\system32> zerotier-cli.bat orbit xxxxxxxxxx xxxxxxxxxx ``` 检查是否添加成功 ```powershell PS C:\Windows\system32> zerotier-cli.bat listpeers ``` > **提示** :Windows 系统的默认程序目录位于 `C:\Program Files (x86)\ZeroTier\One`。 ### 常见问题一:电脑添加了虚拟网络,但Zerotier管理列表中始终没有显示这台设备。 答:可以尝试在Zerotier管理界面中 `Advanced -> Manually Add Member` 中手动添加电脑的节点ID。 ### 相关链接 * [Zerotier 官网**(opens new window)**](https://www.zerotier.com/) * [Creating Your Own Roots (a.k.a. Moons)**(opens new window)**](https://www.zerotier.com/manual/#4_4) * [Putty 官方下载页面](https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html) Last modification:September 19th, 2021 at 11:08 am © 来自互联网 Support 逢年过节,欢迎投喂 Appreciate the author 支付宝微信
4 comments
问题是 啥时候你才会有女朋友呢?
你你你你你!
第一次知道这玩意,看上去很适合 Overcooked 这种局域网联机游戏?
我用来打红警,cs1.6啥的,还有星露谷物语都很合适!