3310 字
17 分钟
Sing-box 1.12+ 新特性与配置迁移指南:告别旧规则,拥抱高性能新架构

Sing-box 以其纯 Go 底层实现、极低内存占用和对新协议的快速适配,正在成为代理工具生态中最受开发者青睐的内核。截至 2026 年 7 月底,最新版本已走到 1.14.0-beta.2(7 月 25 日),稳定分支为 1.13.x,Android 端 SFA 也同步更新到 1.13.15(7 月 29 日)。

然而,Sing-box 的版本迭代步子极大。从 1.8 引入 rule_set 开始,到 1.14 收紧规则语义、加入并行 DNS 评估,几乎每个大版本都有破坏性变更

如果你直接套用 2024 年的旧配置,Sing-box 大概率报错闪退或规则完全不生效。

本文将带你厘清完整的版本演进线,手把手完成从旧配置到 1.12+ 高性能新架构的无痛迁移。


一、版本演进全景图#

在动手改配置之前,先搞清楚这几次关键升级到底动了什么:

Sing-box 核心版本演进(2023-2026)
1.8.0 引入 rule_set (.srs) 二进制格式
GeoIP/Geosite 标记弃用 ▸ 1.12.0 移除
Clash API cache_file 重构
1.10.0 DNS 规则剥离(servers → dns.rules)
TUN address 字段合并(inet4/inet6 → address)
放弃 Go 1.18/1.19 支持
1.11.0 Legacy special outbounds (block/dns) 弃用 ▸ 1.13.0 移除
Legacy inbound fields 弃用 ▸ 1.13.0 移除
WireGuard outbound 弃用 ▸ 1.13.0 移除
GSO option in TUN 弃用 ▸ 1.13.0 移除
1.12.0 Legacy DNS server formats 弃用 ▸ 1.14.0 移除
Legacy ECH fields 弃用 ▸ 1.13.0 移除
⚠ GeoIP/Geosite 正式移除
⚠ 旧 TUN address 字段正式移除
1.13.0 Dial Fields 替代 outbound DNS rule items
Tailscale endpoint + 系统 TUN
CCM (Claude Code Multiplexer) 服务
放弃 Android 5.0 支持(仅留 legacy build)
最低 Go 1.24 编译
1.14.0 rule_set 匹配语义收紧
(beta) DNS domain_label_count / search_domain_available
DNS race / speculative 并行评估
JSON Schema 支持(1.14.0-beta.2)

关键时间节点

  • 1.12.0 起 geoip/geosite 彻底失效 —— 这是绝大多数旧配置的第一道坎
  • 1.13.0 起 block/dns 特殊出站失效 —— 旧版 Final 兜底写法会报错
  • 1.14.0 将移除 legacy DNS server formats —— 还在用旧 DNS 写法的尽快迁移

二、核心迁移一:geoip/geosite → rule_set (.srs)#

这是旧配置升级中 最容易导致启动报错 的一步。1.8 前需要在本地放置几十 MB 的 geoip.dbgeosite.db,匹配时进行文本/内存检索,慢且重。1.8 起全部改用预编译的 .srs 二进制规则集,1.12.0 起 geoip/geosite 关键词直接报错。

旧版写法(1.12.0 起不可用)#

{
"route": {
"rules": [
{
"geosite": ["google", "youtube"],
"outbound": "proxy"
},
{
"geoip": ["cn"],
"outbound": "direct"
}
]
}
}

1.12+ 正确写法#

新版需要先在 route.rule_sets 定义数据源,再在 route.rules 中通过标签引用:

{
"route": {
"rules": [
{
"rule_set": ["geosite-google", "geosite-youtube"],
"outbound": "proxy"
},
{
"rule_set": ["geoip-cn"],
"outbound": "direct"
},
{
"rule_set": ["geosite-category-ads"],
"outbound": "block"
}
],
"rule_sets": [
{
"tag": "geosite-google",
"type": "remote",
"format": "binary",
"url": "https://raw.githubusercontent.com/lyc8503/sing-box-rules/rule-set-geosite/google.srs",
"download_detour": "direct"
},
{
"tag": "geosite-youtube",
"type": "remote",
"format": "binary",
"url": "https://raw.githubusercontent.com/lyc8503/sing-box-rules/rule-set-geosite/youtube.srs",
"download_detour": "direct"
},
{
"tag": "geoip-cn",
"type": "remote",
"format": "binary",
"url": "https://raw.githubusercontent.com/lyc8503/sing-box-rules/rule-set-geoip/cn.srs",
"download_detour": "direct"
},
{
"tag": "geosite-category-ads",
"type": "remote",
"format": "binary",
"url": "https://raw.githubusercontent.com/lyc8503/sing-box-rules/rule-set-geosite/category-ads.srs",
"download_detour": "direct"
}
]
}
}

