网络工具
sing-box
新一代通用代理平台 sing-box 使用指南
sing-box 是由 SagerNet 开发者维护的新一代通用代理平台,定位为 Xray 和 Clash 的统一替代方案。
为什么选择 sing-box?
- 统一配置格式 — JSON 配置,结构清晰
- 全协议支持 — SS、VMess、VLESS、Trojan、Hysteria2、TUIC、WireGuard、Reality
- 高性能 — Go 语言编写,内存占用低
- 全平台客户端 — 官方提供各平台 GUI 客户端
- 活跃开发 — 越来越多机场开始提供 sing-box 订阅
客户端
| 平台 | 客户端 | 说明 |
|---|---|---|
| Android | SFA (sing-box for Android) | 官方客户端 |
| iOS | SFI (sing-box for iOS) | 官方客户端,App Store 可下载 |
| macOS | SFM (sing-box for Mac) | 官方客户端 |
| Windows | SFM | 官方客户端 |
| Linux | sing-box CLI | 命令行使用 |
配置文件结构
sing-box 使用 JSON 配置,核心结构:
{
"log": {
"level": "info"
},
"dns": {
"servers": [
{
"tag": "google",
"address": "tls://8.8.8.8"
},
{
"tag": "local",
"address": "223.5.5.5",
"detour": "direct"
}
],
"rules": [
{
"geosite": "cn",
"server": "local"
}
]
},
"inbounds": [
{
"type": "tun",
"inet4_address": "172.19.0.1/30",
"auto_route": true,
"strict_route": true
}
],
"outbounds": [
{
"type": "vless",
"tag": "proxy",
"server": "example.com",
"server_port": 443,
"uuid": "your-uuid",
"tls": {
"enabled": true,
"server_name": "example.com"
},
"transport": {
"type": "ws",
"path": "/ws"
}
},
{
"type": "direct",
"tag": "direct"
},
{
"type": "block",
"tag": "block"
}
],
"route": {
"rules": [
{
"geosite": "cn",
"geoip": "cn",
"outbound": "direct"
},
{
"geosite": "category-ads-all",
"outbound": "block"
}
],
"final": "proxy"
}
}核心概念
Inbounds(入站)
接收本地流量的方式:
- tun — 系统级接管所有流量(推荐)
- mixed — HTTP/SOCKS5 混合代理
- http — HTTP 代理
- socks — SOCKS5 代理
Outbounds(出站)
流量的出口方式,就是你的代理节点配置。
Route(路由)
分流规则,决定流量走 proxy 还是 direct:
{
"route": {
"rules": [
{ "geosite": "cn", "outbound": "direct" },
{ "geoip": "cn", "outbound": "direct" },
{ "geosite": "google", "outbound": "proxy" }
],
"final": "proxy"
}
}Rule Set(规则集)
支持远程规则集,自动更新:
{
"route": {
"rule_set": [
{
"tag": "geosite-cn",
"type": "remote",
"url": "https://example.com/geosite-cn.srs",
"format": "binary"
}
]
}
}使用订阅
大部分机场已支持 sing-box 订阅格式:
- 在机场控制面板找到 sing-box 订阅链接
- 在客户端导入订阅 URL
- 选择节点,启动代理
sing-box vs Clash vs Xray
| 特性 | sing-box | Clash (mihomo) | Xray |
|---|---|---|---|
| 配置格式 | JSON | YAML | JSON |
| 协议支持 | 全面 | 全面 | 全面 |
| GUI 客户端 | 官方多平台 | 第三方 | 第三方 |
| 性能 | 优秀 | 良好 | 优秀 |
| 学习曲线 | 中等 | 低 | 高 |
| 规则系统 | 强大 | 强大 | 基础 |
| 社区生态 | 快速增长 | 成熟 | 成熟 |