随着SagerNet作者持续“发烧”
升级Sing-box,它的功能变得更强大,性能更加稳定。官方教程配置更新存在滞后,导致低版本程序无法套用现有的官方json配置。从v1.1.6版本为断点,1.1.6版本的,version最大只支持到2,而小于1.1.6的版本,默认version只支持1。即使自行修改配置version=3,程序也会报错无法运行。所以,如果你正在学习Sing-box官方配置,请一定要使用它最新版本程序。本期分享新版核心配置通信流程,展示多用户配置设置和sing-box全局配置代码示例,
及各项疑难解答,算是sing-box进阶教程,如果你是新手,请先看“Sing-box新手教程”
本文默认你有vps,并且已搭建升级好sing-box服务端,如果首次搭建sing-box服务端,请复制以下一键脚本安装。
wget -N --no-check-certificate https://raw.githubusercontent.com/lanhebe/singbox-shadowtls/main/mps_Sing-box.sh && chmod +x mps_Sing-box.sh && bash mps_Sing-box.sh
以下用的是sing-box-1.2-beta10做的两人共用配置测试,如需增设用户数量,详见users突亮代码行依次增加。
{ "inbounds": [ { "type": "shadowtls", "listen": "::", "listen_port": 443, "version": 3, "users": [ { "name": "sekai", "password": "ypGGDagcyFKCf5TYJyH0fw==" }, { "name": "hebe", "password": "1pGGDagcyFKCa8TYYyH0fw==" } ], "handshake": { "server": "www.ebay.com", "server_port": 443 }, "detour": "shadowsocks-in" }, { "type": "shadowsocks", "tag": "shadowsocks-in", "listen": "127.0.0.1", "network": "tcp", "method": "2022-blake3-aes-128-gcm", "password": "PAJdSIxI6tZdR0UqMtBaLQ==" } ] }
{ "inbounds": [ { "type": "mixed", "listen_port": 1080, "sniff": true, "set_system_proxy": true } ], "outbounds": [ { "type": "shadowsocks", "method": "2022-blake3-aes-128-gcm", "password": "PAJdSIxI6tZdR0UqMtBaLQ==", "detour": "shadowtls-out", "multiplex": { "enabled": true, "max_connections": 4, "min_streams": 4 } }, { "type": "shadowtls", "tag": "shadowtls-out", "server": "更改成自己IP", "server_port": 443, "version": 3, "password": "ypGGDagcyFKCf5TYJyH0fw==", "tls": { "enabled": true, "server_name": "www.ebay.com" } }, { "type": "direct", "tag": "direct" }, { "type": "block", "tag": "block" } ], "route": { "rules": [ { "geosite": "cn", "geoip": "cn", "outbound": "direct" }, { "geosite": "category-ads-all", "outbound": "block" } ] } }
{ "inbounds": [ { "type": "mixed", "listen_port": 1080, "sniff": true, "set_system_proxy": true } ], "outbounds": [ { "type": "shadowsocks", "method": "2022-blake3-aes-128-gcm", "password": "PAJdSIxI6tZdR0UqMtBaLQ==", "detour": "shadowtls-out", "multiplex": { "enabled": true, "max_connections": 4, "min_streams": 4 } }, { "type": "shadowtls", "tag": "shadowtls-out", "server": "更改成自己IP", "server_port": 443, "version": 3, "password": "ypGGDagcyFKCf5TYJyH0fw==", "tls": { "enabled": true, "server_name": "www.ebay.com" } }, { "type": "direct", "tag": "direct" }, { "type": "block", "tag": "block" } ], "route": { "rules": [ { "geosite": "category-ads-all", "outbound": "block" } ] } }
{ "dns": { "servers": [ { "tag": "google", "address": "tls://8.8.8.8" }, { "tag": "local", "address": "223.5.5.5", "detour": "direct" } ], "rules": [ { "geosite": "cn", "server": "local" } ], "strategy": "ipv4_only" }, "inbounds": [ { "type": "tun", "inet4_address": "172.19.0.1/30", "auto_route": true, "sniff": true } ], "outbounds": [ { "type": "shadowsocks", "method": "2022-blake3-aes-128-gcm", "password": "PAJdSIxI6tZdR0UqMtBaLQ==", "detour": "shadowtls-out", "multiplex": { "enabled": true, "max_connections": 4, "min_streams": 4 } }, { "type": "shadowtls", "tag": "shadowtls-out", "server": "更改成自己IP", "server_port": 443, "password": "ypGGDagcyFKCf5TYJyH0fw==", "version": 3, "tls": { "enabled": true, "server_name": "www.ebay.com" } }, { "type": "direct", "tag": "direct" }, { "type": "block", "tag": "block" }, { "type": "dns", "tag": "dns-out" } ], "route": { "rules": [ { "protocol": "dns", "outbound": "dns-out" }, { "geosite": "cn", "geoip": "cn", "outbound": "direct" }, { "geosite": "category-ads-all", "outbound": "block" } ], "auto_detect_interface": true } }
{ "inbounds": [ { "type": "mixed", "listen_port": 1080, "sniff": true, "set_system_proxy": true } ], "outbounds": [ { "type": "shadowsocks", "method": "2022-blake3-aes-128-gcm", "password": "PAJdSIxI6tZdR0UqMtBaLQ==", "detour": "shadowtls-out", "multiplex": { "enabled": true, "max_connections": 4, "min_streams": 4 } }, { "type": "shadowtls", "tag": "shadowtls-out", "server": "更改成自己IP", "server_port": 443, "version": 3, "password": "1pGGDagcyFKCa8TYYyH0fw==", "tls": { "enabled": true, "server_name": "www.ebay.com" } }, { "type": "direct", "tag": "direct" }, { "type": "block", "tag": "block" } ], "route": { "rules": [ { "geosite": "cn", "geoip": "cn", "outbound": "direct" }, { "geosite": "category-ads-all", "outbound": "block" } ] } }
{ "dns": { "servers": [ { "tag": "google", "address": "tls://8.8.8.8" }, { "tag": "local", "address": "223.5.5.5", "detour": "direct" } ], "rules": [ { "geosite": "cn", "server": "local" } ], "strategy": "ipv4_only" }, "inbounds": [ { "type": "tun", "inet4_address": "172.19.0.1/30", "auto_route": true, "sniff": true } ], "outbounds": [ { "type": "shadowsocks", "method": "2022-blake3-aes-128-gcm", "password": "PAJdSIxI6tZdR0UqMtBaLQ==", "detour": "shadowtls-out", "multiplex": { "enabled": true, "max_connections": 4, "min_streams": 4 } }, { "type": "shadowtls", "tag": "shadowtls-out", "server": "更改成自己IP", "server_port": 443, "password": "1pGGDagcyFKCa8TYYyH0fw==", "version": 3, "tls": { "enabled": true, "server_name": "www.ebay.com" } }, { "type": "direct", "tag": "direct" }, { "type": "block", "tag": "block" }, { "type": "dns", "tag": "dns-out" } ], "route": { "rules": [ { "protocol": "dns", "outbound": "dns-out" }, { "geosite": "cn", "geoip": "cn", "outbound": "direct" }, { "geosite": "category-ads-all", "outbound": "block" } ], "auto_detect_interface": true } }
{ "dns": { "servers": [ { "tag": "google", "address": "tls://8.8.8.8" }, { "tag": "local", "address": "223.5.5.5", "detour": "direct" } ], "rules": [ { "geosite": "cn", "server": "local" } ], "strategy": "ipv4_only" }, "inbounds": [ { "type": "tun", "inet4_address": "172.19.0.1/30", "auto_route": true, "sniff": true } ], "outbounds": [ { "type": "shadowsocks", "method": "2022-blake3-aes-128-gcm", "password": "PAJdSIxI6tZdR0UqMtBaLQ==", "detour": "shadowtls-out", "multiplex": { "enabled": true, "max_connections": 4, "min_streams": 4 } }, { "type": "shadowtls", "tag": "shadowtls-out", "server": "更改成自己IP", "server_port": 443, "password": "1pGGDagcyFKCa8TYYyH0fw==", "version": 3, "tls": { "enabled": true, "server_name": "www.ebay.com" } }, { "type": "direct", "tag": "direct" }, { "type": "block", "tag": "block" }, { "type": "dns", "tag": "dns-out" } ], "route": { "rules": [ { "protocol": "dns", "outbound": "dns-out" }, { "geosite": "category-ads-all", "outbound": "block" } ], "auto_detect_interface": true } }
Sing-box图形客户端使用教程详见此处,此处略。
bad timestamp: received
原因:客户端系统时间不正确;解决办法:纠正客户端系统时间为正确北京时间即可。
client hello verify failed: hmac mismatch
原因:password错误或没有设置;解决办法:检查两端密码是否设置一致,或一方增加密码设置。
如果本文对你非常有用!不妨点赞并转发,感谢支持!