隐去 outbounds ,其他信息尽量保真。
版本 1.12+, 越新越好,谢谢🙏🏻

binary 版 是那个 有 github 吗

就是命令行版

呃,照着教程撸,估计你不愿意
可以下载 v2rayN, 然后配置使用 sb 为 core ,添加并激活服务器它会在程序根目录/配置目录生成配置文件,你拷出来照着文档改一下就行。配置文件具体在哪个目录,你自己找一下。

自用的,供参考,分流是根据我自己需要设置的,删掉了很多节点,所以看起来略微有点怪,凑合看,outbounds 部份的思路是先有节点,然后用 urltest 按地区聚合,再用 selector 供选择,自有节点一个,机场节点若干个。因为我这里污染情况还好,所以也没用上 fakeip

我也是最近刚用上这个 sing-box ,自己看了下说明随便鼓捣的

{
"log": {
"level": "error",
"timestamp": true
},
"dns": {
"servers": [
{
"type": "udp",
"server": "223.5.5.5",
"detour": "direct-out",
"tag": "local"
},
{
"type": "udp",
"server": "8.8.8.8",
"detour": "Default",
"tag": "remote"
}
],
"final": "local",
"independent_cache": true,
"strategy": "ipv4_only"
},
"inbounds": [
{
"type": "mixed",
"tag": "mixed-in",
"set_system_proxy": true,
"listen": "127.0.0.1",
"listen_port": 2080
},
{
"type": "tun",
"tag": "tun-in",
"address": [
"172.18.0.1/30"
],
"auto_route": true,
"strict_route": true
}
],
"outbounds": [
{
"type": "direct",
"tag": "direct-out",
"domain_resolver": "local"
},
{
"type": "vless",
"tag": "🇺🇸 La",
"server": "",
"server_port": 443,
"domain_resolver": "remote",
"uuid": "",
"flow": "xtls-rprx-vision",
"tls": {
"enabled": true,
"server_name": "",
"utls": {
"enabled": true,
"fingerprint": "edge"
},
"reality": {
"enabled": true,
"public_key": "",
"short_id": ""
}
}
},
{
"type": "shadowsocks",
"tag": "🇭🇰 香港",
"server": "",
"server_port": 443,
"method": "2022-blake3-aes-128-gcm",
"password": "",
"tcp_fast_open": true
},
{
"type": "selector",
"tag": "Default",
"outbounds": [
"🇺🇸 La",
"🇭🇰 香港",
"🇺🇸 美国",
"🇯🇵 日本",
"🇨🇳 台湾",
"🇸🇬 新加坡"
]
},
{
"type": "selector",
"tag": "OpenAI",
"outbounds": [
"🇺🇸 La",
"🇺🇸 美国",
"🇯🇵 日本",
"🇨🇳 台湾",
"🇸🇬 新加坡"
]
},
{
"type": "selector",
"tag": "GlobalMedia",
"outbounds": [
"🇺🇸 La",
"🇭🇰 香港",
"🇺🇸 美国",
"🇯🇵 日本",
"🇨🇳 台湾",
"🇸🇬 新加坡"
]
},
{
"type": "selector",
"tag": "Steam",
"outbounds": [
"🇺🇸 La",
"🇭🇰 香港",
"🇺🇸 美国",
"🇯🇵 日本",
"🇨🇳 台湾",
"🇸🇬 新加坡"
]
},
{
"type": "selector",
"tag": "Whatsapp",
"outbounds": [
"🇺🇸 La",
"🇭🇰 香港",
"🇺🇸 美国",
"🇯🇵 日本",
"🇨🇳 台湾",
"🇸🇬 新加坡"
]
},
{
"type": "selector",
"tag": "Global",
"outbounds": [
"🇺🇸 La",
"🇭🇰 香港",
"🇺🇸 美国",
"🇯🇵 日本",
"🇨🇳 台湾",
"🇸🇬 新加坡"
]
},
{
"type": "selector",
"tag": "Final",
"outbounds": [
"direct-out",
"🇺🇸 La",
"🇭🇰 香港",
"🇺🇸 美国",
"🇯🇵 日本",
"🇨🇳 台湾",
"🇸🇬 新加坡"
]
},
{
"type": "urltest",
"tag": "🇭🇰 香港",
"outbounds": [
""
]
},
{
"type": "urltest",
"tag": "🇺🇸 美国",
"outbounds": [
""
]
},
{
"type": "urltest",
"tag": "🇯🇵 日本",
"outbounds": [
""
]
},
{
"type": "urltest",
"tag": "🇨🇳 台湾",
"outbounds": [
""
]
},
{
"type": "urltest",
"tag": "🇸🇬 新加坡",
"outbounds": [
""
]
}
],
"route": {
"rules": [
{
"action": "sniff"
},
{
"protocol": "dns",
"action": "hijack-dns"
},
{
"rule_set": [
"OpenAI"
],
"outbound": "OpenAI"
},
{
"rule_set": [
"Steam"
],
"outbound": "Steam"
},
{
"rule_set": [
"Whatsapp"
],
"outbound": "Whatsapp"
},
{
"rule_set": [
"GlobalMedia"
],
"outbound": "GlobalMedia"
},
{
"rule_set": [
"Global"
],
"outbound": "Global"
},
{
"rule_set": [
"Lan",
"Apple",
"SteamCN",
"ChinaMax"
],
"outbound": "direct-out"
}
],
"rule_set": [
{
"tag": "Lan",
"type": "remote",
"format": "binary",
"url": " cdn.jsdelivr.net/gh/senshinya/singbox_ruleset@main/rule/Lan/Lan.srs",
"download_detour": "Default"
},
{
"tag": "Apple",
"type": "remote",
"format": "binary",
"url": " cdn.jsdelivr.net/gh/senshinya/singbox_ruleset@main/rule/Apple/Apple.srs",
"download_detour": "Default"
},
{
"tag": "OpenAI",
"type": "remote",
"format": "binary",
"url": " cdn.jsdelivr.net/gh/senshinya/singbox_ruleset@main/rule/OpenAI/OpenAI.srs",
"download_detour": "Default"
},
{
"tag": "Steam",
"type": "remote",
"format": "binary",
"url": " cdn.jsdelivr.net/gh/senshinya/singbox_ruleset@main/rule/Steam/Steam.srs",
"download_detour": "Default"
},
{
"tag": "Whatsapp",
"type": "remote",
"format": "binary",
"url": " cdn.jsdelivr.net/gh/senshinya/singbox_ruleset@main/rule/Whatsapp/Whatsapp.srs",
"download_detour": "Default"
},
{
"tag": "SteamCN",
"type": "remote",
"format": "binary",
"url": " cdn.jsdelivr.net/gh/senshinya/singbox_ruleset@main/rule/SteamCN/SteamCN.srs",
"download_detour": "Default"
},
{
"tag": "GlobalMedia",
"type": "remote",
"format": "binary",
"url": " cdn.jsdelivr.net/gh/senshinya/singbox_ruleset@main/rule/GlobalMedia/GlobalMedia.srs",
"download_detour": "Default"
},
{
"tag": "Global",
"type": "remote",
"format": "binary",
"url": " cdn.jsdelivr.net/gh/senshinya/singbox_ruleset@main/rule/Global/Global.srs",
"download_detour": "Default"
},
{
"tag": "ChinaMax",
"type": "remote",
"format": "binary",
"url": " cdn.jsdelivr.net/gh/senshinya/singbox_ruleset@main/rule/ChinaMax/ChinaMax.srs",
"download_detour": "Default"
}
],
"default_domain_resolver": "remote",
"auto_detect_interface": true,
"final": "Final"
},
"experimental": {
"cache_file": {
"enabled": true
}
}
}

