求一份 sing-box binary 版客户端在 macOS 上的可用配置 - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
请不要在回答技术问题时复制粘贴 AI 生成的内容
superhack
V2EX    程序员

求一份 sing-box binary 版客户端在 macOS 上的可用配置

  •  
  •   superhack 36 天前 1961 次点击
    这是一个创建于 36 天前的主题,其中的信息可能已经有所发展或是发生改变。

    隐去 outbounds ,其他信息尽量保真。

    版本 1.12+, 越新越好,谢谢

    22 条回复    2025-09-25 18:45:15 +08:00
    wxyrrcj
        1
    wxyrrcj  
       36 天前
    binary 版 是那个 有 github 吗
    superhack
        2
    superhack  
    OP
       36 天前
    @wxyrrcj 就是命令行版
    RobinHuuu
        3
    RobinHuuu  
       36 天前 via iPhone
    呃,照着教程撸,估计你不愿意
    可以下载 v2rayN, 然后配置使用 sb 为 core ,添加并激活服务器它会在程序根目录/配置目录生成配置文件,你拷出来照着文档改一下就行。配置文件具体在哪个目录,你自己找一下。
    clarkethan
        4
    clarkethan  
       36 天前
    自用的,供参考,分流是根据我自己需要设置的,删掉了很多节点,所以看起来略微有点怪,凑合看,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": "https://cdn.jsdelivr.net/gh/senshinya/singbox_ruleset@main/rule/Lan/Lan.srs",
    "download_detour": "Default"
    },
    {
    "tag": "Apple",
    "type": "remote",
    "format": "binary",
    "url": "https://cdn.jsdelivr.net/gh/senshinya/singbox_ruleset@main/rule/Apple/Apple.srs",
    "download_detour": "Default"
    },
    {
    "tag": "OpenAI",
    "type": "remote",
    "format": "binary",
    "url": "https://cdn.jsdelivr.net/gh/senshinya/singbox_ruleset@main/rule/OpenAI/OpenAI.srs",
    "download_detour": "Default"
    },
    {
    "tag": "Steam",
    "type": "remote",
    "format": "binary",
    "url": "https://cdn.jsdelivr.net/gh/senshinya/singbox_ruleset@main/rule/Steam/Steam.srs",
    "download_detour": "Default"
    },
    {
    "tag": "Whatsapp",
    "type": "remote",
    "format": "binary",
    "url": "https://cdn.jsdelivr.net/gh/senshinya/singbox_ruleset@main/rule/Whatsapp/Whatsapp.srs",
    "download_detour": "Default"
    },
    {
    "tag": "SteamCN",
    "type": "remote",
    "format": "binary",
    "url": "https://cdn.jsdelivr.net/gh/senshinya/singbox_ruleset@main/rule/SteamCN/SteamCN.srs",
    "download_detour": "Default"
    },
    {
    "tag": "GlobalMedia",
    "type": "remote",
    "format": "binary",
    "url": "https://cdn.jsdelivr.net/gh/senshinya/singbox_ruleset@main/rule/GlobalMedia/GlobalMedia.srs",
    "download_detour": "Default"
    },
    {
    "tag": "Global",
    "type": "remote",
    "format": "binary",
    "url": "https://cdn.jsdelivr.net/gh/senshinya/singbox_ruleset@main/rule/Global/Global.srs",
    "download_detour": "Default"
    },
    {
    "tag": "ChinaMax",
    "type": "remote",
    "format": "binary",
    "url": "https://cdn.jsdelivr.net/gh/senshinya/singbox_ruleset@man/rule/ChinaMax/ChinaMax.srs",
    "download_detour": "Default"
    }
    ],
    "default_domain_resolver": "remote",
    "auto_detect_interface": true,
    "final": "Final"
    },
    "experimental": {
    "cache_file": {
    "enabled": true
    }
    }
    }
    weofuh
        5
    weofuh  
       36 天前
    不想折腾就直接复制官方 wiki 上的例子就可以了 https://sing-box.sagernet.org/manual/proxy/client/#__tabbed_1_2
    superhack
        6
    superhack  
    OP
       36 天前 via Android
    @weofuh 这种,dns 流量压根就没进 sing-box
    superhack
        7
    superhack  
    OP
       36 天前 via Android
    @RobinHuuu 我试试,多谢
    weofuh
        8
    weofuh  
       36 天前
    @superhack 你往下拉啊,他是分了两部分,一部分是你本地 tun 和路由规则配置,下面的才是 dns 服务的路由规则和规则集合下载
    superhack
        9
    superhack  
    OP
       36 天前
    @weofuh 我照着贴也没有,现在唯一有用的方案是添加一个 inbound listen :: 53 ,然后 `sudo networksetup -setdnsservers "Wi-Fi" 127.0.0.1 ` 才管用,但如果是这样才关于,哪些 sniff / hijack-dns 之类的还有啥用啊?

    按说 tun 入站还需要配个 listen 53 和设置系统 dns ,做起来也太多余了吧,请教一下是我哪里没弄对吗?
    superhack
        11
    superhack  
    OP
       36 天前
    @huangzhiyia mixed 没问题,我这里的问题是 tun-in 的时候,macOS 系统 dns 请求不进 sing-box ...
    shonnliberty
        13
    shonnliberty  
       36 天前
    可以用这个脚本自己生成,Gemini 生成的脚本。
    pip3 install requests

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

    https://drive.google.com/file/d/1v3GHmmewKE-ilrswCuj3tkSvjY0Mc1le/view?usp=drive_link
    superhack
        14
    superhack  
    OP
       36 天前
    感谢各位楼上,我好像知道问题原因了,并不是我的配置问题,而是 dns 请求在 macOS 上压根没进 tun ,必须设置一下系统网络 dns ...

    https://github.com/SagerNet/sing-box/issues/3223
    fymap
        15
    fymap  
       35 天前 via Android
    自己撸配置要经常维护,版本更新之后,很有可能要去修改下配置
    weofuh
        16
    weofuh  
       35 天前
    @superhack 是的,必须要设置系统 dns 才能拦截你的 dns 请求,我都是启动时设置系统 dns ,退出时清空 sudo networksetup -setdnsservers
    wheat0r
        17
    wheat0r  
       35 天前   1
    dns 监听就是要单独开的,issues 里有人问这个问题,答复是不认为这个监听要默认启动。
    sing-box 的配置变动太大,每次升级都跟上课一样。
    LOGOSJ
        18
    LOGOSJ  
       35 天前 via iPhone
    说来奇怪,同一套配置文件,最新版的 singbox ,TUN 模式。使用 GUI 版本一切正常。GLI 版本下内网流量不会进入 singbox ,但目的是外网 IP 的请求就正常。
    superhack
        19
    superhack  
    OP
       35 天前
    @LOGOSJ GUI 做了 CLI 之外的一些事情,比如 dns
    LOGOSJ
        20
    LOGOSJ  
       35 天前 via iPhone
    @superhack 看了一下 netstat -rn ,GUI 启动之后会在原有的到网关的 default 条目上面插入一条到 utun 网卡的 default ,而 GLI 没有这个行为。可能是这个原因,但还是无法解释为什么同一个配置文件行为不一样。
    Cruzz
        21
    Cruzz  
       35 天前
    @LOGOSJ #18 因为 gui 走的是系统的 vpn ,可以劫持所有的流量,但是 cli 劫持不了 dns ,singbox 开启 dns 服务,然后本机 dns 指向 singbox 就行了。或者自己写劫持规则。
    zaihuilvcha
        22
    zaihuilvcha  
       15 天前
    这个问题真的蛋疼,图形化客户端确实会自动设置 dns (开启时会直接改系统的 /etc/resolv.conf ) ,但是命令行版就没有这个行为,每次还要手动去设置 dns 也太麻烦了……
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     1030 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 25ms UTC 18:38 PVG 02:38 LAX 11:38 JFK 14:38
    Do have faith in what you're doing.
    ubao snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86