🐾LuoLuo Wiki
网络工具

sing-box

新一代通用代理平台 sing-box 使用指南

sing-box 是由 SagerNet 开发者维护的新一代通用代理平台,定位为 Xray 和 Clash 的统一替代方案。

为什么选择 sing-box?

  • 统一配置格式 — JSON 配置,结构清晰
  • 全协议支持 — SS、VMess、VLESS、Trojan、Hysteria2、TUIC、WireGuard、Reality
  • 高性能 — Go 语言编写,内存占用低
  • 全平台客户端 — 官方提供各平台 GUI 客户端
  • 活跃开发 — 越来越多机场开始提供 sing-box 订阅

客户端

平台客户端说明
AndroidSFA (sing-box for Android)官方客户端
iOSSFI (sing-box for iOS)官方客户端,App Store 可下载
macOSSFM (sing-box for Mac)官方客户端
WindowsSFM官方客户端
Linuxsing-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 订阅格式:

  1. 在机场控制面板找到 sing-box 订阅链接
  2. 在客户端导入订阅 URL
  3. 选择节点,启动代理

sing-box vs Clash vs Xray

特性sing-boxClash (mihomo)Xray
配置格式JSONYAMLJSON
协议支持全面全面全面
GUI 客户端官方多平台第三方第三方
性能优秀良好优秀
学习曲线中等
规则系统强大强大基础
社区生态快速增长成熟成熟

On this page