sing-box 是一款基于 Go 语言开发的新一代代理工具,支持 Shadowsocks、VMess、Trojan、Hysteria 2、VLESS 等多种协议。相比 Clash,sing-box 内核更轻量、性能更强,且原生支持 iOS、Android、Windows、macOS 和 Linux 全平台。
🚀 推荐资源:
机场推荐 — 稳定高速的节点服务商
机场客户端下载 — 各平台客户端合集
一、sing-box 简介
1.1 核心特性
| 特性 | 说明 |
|---|---|
| 多协议支持 | Shadowsocks、VMess、Trojan、Hysteria 2、VLESS、Reality 等 |
| 全平台覆盖 | iOS、Android、Windows、macOS、Linux、路由器 |
| 高性能内核 | Go 语言编写,内存占用低,并发处理能力强 |
| 规则引擎 | 支持 GeoIP、Geosite、自定义规则集,分流精准 |
| TUN 模式 | 系统级代理,无需手动配置系统代理设置 |
| 可视化客户端 | SFA (Android)、SFI (iOS)、SFM (macOS) 官方客户端 |
1.2 适用场景
- 进阶用户:需要更精细的流量控制和规则分流
- 多设备用户:统一配置跨平台同步
- 性能敏感:追求更低的延迟和更高的吞吐量
- 协议尝鲜:第一时间体验 Hysteria 2、Reality 等新协议
二、各平台安装指南
2.1 Windows 安装
方法一:官方客户端 SFM (sing-box for Windows)
- 访问 GitHub Releases
- 下载
sing-box-1.11.x-windows-amd64.zip - 解压到任意目录(如
C:\sing-box) - 双击运行
sing-box.exe
方法二:命令行安装(推荐高级用户)
# 使用 PowerShell
Invoke-WebRequest -Uri "https://github.com/SagerNet/sing-box/releases/latest/download/sing-box-1.11.0-windows-amd64.zip" -OutFile "sing-box.zip"
Expand-Archive -Path "sing-box.zip" -DestinationPath "C:\sing-box"
cd C:\sing-box
.\sing-box.exe version
2.2 macOS 安装
# 使用 Homebrew
brew install sing-box
# 或下载官方客户端 SFM
brew install --cask sfm
2.3 Linux 安装
# Debian/Ubuntu
curl -fsSL https://sing-box.app/deb-install.sh | bash
# 或手动安装
wget https://github.com/SagerNet/sing-box/releases/latest/download/sing-box-1.11.0-linux-amd64.tar.gz
tar -xzf sing-box-1.11.0-linux-amd64.tar.gz
sudo mv sing-box /usr/local/bin/
2.4 Android 安装 (SFA)
- Google Play 搜索 “sing-box”
- 或下载 APK:GitHub Releases
- 安装后授予 VPN 权限
2.5 iOS 安装 (SFI)
- App Store 搜索 “sing-box”(国区可能不可用,需切换外区账号)
- 或使用 TestFlight 安装测试版
三、配置文件详解
3.1 基础配置结构
{
"log": {
"level": "info",
"timestamp": true
},
"dns": {
"servers": [
{
"tag": "google",
"address": "tls://8.8.8.8",
"detour": "proxy"
},
{
"tag": "local",
"address": "223.5.5.5",
"detour": "direct"
}
],
"rules": [
{
"rule_set": "geosite-cn",
"server": "local"
}
],
"final": "google"
},
"inbounds": [
{
"type": "mixed",
"tag": "mixed-in",
"listen": "127.0.0.1",
"listen_port": 7890
},
{
"type": "tun",
"tag": "tun-in",
"inet4_address": "172.19.0.1/30",
"auto_route": true,
"strict_route": true,
"sniff": true
}
],
"outbounds": [
{
"type": "selector",
"tag": "proxy",
"outbounds": ["auto", "direct"],
"default": "auto"
},
{
"type": "urltest",
"tag": "auto",
"outbounds": ["hk", "jp", "us"],
"url": "http://www.gstatic.com/generate_204",
"interval": "1m"
},
{
"type": "shadowsocks",
"tag": "hk",
"server": "hk.example.com",
"server_port": 443,
"method": "2022-blake3-aes-128-gcm",
"password": "your-password"
},
{
"type": "vmess",
"tag": "jp",
"server": "jp.example.com",
"server_port": 443,
"uuid": "your-uuid",
"security": "auto",
"transport": {
"type": "ws",
"path": "/path"
}
},
{
"type": "trojan",
"tag": "us",
"server": "us.example.com",
"server_port": 443,
"password": "your-password",
"tls": {
"enabled": true,
"server_name": "us.example.com"
}
},
{
"type": "direct",
"tag": "direct"
},
{
"type": "block",
"tag": "block"
}
],
"route": {
"rules": [
{
"rule_set": "geosite-private",
"outbound": "direct"
},
{
"rule_set": "geoip-private",
"outbound": "direct"
},
{
"rule_set": "geosite-cn",
"outbound": "direct"
},
{
"rule_set": "geoip-cn",
"outbound": "direct"
}
],
"rule_set": [
{
"tag": "geoip-cn",
"type": "remote",
"format": "binary",
"url": "https://raw.githubusercontent.com/SagerNet/sing-geoip/rule-set/geoip-cn.srs",
"download_detour": "proxy"
},
{
"tag": "geosite-cn",
"type": "remote",
"format": "binary",
"url": "https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-cn.srs",
"download_detour": "proxy"
}
],
"final": "proxy",
"auto_detect_interface": true
},
"experimental": {
"cache_file": {
"enabled": true
}
}
}
3.2 配置字段说明
| 字段 | 说明 | 必填 |
|---|---|---|
log.level |
日志级别:debug/info/warn/error | 否 |
dns.servers |
DNS 服务器列表,支持 DoH/DoT/UDP | 是 |
inbounds |
入站协议:mixed(HTTP+SOCKS)、tun、redirect 等 | 是 |
outbounds |
出站协议:shadowsocks、vmess、trojan、hysteria2 等 | 是 |
route.rules |
路由规则:按域名、IP、规则集分流 | 否 |
experimental |
实验性功能:缓存文件等 | 否 |
四、订阅转换与导入
4.1 订阅链接转换
sing-box 支持多种订阅格式,可直接导入:
- Clash 订阅:自动转换为 sing-box 配置
- Base64 订阅:SS/VMess/Trojan 通用格式
- SIP008:Shadowsocks 标准订阅
4.2 配置文件路径
| 平台 | 配置文件路径 |
|---|---|
| Windows | %LOCALAPPDATA%\sing-box\config.json |
| macOS | ~/Library/Application Support/sing-box/config.json |
| Linux | ~/.config/sing-box/config.json |
| Android | 应用内导入/导出 |
| iOS | 应用内导入/导出 |
五、启动与使用
5.1 命令行启动
# 前台运行
sing-box run -c config.json
# 后台运行(Linux/macOS)
nohup sing-box run -c config.json > /dev/null 2>&1 &
# 验证配置
sing-box check -c config.json
5.2 系统服务(systemd)
# 创建服务文件
sudo tee /etc/systemd/system/sing-box.service > /dev/null <<EOF
[Unit]
Description=sing-box service
After=network.target
[Service]
Type=simple
User=root
ExecStart=/usr/local/bin/sing-box run -c /etc/sing-box/config.json
Restart=on-failure
RestartSec=10
[Install]
WantedBy=multi-user.target
EOF
# 启动服务
sudo systemctl daemon-reload
sudo systemctl enable sing-box
sudo systemctl start sing-box
sudo systemctl status sing-box
六、进阶功能
6.1 TUN 模式(透明代理)
TUN 模式可以接管系统所有流量,无需手动设置系统代理:
{
"type": "tun",
"tag": "tun-in",
"inet4_address": "172.19.0.1/30",
"auto_route": true,
"strict_route": true,
"sniff": true,
"sniff_override_destination": false
}
6.2 多出口负载均衡
{
"type": "urltest",
"tag": "auto",
"outbounds": ["hk", "jp", "us", "sg"],
"url": "http://www.gstatic.com/generate_204",
"interval": "1m",
"tolerance": 50
}
6.3 Reality 协议配置
{
"type": "vless",
"tag": "reality",
"server": "server.com",
"server_port": 443,
"uuid": "your-uuid",
"flow": "xtls-rprx-vision",
"tls": {
"enabled": true,
"server_name": "www.microsoft.com",
"utls": {
"enabled": true,
"fingerprint": "chrome"
},
"reality": {
"enabled": true,
"public_key": "your-public-key",
"short_id": "your-short-id"
}
}
}
七、常见问题排查
| 问题 | 解决方案 |
|---|---|
| 无法启动 | 检查配置文件 JSON 格式,使用 sing-box check 验证 |
| DNS 解析失败 | 检查 DNS 服务器配置,确保 detour 指向可用出站 |
| TUN 模式无效 | 以管理员/root 权限运行,检查防火墙设置 |
| 规则不生效 | 检查规则集下载是否成功,确认规则顺序 |
| 连接速度慢 | 尝试更换节点,调整 MTU 值,启用多路复用 |
| 内存占用高 | 降低日志级别,关闭不必要的 sniff 功能 |
八、相关资源推荐
- 机场推荐 — 稳定高速的节点服务商,支持 sing-box 订阅
- 机场客户端下载 — 各平台客户端下载合集
- 官方文档 — sing-box 完整配置参考
- GitHub 仓库 — 源码与 Releases
九、总结
sing-box 作为新一代代理工具,凭借其高性能、多协议支持和全平台覆盖,正在逐渐成为进阶用户的首选。通过本教程,你应该已经掌握了从安装到配置的完整流程。
如果你是初次接触代理工具,建议先从 机场客户端下载 获取图形界面客户端;如果你追求极致性能和灵活配置,sing-box 的命令行模式将是你的最佳选择。
如有任何问题,欢迎在评论区留言交流!
发表回复