MKMihomo 与 sing-box 内核手册TECHNICAL REFERENCE · mihomo / sing-box
文档号
YYK-3.2
修订 · 页
2026-10-18 · 08/10
§ 3.2sing-box第 08 / 10 页

sing-box 配置文件结构说明

Mihomo 与 sing-box 内核手册编辑部 · 更新于 2026-10-18

sing-box 使用 JSON 配置,顶层包括 log、dns、inbounds、outbounds、route 与 experimental 等部分。规则集支持 JSON source 与二进制 .srs,Clash API 在 experimental.clash_api。

sing-box 使用 JSON 配置。顶层结构包含日志、DNS、证书、端点、入站、出站、路由、服务和实验性功能等部分;其中 inbounds 描述入站,outbounds 描述出站,route 放置路由相关配置。

顶层部分

字段文档描述的内容
log日志设置
dnsDNS 配置
ntpNTP 配置
certificate / certificate_providers证书及证书提供项
endpoints同时具备入站与出站行为的端点
inbounds入站配置
outbounds出站配置
route路由规则与规则集引用
services服务配置
experimental实验性功能,包括 Clash API 配置

路由规则字段包括 inbound、network、domain、ip_cidr、process_name、rule_set、action 等;逻辑规则使用 type: logical,mode 可为 and 或 or。已弃用的 geosite、geoip、source_geoip 文档注明应迁移至 rule-set;规则中的 outbound 字段也已弃用并移至 Rule Action。

rule-set 与 .srs

rule-set 支持 inline、local 和 remote 类型。格式可为 source(JSON)或 binary;文件扩展名为 .json 或 .srs 时可省略 format。.srs 是二进制规则集,可通过官方记录的 sing-box rule-set compile 命令编译 JSON 文件。

远程 rule-set 的 update_interval 默认值为 1d;启用 cache_file 后会缓存。文档还写有 1.14.0 新增的 initial_path 和 http_client 等字段。由于官方文档含 testing 分支内容,部分条目需注意其版本归属。

Clash API

experimental.clash_api 配置 Clash API 兼容接口,包括 external_controller、external_ui、secret 和 default_mode 等字段。external_controller 为空时接口禁用;官方特别写明监听 0.0.0.0 时应设置 secret。它与 sing-box 自有 gRPC API 服务不是同一接口。

继续查看sing-box 与 mihomo 差异和启动检查。

规则集源格式的版本记录从 1.8.0 的 1 开始,之后在 1.10.0、1.11.0、1.13.0、1.14.0 依次增加,新增内容包括 network_type、network_interface_address 与 package_name_regex 等。

顶层字段清单还包括 http_clients 与 network_namespaces。入站和出站分别有独立章节,route 规则支持 domain、source_ip_cidr、port、process_name 和 rule_set 等条件。1.14.0 起配置支持 JSON Schema。

DNS 顶层配置下还包含 servers、rules、final、strategy、disable_cache、disable_expire 和 fakeip 等配置项。TUN 入站有独立页面,字段包括 interface_name、address、mtu、auto_route 等。

sing-box 的 route 规则还记录 source_port、port_range、package_name、wifi_ssid 与 source_mac_address 等条件。dns_server_address 和 dns_search_domain 是 1.15.0 新增项目,目前仅见于 alpha 文档,正式版 v1.14.3 还没有。

常见问题

sing-box 配置使用什么格式?

官方文档说明配置采用 JSON,顶层含 log、dns、inbounds、outbounds、route 和 experimental 等字段。

.srs 文件是什么?

.srs 是 sing-box rule-set 的 binary 格式;官方文档也支持 JSON source 格式,并记录 sing-box rule-set compile 编译命令。