Building a LAN Gaming Environment with ZeroTier

前言

ZeroTier是一个非常好用的软件定义局域网SDN,但在用来玩局域网游戏时可能会遇到一些问题,比如无法发现其他玩家或连接延迟高。

服务器端配置

1. 启用网络广播

要让游戏能够自动发现其他玩家,需要在ZeroTier网络设置中启用广播和组播:

  1. 登录管理面板(或者是ztncui)
  2. 添加新路由
  3. 添加以下两条路由规则:
    • 目标: 255.255.255.255/32,via: 0.0.0.0(启用广播)
    • 目标: 224.0.0.0/4,via: 0.0.0.0(启用组播)

注意:虽然广播会降低网络效率,但对于游戏发现功能来说是必需的。

2. 优化MTU设置

大多数家用网络的MTU为1500(PPPoE环境下为1492),需要调整ZeroTier的MTU以避免数据包分片:

1
2
3
4
5
# 进入ZeroTier配置目录
sudo su
cd /var/lib/zerotier-one/controller.d/network
# 修改目录下所有json网络配置文件中的MTU值
# 使用文本编辑器打开.json文件,将"mtu":2800改为"mtu":1492

客户端配置

1.安装WindowsIPBroadcast

某些游戏(文明6)只在第一个网络适配器上面广播,需要第三方软件广播到全部适配器上,WindowsIPBroadcast可以解决这个问题:
GitHub仓库下载最新版本

2.加钱上moon服务器

Introduction

ZeroTier is a very useful Software-Defined Network (SDN), but when used for playing LAN games, you might encounter issues such as being unable to discover other players or experiencing high connection latency.

Server-Side Configuration

1. Enable Network Broadcast

To allow the game to automatically discover other players, you need to enable broadcast and multicast in the ZeroTier network settings:

  1. Log into the management panel (or use ztncui).
  2. Add a new route.
  3. Add the following two routing rules:
  • Destination: 255.255.255.255/32, via: 0.0.0.0 (enables broadcast)
  • Destination: 224.0.0.0/4, via: 0.0.0.0 (enables multicast)

Note: While broadcast reduces network efficiency, it is necessary for game discovery functionality.

2. Optimize MTU Settings

Most home networks have an MTU of 1500 (1492 in PPPoE environments). It’s necessary to adjust ZeroTier’s MTU to avoid packet fragmentation:

1
2
3
4
5
# Go to the ZeroTier configuration directory
sudo su
cd /var/lib/zerotier-one/controller.d/network
# Modify the MTU value in all .json network config files in this directory
# Use a text editor to open the .json files, change "mtu":2800 to "mtu":1492

Client-Side Configuration

1. Install WindowsIPBroadcast

Some games (like Civilization 6) only broadcast on the first network adapter. To handle this, you need third-party software to broadcast across all adapters. WindowsIPBroadcast can resolve this issue:
GitHub Repository Download the latest version.

2. Invest in a Moon Server (Spending more money)


Building a LAN Gaming Environment with ZeroTier
https://tokisaki.top/blog/zerotier-game-setting/
作者
Tokisaki Galaxy
发布于
2025年2月4日
许可协议