自己用的一些 sing-box 配置文件模板, 支持 Toperlock/sing-box-subscribe 远程调用。
#!/bin/bash
url_gene="https://a.com" # 生成配置的后端地址
url_sub="https://b.com" # 来自机场的订阅链接
url_tpl="https://raw.githubusercontent.com/senzyo/sing-box-templates/normal/tun/dot/8.8.8.8/ghproxy.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 图形客户端中添加这个最终的 URL 作为订阅链接。
对于 Linux 和 Windows, 阅读 sing-box on Linux 和 sing-box on Windows。
至于 Toperlock/sing-box-subscribe 的更多参数信息, 阅读其 README.md。
文件按照 "入站方式 → DNS 协议 → DNS 服务商 → CDN" 进行层级划分。
目录结构参考
├── mixed
│ ├── doh
│ │ └── 8.8.8.8
│ │ ├── ghproxy.net
│ │ │ └── config.json
│ │ └── testingcf.jsdelivr.net
│ │ └── config.json
│ └── dot
│ └── 8.8.8.8
│ ├── ghproxy.net
│ │ └── config.json
│ └── testingcf.jsdelivr.net
│ └── config.json
└── tun
├── doh
│ └── 8.8.8.8
│ ├── ghproxy.net
│ │ └── config.json
│ └── testingcf.jsdelivr.net
│ └── config.json
└── dot
└── 8.8.8.8
├── ghproxy.net
│ └── config.json
└── testingcf.jsdelivr.net
└── config.json
"inbounds": [
{
"type": "tun",
"inet4_address": "172.19.0.1/30",
"inet6_address": "fdfe:dcba:9876::1/126",
"gso": false,
"auto_route": true,
"strict_route": true,
"endpoint_independent_nat": false,
"stack": "mixed",
"exclude_package": ["com.android.captiveportallogin"],
"platform": {
"http_proxy": {
"enabled": true,
"server": "127.0.0.1",
"server_port": 7890
}
},
"sniff": true,
"sniff_override_destination": false
},
{
"type": "mixed",
"listen": "::",
"listen_port": 7890,
"sniff": true,
"sniff_override_destination": false
}
],
"inbounds": [
{
"type": "mixed",
"listen": "::",
"listen_port": 7890,
"sniff": true,
"sniff_override_destination": false
}
],
DNS 协议只用 DNS over TLS
或 DNS over HTTPS
, 更多 DNS 协议与格式参考 sing-box 文档。
所有模板的 国内DNS
都使用 阿里DNS
;
国外DNS
使用 AdGuard DNS
, Cisco OpenDNS
, Cloudflare DNS
, Google DNS
中的一个。
更多 DNS 服务商参考 公共DNS。
"dns": {
"servers": [
{
"tag": "国外DNS",
"address": "tls://8.8.8.8",
"detour": "🚀 默认出站"
},
{
"tag": "国内DNS",
"address": "tls://223.5.5.5",
"detour": "🐢 直连"
},
...
],
...
},
仅影响客户端下载规则集的速度。
"route": {
...
"rule_set": [
...
{
"tag": "download-process",
"type": "remote",
"format": "binary",
"url": "https://ghproxy.net/https://raw.githubusercontent.com/senzyo/sing-box-rules/master/download-process.srs",
"download_detour": "🐢 直连",
"update_interval": "3d"
},
...
]
}
规则源地址举例:
https://raw.githubusercontent.com/senzyo/sing-box-rules/master/download-process.srs
CDN 格式列举:
https://fastly.jsdelivr.net/gh/senzyo/sing-box-rules@master/download-process.srs
https://gcore.jsdelivr.net/gh/senzyo/sing-box-rules@master/download-process.srs
https://testingcf.jsdelivr.net/gh/senzyo/sing-box-rules@master/download-process.srs
https://mirror.ghproxy.com/https://raw.githubusercontent.com/senzyo/sing-box-rules/master/download-process.srs
https://ghproxy.net/https://raw.githubusercontent.com/senzyo/sing-box-rules/master/download-process.srs
可自行替换模板中使用的 CDN, 替换前推荐对这些 CDN 的域名进行 网站测速。不推荐 cdn.jsdelivr.net
。
推荐使用入站方式为 tun
的模板:
https://raw.githubusercontent.com/senzyo/sing-box-templates/normal/tun/doh/8.8.8.8/ghproxy.net/config.json
或者使用入站方式为 mixed
的模板:
https://raw.githubusercontent.com/senzyo/sing-box-templates/normal/mixed/doh/8.8.8.8/ghproxy.net/config.json
只推荐使用入站方式为 tun
的模板:
https://raw.githubusercontent.com/senzyo/sing-box-templates/normal/tun/doh/8.8.8.8/ghproxy.net/config.json
由于暂时无法准确分流 BitTorrent 流量, 干脆匹配 下载软件的进程 来一刀切。使用 Bittorrent 方式下载时, 手动切换 📥 Downloader
分组的策略, 改用 🐢 直连
。
根据 issue#883, 如果在 TUN 模式下无法使用进行 SSH 访问, , 需要关闭严格路由:
"inbounds": [
{
"type": "tun",
...
"strict_route": false,
...
},
...
],
如果关闭了严格路由, Linux 平台在 TUN 模式下还是无法使用 IPv6 进行 SSH 访问, 根据 issue#458 得知:
由于技术限制, 在 Linux 平台中 tun 的自动路由会阻止 IPv6 入站连接, 您可以选择手动配置路由。