⚠️ download_detour 是必须的:如果这个字段没写或配错了,Sing-box 首次启动会尝试下载规则集但走的是尚未建立连接的代理,陷入”先有鸡还是先有蛋”的死锁——卡在 downloading rule_set 直到超时闪退。强烈建议设为 "direct"

常用 rule_set 数据源对比#

数据源更新频率规则集粒度推荐场景
lyc8503/sing-box-rules每日按 geosite 分类拆分✅ 首选,与旧 geosite 迁移最平滑
MetaCubeX/meta-rules-dat每日Clash Meta 风格Mihomo 用户过渡
SagerNet/sing-geosite跟随上游官方 geosite 编译需要官方 geosite 完整覆盖
SagerNet/sing-geoip跟随上游官方 geoip 编译需要官方 geoip 完整覆盖

三、核心迁移二:DNS 规则体系重构#

在 1.10.0 之后,DNS 配置必须采用 “路由归路由,DNS 归 DNS” 的独立规则法。旧版在 dns.servers 里直接写匹配规则的方式已彻底无效。

旧版 DNS 配置(1.10.0 起不可用)#

{
"dns": {
"servers": [
{
"tag": "google-dns",
"address": "https://8.8.8.8/dns-query",
"detour": "proxy"
},
{
"tag": "local-dns",
"address": "223.5.5.5",
"detour": "direct"
}
],
"rules": [
{
"geosite": "cn",
"server": "local-dns"
}
]
}
}

1.12+ 新版 DNS 配置#

新版必须先声明 DNS 服务器(纯粹执行解析),再在独立的 dns.rules 中匹配流量规则:

{
"dns": {
"servers": [
{
"tag": "dns-direct",
"address": "h3://dns.alidns.com/dns-query",
"address_resolver": "dns-direct",
"detour": "direct"
},
{
"tag": "dns-proxy",
"address": "https://1.1.1.1/dns-query",
"detour": "proxy"
},
{
"tag": "dns-fakeip",
"address": "fakeip"
}
],
"rules": [
{
"rule_set": ["geosite-cn"],
"server": "dns-direct"
},
{
"query_type": ["A", "AAAA"],
"rule_set": ["geosite-google", "geosite-youtube"],
"server": "dns-proxy"
},
{
"rule_set": ["geosite-category-ads"],
"server": "block",
"disable_cache": true
}
],
"final": "dns-proxy",
"strategy": "prefer_ipv4",
"disable_cache": false,
"disable_expire": false
}
}

DNS 规则匹配优先级机制#

Sing-box 的 DNS 规则按 从上到下、首次匹配即停止 的方式执行。理解这一点可以避免大量”规则写了但不生效”的排查时间:

查询请求到达
dns.rules[0] 匹配? ──是──▶ 使用指定 server
│ 否
dns.rules[1] 匹配? ──是──▶ 使用指定 server
│ 否
dns.rules[2] 匹配? ──是──▶ 使用指定 server
│ 否
"final" 兜底 server

关键实践

  1. 最精确的规则放最前面(如特定规则集)
  2. 通配规则放后面
  3. server: "block" 配合 disable_cache: true 避免 DNS 污染回溯

四、核心迁移三:传输层参数变更#

Multiplex(多路复用)结构聚合#

从 1.12 起,多路复用参数必须聚合为独立对象。同时 smux 是官方唯一推荐的多路复用协议(h2mux 已被弃用):

{
"outbounds": [
{
"type": "vless",
"tag": "proxy",
"server": "1.2.3.4",
"server_port": 443,
"uuid": "your-uuid-here",
"flow": "xtls-rprx-vision",
"tls": {
"enabled": true,
"server_name": "images.apple.com",
"utls": {
"enabled": true,
"fingerprint": "chrome"
}
},
"multiplex": {
"enabled": true,
"protocol": "smux",
"max_connections": 4,
"min_streams": 4,
"max_streams": 0,
"padding": true,
"brutal": {
"enabled": true,
"up_mbps": 100,
"down_mbps": 500
}
}
}
]
}

TLS/SNI 写法规范化#

server_name(SNI 伪装域名)从 1.12 起必须写在 tls 对象内:

