搭配 Toperlock/sing-box-subscribe 使用的 sing-box 配置转换模板, 仅适用于客户端
文件的存储路径按照 "入站方式 → DNS 协议 → 中国 DNS 服务商 → 国际 DNS 服务商 → 规则集 CDN → 配置文件名称" 进行层级划分。
比如对于 https://raw.githubusercontent.com/senzyo/sing-box-templates/public/tun/doh/ali/google/testingcf.jsdelivr.net/config.json
, 即 https://raw.githubusercontent.com/senzyo/sing-box-templates/<Git 分支名称>/<入站方式>/<DNS 协议>/<中国 DNS 服务商>/<国际 DNS 服务商>/<规则集 CDN>/<配置文件名称>
。
入站方式
的可选值:mixed
,tun
DNS 协议
的可选值:doh
,doq
,dot
,h3
中国 DNS 服务商
的可选值:ali
,dnspod
国际 DNS 服务商
的可选值:adguard
,cloudflare
,google
,opendns
规则集 CDN
的可选值:fastly.jsdelivr.net
,gcore.jsdelivr.net
,testingcf.jsdelivr.net
,ghproxy.net
,gh-proxy.com
,ghfast.top
(域名经常变动, 关注地址发布页 ghproxy.link)配置文件名称
的可选值:- 对于
入站方式
为mixed
的, 可选值:config.json
- 对于
入站方式
为tun
的, 可选值:config.json
,config_fakeip.json
,config_apple.json
- 对于
当然有些 DNS 服务商不支持 DNS over QUIC (DoQ) 或 DNS over HTTP3 (DoH3), 所以, 当你用上述可选值选择模板时, 确保它在 public 分支中是存在的。
推荐 Android, Linux 和 Windows 使用入站方式为 tun
的模板, 比如:
https://raw.githubusercontent.com/senzyo/sing-box-templates/public/tun/doh/ali/google/testingcf.jsdelivr.net/config.json
也可使用 FakeIP, 比如:
https://raw.githubusercontent.com/senzyo/sing-box-templates/public/tun/doh/ali/google/testingcf.jsdelivr.net/config_fakeip.json
对于 Apple 设备, 使用文件名为 config_apple.json
的模板, 比如:
https://raw.githubusercontent.com/senzyo/sing-box-templates/public/tun/doh/ali/google/testingcf.jsdelivr.net/config_apple.json
不推荐使用入站方式仅为 mixed
的模板, 比如:
https://raw.githubusercontent.com/senzyo/sing-box-templates/public/mixed/doh/ali/google/testingcf.jsdelivr.net/config.json
#!/bin/bash
url_gene="https://a.com" # 生成配置的后端地址
url_sub="https://b.com" # 来自机场的订阅链接
url_tpl="https://raw.githubusercontent.com/senzyo/sing-box-templates/public/tun/doh/ali/google/testingcf.jsdelivr.net/config.json" # 配置所用模板的地址
url_dl="$url_gene/config/$url_sub&ua=clashmeta&emoji=1&file=$url_tpl"
echo $url_dl
curl -L -o config.json "$url_dl"
也就是说, 可以拼接 生成配置的后端地址
+来自机场的订阅链接
+配置所用模板的地址
得到最终的订阅地址, 然后将其添加至 Android 或 Apple 设备的 sing-box 图形客户端中。比如: https://a.com/config/https://b.com&ua=clashmeta&emoji=1&file=https://raw.githubusercontent.com/senzyo/sing-box-templates/public/tun/doh/ali/google/testingcf.jsdelivr.net/config.json
对于 Linux 和 Windows, 可参阅 sing-box on Linux 和 sing-box on Windows。
至于 Toperlock/sing-box-subscribe 的更多参数信息, 请阅读其 README。
在 Windows 中, 如果在 TUN 配置中启用了严格路由, 则:
- 不必手动启用组策略中
计算机配置
→管理模板
→网络
→DNS 客户端
→禁用智能多宿主名称解析
这一策略了, 保持这一策略为未配置/已禁用
即可。 - 不必手动为 sing-box 配置 Windows 防火墙, sing-box 会自动配置的。
- 不然, 你会发现虽然测速延迟还可以, 但实际速度很慢。
- 由于 mihomo 和 sing-box 都使用 sing-tun, 所以上述注意事项同样适用于 mihomo。
DNS 协议使用 DNS over HTTPS
或 DNS over QUIC
或 DNS over TLS
或 DNS over HTTP3
, 更多 DNS 协议与格式参考 sing-box 文档。
中国 DNS
包括 Ali DNS
和 DNSPod
。
国际 DNS
包括 AdGuard DNS
, Cisco OpenDNS
, Cloudflare DNS
和 Google DNS
。
更多 DNS 服务商 参考。
根据 公共 DNS 免费版接入限速, 单 IP 访问量 超过 20 QPS, UDP/TCP 流量超过 2000 bps 将被限速。 升级到公共 DNS 付费版, 每月有 1000 万次 的免费解析额度。
根据 DoH 与 DoT 说明, 单个域名解析调用频率 限制为 20 QPS。 开通腾讯云 Public DNS 专业版, 每月有 300 万次 的免费解析额度。
"dns": {
"servers": [
{
"tag": "国际 DNS",
"address": "https://dns.google/dns-query",
"address_resolver": "CNNIC DNS",
"detour": "🚀 默认出站"
},
{
"tag": "中国 DNS",
"address": "https://dns.alidns.com/dns-query",
"address_resolver": "CNNIC DNS",
"detour": "🐢 直连"
},
{
"tag": "CNNIC DNS",
"address": "1.2.4.8",
"detour": "🐢 直连"
}
],
...
},
仅影响客户端下载规则集的速度。
"route": {
...
"rule_set": [
...
{
"tag": "geosite_category-games",
"type": "remote",
"format": "binary",
"url": "https://testingcf.jsdelivr.net/gh/MetaCubeX/meta-rules-dat@sing/geo/geosite/category-games.srs",
"download_detour": "🐢 直连",
"update_interval": "3d"
},
...
]
}
源地址举例:
https://raw.githubusercontent.com/MetaCubeX/meta-rules-dat/refs/heads/sing/geo/geosite/category-games.json
CDN 地址列举:
https://fastly.jsdelivr.net/gh/MetaCubeX/meta-rules-dat@sing/geo/geosite/category-games.json
https://gcore.jsdelivr.net/gh/MetaCubeX/meta-rules-dat@sing/geo/geosite/category-games.json
https://testingcf.jsdelivr.net/gh/MetaCubeX/meta-rules-dat@sing/geo/geosite/category-games.json
https://ghproxy.net/https://raw.githubusercontent.com/MetaCubeX/meta-rules-dat/refs/heads/sing/geo/geosite/category-games.json
https://gh-proxy.com/https://raw.githubusercontent.com/MetaCubeX/meta-rules-dat/refs/heads/sing/geo/geosite/category-games.json
https://ghfast.top/https://raw.githubusercontent.com/MetaCubeX/meta-rules-dat/refs/heads/sing/geo/geosite/category-games.json
可自行替换模板中使用的 CDN, 替换前推荐对这些 CDN 的域名进行 网站测速。另外不推荐 cdn.jsdelivr.net
, 因为它偶尔会被墙。
GitLab 地址举例:
https://gitlab.com/senzyo_sama/as-gist/-/raw/master/Rule/sing-box/downloader.json