sing-box代理使用攻略

sing-box 是一款跨平台、高性能的代理工具,支持多种协议(如 VLESS、VMess、Trojan、Shadowsocks 等),可用于客户端代理上网或服务端搭建。

一、客户端使用(以 Windows/macOS/Linux 为例)

1. 下载安装

Windows

macOS

Linux(命令行)

1
2
3
4
5
6
7
8
# Debian/Ubuntu
bash <(curl -fsSL https://sing-box.app/deb-install.sh)

# RedHat/CentOS
bash <(curl -fsSL https://sing-box.app/rpm-install.sh)

# Arch
bash <(curl -fsSL https://sing-box.app/arch-install.sh)

2. 配置文件(核心)

sing-box 用 JSON 配置文件(如 config.json)定义代理、路由、入站/出站。

最小配置示例(VLESS 客户端)

  • 关键说明:
    • inbounds:本地代理端口(默认 7890,HTTP/SOCKS5 混合)。
    • outbounds:定义代理节点(VLESS/Trojan/VMess 等)。
    • route:分流规则(国外走代理,国内直连)。

订阅转换

若只有 Clash 订阅,用工具转成 sing-box 格式:

  • 在线工具:在线订阅转换工具
  • 操作:粘贴 Clash 订阅 → 选择输出格式为 sing-box → 生成并下载 config.json

3. 启动与使用

命令行(通用)

1
2
3
4
5
# 前台运行
sing-box run -c config.json

# 后台运行(Linux/macOS)
nohup sing-box run -c config.json > sing-box.log 2>&1 &

GUI 客户端(Windows/macOS)

  1. 打开 sing-box GUI → 进入 Profiles → 新建配置。
  2. 选择 remote,粘贴转换后的订阅链接,保存。
  3. 返回 Dashboard → 选择配置 → 点击 启动
  4. 浏览器/系统设置代理为:127.0.0.1:7890

4. 常见问题

  • 无法连接:检查服务器 IP/端口/UUID/TLS 配置是否正确。
  • 速度慢:更换节点、开启 utls 指纹、调整 flow(如 xtls-rprx-vision)。
  • 分流失效:确保 geosite 规则文件存在(sing-box 会自动下载)。

二、服务端搭建(Linux,以 VLESS+XTLS 为例)

1. 安装内核

1
bash <(curl -fsSL https://sing-box.app/deb-install.sh)

2. 服务端配置(/etc/sing-box/config.json)

  • 证书:用 Let’s Encrypt 申请(certbot),确保域名解析到服务器。

3. 启动与管理

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# 启动
sudo systemctl start sing-box

# 开机自启
sudo systemctl enable sing-box

# 查看状态
sudo systemctl status sing-box

# 重启
sudo systemctl restart sing-box

4、自建海外节点

自建sing-box代理海外节点

三、Android 客户端

  1. 下载:sing-box for Android(APK)。
  2. 安装:允许未知来源应用。
  3. 配置:
    • 打开 APP → 点击 + → 选择 从文件导入粘贴订阅
    • 选择配置 → 点击 启动,开启 VPN 权限。

四、核心概念速记

  • inbounds:本地入站(代理端口)。
  • outbounds:出站节点(代理/直连)。
  • route:分流规则(按域名/IP 走不同出站)。
  • tls/utls:加密与指纹伪装(提升兼容性)。
原文链接: https://www.17you.com/tool/sing-box%E4%BD%BF%E7%94%A8/ 已复制!
脚本编程和自动化工具

寻找技术支持帮助和技术合伙人一起搞事。

请点击联系我


相关内容