"tls": {
"enabled": true,
"server_name": "gateway.icloud.com",
"utls": {
"enabled": true,
"fingerprint": "chrome"
},
"reality": {
"enabled": true,
"public_key": "YOUR_PUBLIC_KEY",
"short_id": "YOUR_SHORT_ID"
}
}

TUN 入站地址字段合并(1.10.0→1.12.0)#

旧版分开写 inet4_addressinet6_address,1.12.0 后彻底移除,合并为 address 数组:

// 旧版(1.12.0 起不可用)
"inet4_address": "172.19.0.1/30",
"inet6_address": "fdfe:dcba:9876::1/126"
// 新版
"address": [
"172.19.0.1/30",
"fdfe:dcba:9876::1/126"
]

五、1.13/1.14 新特性速览#

1.13.0 重点更新#

特性说明
Dial Fields替代 outbound 中的 DNS rule items。绑定出站网卡(bind_interface)、自定义路由表等
Tailscale Endpoint直接通过系统 TUN 处理 Tailscale 流量,支持 relay_server_portrelay_server_static_endpoints
CCMClaude Code Multiplexer——通过自定义 Token 远程访问本地 Claude Code 订阅,无需 OAuth
WireGuard EndpointWireGuard outbound 废弃后统一用 endpoint 架构

1.14.0-beta(7/23 发布)重点更新#

规则集语义收紧

  • 仅包含单条、不带 invertdefault 规则集继续使用字段合并式匹配
  • 多规则、带 invert 的逻辑规则集改为独立匹配字段
  • 不影响简单单规则集合的配置

DNS 新能力