不想折腾就直接复制官方 wiki 上的例子就可以了 sing-box.sagernet.org/manual/proxy/client/#__tabbed_1_2

这种,dns 流量压根就没进 sing-box

我试试,多谢

你往下拉啊,他是分了两部分,一部分是你本地 tun 和路由规则配置,下面的才是 dns 服务的路由规则和规则集合下载

我照着贴也没有,现在唯一有用的方案是添加一个 inbound listen :: 53 ,然后 sudo networksetup -setdnsservers "Wi-Fi" 127.0.0.1 才管用,但如果是这样才关于,哪些 sniff / hijack-dns 之类的还有啥用啊?

按说 tun 入站还需要配个 listen 53 和设置系统 dns ,做起来也太多余了吧,请教一下是我哪里没弄对吗?

这个很符合你的要求

github.com/OneOhCloud/OneBox/blob/main/src/config/version_1_12/mixed-config.ts

mixed 没问题,我这里的问题是 tun-in 的时候,macOS 系统 dns 请求不进 sing-box ...

也有 tun 配置模板啊
github.com/OneOhCloud/OneBox/blob/main/src/config/version_1_12/tun-config.ts

可以用这个脚本自己生成,Gemini 生成的脚本。
pip3 install requests

python3 sub_converter_final.py -u "机场链接"

drive.google.com/file/d/1v3GHmmewKE-ilrswCuj3tkSvjY0Mc1le/view?usp=drive_link

感谢各位楼上,我好像知道问题原因了,并不是我的配置问题,而是 dns 请求在 macOS 上压根没进 tun ,必须设置一下系统网络 dns ...

github.com/SagerNet/sing-box/issues/3223

自己撸配置要经常维护,版本更新之后,很有可能要去修改下配置

是的,必须要设置系统 dns 才能拦截你的 dns 请求,我都是启动时设置系统 dns ,退出时清空 sudo networksetup -setdnsservers

dns 监听就是要单独开的,issues 里有人问这个问题,答复是不认为这个监听要默认启动。
sing-box 的配置变动太大,每次升级都跟上课一样。

说来奇怪,同一套配置文件,最新版的 singbox ,TUN 模式。使用 GUI 版本一切正常。GLI 版本下内网流量不会进入 singbox ,但目的是外网 IP 的请求就正常。

GUI 做了 CLI 之外的一些事情,比如 dns

看了一下 netstat -rn ,GUI 启动之后会在原有的到网关的 default 条目上面插入一条到 utun 网卡的 default ,而 GLI 没有这个行为。可能是这个原因,但还是无法解释为什么同一个配置文件行为不一样。