Skip to content

NTP

ntp 块用于配置 mihomo 的内嵌 NTP 客户端。启用后 mihomo 的内部时钟 不再信任系统时间 —— 在本地时钟容易漂移的设备上做 TLS 时钟偏差容忍 很有用。

选项

字段类型默认值允许值描述
enableboolfalsetrue | false启用内嵌 NTP 客户端。关闭时块内其他字段被忽略。
serverstring(unset)<hostname> | <IP>NTP 服务器。常用选择:time.cloudflare.com、time.apple.com、time.google.com。
portint123<port>NTP 服务器端口。标准 NTP 为 UDP/123。
intervalint30<minutes>两次 NTP 查询的间隔,单位 **分钟**。纯整数,不是时长字符串。
dialer-proxystring(direct)<proxy name> | <proxy group>让 NTP 流量经指定代理。当本地网络封禁 123 端口时有用。
write-to-systemboolfalsetrue | false每次同步成功后把时间写入操作系统时钟。需要更高的权限。

源码: config/config.go:259-266 · 锚定版本 v1.19.27 (5184081)

示例

yaml
ntp:
  enable: true
  server: time.cloudflare.com
  port: 123
  interval: 30
  write-to-system: false

说明

  • interval分钟,不是 Go 风格的时长字符串。interval: 30 即「每 30 分钟」。
  • dialer-proxy 引用的代理组本身依赖时间敏感操作(如 TLS), 建议改用单个直连代理,避免引导期循环依赖。

源码: config/config.go:259-266 · v1.19.27 (5184081)

由 Argsment 出品的 Core Tutorial