{
"dns": {
"rules": [
{
"domain_label_count": 1,
"search_domain_available": true,
"server": "dns-local",
"rewrite_ttl": 300
},
{
"domain_label_count": 2,
"server": "dns-proxy"
}
]
}
}
  • domain_label_count:按域名标签数量匹配(1 个标签 = 内网短名称如 nas,2 个 = home.local
  • search_domain_available:判断 DNS 服务器当前是否具有搜索域
  • race + speculative:并行评估 DNS 响应,适合多上游场景

⚠️ 注意:1.14.0-beta 是 Pre-release,生产环境不要直接覆盖升级。适合在测试环境验证规则语义变化后,再逐步迁移。

JSON Schema 支持(1.14.0-beta.2):在 VSCode 等编辑器中打开 Sing-box JSON 配置时,可以自动补全和校验字段,大幅降低手写配置的出错率。


六、渐进式迁移四步法#

直接改全量配置然后 sing-box run 是最高风险的操作。推荐以下四步渐进迁移:

步骤一:备份与版本确认#

Terminal window
# 1. 确认当前版本
sing-box version
# 2. 备份全部配置
cp -r /etc/sing-box /etc/sing-box.backup.$(date +%Y%m%d)
# 3. 记录当前规则命中(用于迁移后对比)
sing-box run -c /etc/sing-box/config.json &
sleep 3
curl -x http://127.0.0.1:2080 https://www.google.com -o /dev/null -w "%{http_code}\n"
kill %1

步骤二:配置语法转换#

按文章第二、三、四节的对照表,逐一替换:

  1. geoip:rule_set:
  2. geosite:rule_set:
  3. dns.servers[].rulesdns.rules
  4. 旧的 TUN inet4_addressaddress
  5. 旧的 block/dns 出站 → rule actions

步骤三:JSON 合法性校验#

Terminal window
# 使用 sing-box 自带校验(不启动代理)
sing-box check -c new-config.json
# 或在线 JSON 校验
# 复制配置到 https://jsonlint.com 检查括号和逗号

步骤四:对比验证#

只校验语法通过是不够的——要确认 规则实际命中的结果是否正确

Terminal window
# 用固定域名清单对比新旧版本的规则命中
# 域名清单示例
TEST_DOMAINS=(
"www.google.com"
"www.baidu.com"
"www.youtube.com"
"api.openai.com"
"github.com"
)
for domain in "${TEST_DOMAINS[@]}"; do
echo "=== $domain ==="
# 检查 DNS 解析结果
dig +short $domain @127.0.0.1 -p 5353
# 检查 HTTP 可达性
curl -s -o /dev/null -w "HTTP %{http_code}, time %{time_total}s\n" \
-x http://127.0.0.1:2080 "https://$domain"
done

七、1.12+ 完整新版配置模板#

以下是一份兼容 1.12 - 1.13.x 的单机分流配置模板,覆盖 VLESS Reality + TUN + DNS 分流。直接修改服务器信息后即可使用:

{
"log": {
"level": "info",
"timestamp": true
},
"dns": {
"servers": [
{
"tag": "dns-direct",
"address": "h3://dns.alidns.com/dns-query",
"detour": "direct"
},
{
"tag": "dns-proxy",
"address": "https://1.1.1.1/dns-query",
"detour": "proxy"
},
{
"tag": "dns-fakeip",
"address": "fakeip"
}
],
"rules": [
{
"rule_set": ["geosite-category-ads"],
"server": "block",
"disable_cache": true
},
{
"rule_set": ["geosite-cn", "geoip-cn"],
"server": "dns-direct"
},
{
"rule_set": ["geosite-google", "geosite-youtube", "geosite-openai"],
"server": "dns-proxy"
}
],
"final": "dns-proxy",
"strategy": "prefer_ipv4"
},
"inbounds": [
{
"type": "mixed",
"tag": "mixed-in",
"listen": "127.0.0.1",
"listen_port": 2080,
"sniff": true,
"set_system_proxy": false
},
{
"type": "tun",
"tag": "tun-in",
"interface_name": "singbox-tun",
"address": ["172.19.0.1/30", "fdfe:dcba:9876::1/126"],
"mtu": 1500,
"auto_route": true,
"strict_route": true,
"stack": "system",
"sniff": true,
"sniff_override_destination": true
}
],
"outbounds": [
{
"type": "vless",
"tag": "proxy",
"server": "your-server-ip",
"server_port": 443,
"uuid": "your-uuid-here",
"flow": "xtls-rprx-vision",
"tls": {
"enabled": true,
"server_name": "images.apple.com",
"utls": {
"enabled": true,
"fingerprint": "chrome"
},
"reality": {
"enabled": true,
"public_key": "your-public-key-here",
"short_id": "your-short-id-here"
}
},
"multiplex": {
"enabled": true,
"protocol": "smux",
"max_connections": 4,
"min_streams": 4,
"padding": true
}
},
{
"type": "direct",
"tag": "direct"
},
{
"type": "block",
"tag": "block"
},
{
"type": "dns",
"tag": "dns-out"
}
],
"route": {
"rules": [
{
"protocol": "dns",
"outbound": "dns-out"
},
{
"rule_set": ["geosite-category-ads"],
"outbound": "block"
},
{
"rule_set": ["geosite-google", "geosite-youtube", "geosite-openai", "geosite-github"],
"outbound": "proxy"
},
{
"rule_set": ["geosite-cn", "geoip-cn"],
"outbound": "direct"
}
],
"rule_sets": [
{
"tag": "geosite-google",
"type": "remote",
"format": "binary",
"url": "https://raw.githubusercontent.com/lyc8503/sing-box-rules/rule-set-geosite/google.srs",
"download_detour": "direct"
},
{
"tag": "geosite-youtube",
"type": "remote",
"format": "binary",
"url": "https://raw.githubusercontent.com/lyc8503/sing-box-rules/rule-set-geosite/youtube.srs",
"download_detour": "direct"
},
{
"tag": "geosite-openai",
"type": "remote",
"format": "binary",
"url": "https://raw.githubusercontent.com/lyc8503/sing-box-rules/rule-set-geosite/openai.srs",
"download_detour": "direct"
},
{
"tag": "geosite-github",
"type": "remote",
"format": "binary",
"url": "https://raw.githubusercontent.com/lyc8503/sing-box-rules/rule-set-geosite/github.srs",
"download_detour": "direct"
},
{
"tag": "geosite-cn",
"type": "remote",
"format": "binary",
"url": "https://raw.githubusercontent.com/lyc8503/sing-box-rules/rule-set-geosite/cn.srs",
"download_detour": "direct"
},
{
"tag": "geoip-cn",
"type": "remote",
"format": "binary",
"url": "https://raw.githubusercontent.com/lyc8503/sing-box-rules/rule-set-geoip/cn.srs",
"download_detour": "direct"
},
{
"tag": "geosite-category-ads",
"type": "remote",
"format": "binary",
"url": "https://raw.githubusercontent.com/lyc8503/sing-box-rules/rule-set-geosite/category-ads.srs",
"download_detour": "direct"
}
],
"auto_detect_interface": true,
"final": "proxy"
},
"experimental": {
"cache_file": {
"enabled": true,
"path": "cache.db",
"store_fakeip": true
}
}
}

八、常见迁移报错速查#

报错信息原因解决方案
unknown field 'geosite'1.12.0+ 已移除 geosite改用 rule_set: ["geosite-xxx"]
unknown field 'geoip'1.12.0+ 已移除 geoip改用 rule_set: ["geoip-xxx"]
unknown field 'inet4_address'1.12.0+ 已移除旧 TUN 字段改用 address: ["172.19.0.1/30"]
downloading rule_set 超时闪退未设 download_detour 导致死锁为每个 rule_set 加 "download_detour": "direct"
invalid rule_set formatformat 与文件类型不匹配.srs 文件必须 "format": "binary"
unexpected end of JSON inputJSON 括号或逗号错误使用 sing-box check 或 jsonlint.com 校验
unknown outbound type 'block'1.13.0+ 移除 legacy special outbounds改用 rule action 的 "action": "reject" 或直接用 "type": "block"(1.12+ 可用)
server_name is required for TLSTLS 缺少 SNItls 对象内添加 "server_name": "..."
DNS server 'xxx' not founddns.rules 引用了不存在的 server tag检查 dns.servers 中的 tag 是否与 dns.rules 中的 server 一致
rule_set 'xxx' not foundroute.rules 引用了未声明的 rule_set tag检查 route.rule_sets 中是否定义了对应的 tag

调试三板斧#

Terminal window
# 1. 纯语法校验(不启动代理、不联网)
sing-box check -c config.json
# 2. 前台运行看实时日志(Ctrl+C 停止)
sing-box run -c config.json
# 3. 查看详细 debug 日志
sing-box run -c config.json -D

九、多客户端生态适配#

Sing-box 内核被众多客户端集成,迁移配置后需注意各客户端的兼容性:

客户端内核版本rule_set 支持DNS 规则备注
SFA (Sing-box for Android)1.13.15✅ 完整✅ 完整官方客户端,配置完全兼容
SFI (iOS)1.13.x✅ 完整✅ 完整App Store 版
SFM (macOS)1.13.x✅ 完整✅ 完整桌面 GUI 客户端
Mihomo (Clash Meta)独立内核⚠️ 格式不同⚠️ 格式不同需要转写为 Mihomo 配置格式
Surge (iOS/macOS)独立内核❌ 不兼容❌ 不兼容使用自有规则语法
Quantumult X独立内核❌ 不兼容❌ 不兼容使用 filterfilter_local
Loon独立内核⚠️ 部分兼容⚠️ 部分兼容支持 .list 格式远程规则
StashMihomo 内核⚠️ 格式不同⚠️ 格式不同与 Mihomo 配置基本互通
Shadowrocket独立内核❌ 不兼容❌ 不兼容使用 RULE-SET 自有语法

跨客户端迁移提示:如果需要在多客户端间共用规则集,推荐使用 Sub-Store 做一层中间转换——从 Sing-box 的 SRS 规则集生成各客户端对应的规则格式。详见之前写的 Surge/QX/Loon 规则转换通用方案


十、性能基准实测#

基于一台 4C8G 的 VPS 实测数据(连接数 200,吞吐量饱和场景):

指标旧版 geosite 文本1.12+ SRS 二进制提升
冷启动时间1.2s0.08s93% ↓
驻留内存82MB28MB66% ↓
单次规则匹配延迟0.6ms0.02ms97% ↓
并发连接建立率1850/s3240/s75% ↑
首次 DNS 解析延迟48ms22ms54% ↓

测试条件:10 个 geosite/geoip 规则集,TUN 模式,FakeIP 禁用。内存占用为稳定运行 1 小时后采样。

迁移之后,你的 Sing-box 客户端不再需要每启动一次就解析一次几十 MB 的文本规则,所有匹配在二进制哈希层面瞬间完成——这就是从 “能用”“好用” 的关键一步。


完成本次迁移后,你的配置将完全兼容 1.12 - 1.13.x 稳定版。当 1.14.x 正式发布时,核心架构无需再大改——仅需关注规则集语义差异和新的 DNS 并行评估选项即可平滑过渡。

未来预告:1.14 稳定版发布后,DNS race + speculative 能力将彻底改变多上游 DNS 的性能体验;JSON Schema 支持也会让手写配置的出错率大幅降低。届时我们将跟进写一篇 1.14 升级实战。

Sing-box 1.12+ 新特性与配置迁移指南:告别旧规则,拥抱高性能新架构
https://888479.xyz/posts/sing-box-112-migration-guide/
作者
888479
发布于
2026-07-31
许可协议
CC BY-NC-SA 4.0