V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
• 请不要在回答技术问题时复制粘贴 AI 生成的内容
superhack
V2EX  ›  程序员

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

  •  
  •   superhack · 1 天前 · 1039 次点击

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

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

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

    按说 tun 入站还需要配个 listen 53 和设置系统 dns ,做起来也太多余了吧,请教一下是我哪里没弄对吗?
    superhack
        11
    superhack  
    OP
       1 天前
    @huangzhiyia mixed 没问题,我这里的问题是 tun-in 的时候,macOS 系统 dns 请求不进 sing-box ...
    shonnliberty
        13
    shonnliberty  
       1 天前
    可以用这个脚本自己生成,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
       1 天前
    感谢各位楼上,我好像知道问题原因了,并不是我的配置问题,而是 dns 请求在 macOS 上压根没进 tun ,必须设置一下系统网络 dns ...

    https://github.com/SagerNet/sing-box/issues/3223
    fymap
        15
    fymap  
       20 小时 28 分钟前 via Android
    自己撸配置要经常维护,版本更新之后,很有可能要去修改下配置
    weofuh
        16
    weofuh  
       19 小时 36 分钟前
    @superhack 是的,必须要设置系统 dns 才能拦截你的 dns 请求,我都是启动时设置系统 dns ,退出时清空 sudo networksetup -setdnsservers
    wheat0r
        17
    wheat0r  
       19 小时 28 分钟前   ❤️ 1
    dns 监听就是要单独开的,issues 里有人问这个问题,答复是不认为这个监听要默认启动。
    sing-box 的配置变动太大,每次升级都跟上课一样。
    LOGOSJ
        18
    LOGOSJ  
       18 小时 38 分钟前 via iPhone
    说来奇怪,同一套配置文件,最新版的 singbox ,TUN 模式。使用 GUI 版本一切正常。GLI 版本下内网流量不会进入 singbox ,但目的是外网 IP 的请求就正常。
    superhack
        19
    superhack  
    OP
       18 小时 32 分钟前
    @LOGOSJ GUI 做了 CLI 之外的一些事情,比如 dns
    LOGOSJ
        20
    LOGOSJ  
       18 小时 27 分钟前 via iPhone
    @superhack 看了一下 netstat -rn ,GUI 启动之后会在原有的到网关的 default 条目上面插入一条到 utun 网卡的 default ,而 GLI 没有这个行为。可能是这个原因,但还是无法解释为什么同一个配置文件行为不一样。
    Richared
        21
    Richared  
       11 小时 44 分钟前
    @LOGOSJ #18 因为 gui 走的是系统的 vpn ,可以劫持所有的流量,但是 cli 劫持不了 dns ,singbox 开启 dns 服务,然后本机 dns 指向 singbox 就行了。或者自己写劫持规则。
    关于   ·   帮助文档   ·   自助推广系统   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   901 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 50ms · UTC 20:31 · PVG 04:31 · LAX 13:31 · JFK 16:31
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.