V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
beginor
V2EX  ›  问与答

求一份在 macOS 上能用的 sing-box 1.12 的 tun 配置

  •  
  •   beginor · 23 小时 34 分钟前 · 578 次点击

    最近在看 sing-box 的配置看看如何分流,有点儿上头。 混合 (mined) 模式+设置系统代理很容易就配置好了, 但是 tun 模式在 mac 上总是出错。

    sing-box 的 GitHub 上的 issue 中也有类似的问题, 照着配置了也是出错。

    也问 chatgpt ,根据提示一步一步写下来,还是出错。

    希望在 macOS 上用 sing-box 的 tun 模式的 V 友能分享一个配置, 只需要 tun 段即可。

    12 条回复    2025-09-25 11:06:34 +08:00
    wheat0r
        1
    wheat0r  
       23 小时 17 分钟前
    注意这几点:
    1. 在 tun 里启用 sniff ,虽然官方变更看起来 sniff 只要在 route 启用就行,但是我这里个别场景会遇到问题。
    2. route 里配置 dns hijack 或启用 dns 监听,二选一。dns hijack 需要你在终端上配置一个子网以外的 dns 地址,dns 监听需要你在终端上配置 sing-box 主机地址作为 dns 。
    3. auto_route 肯定是要启用的,所以 route.auto_detect_interface 也记得要配置。
    4. sing-box 的配置变更比女人翻脸还快,快跑。
    beginor
        2
    beginor  
    OP
       21 小时 40 分钟前   ❤️ 1
    @wheat0r 感谢回复。 你说的那几个都试过了, 在 macOS 下还是出错, 系统版本是 15.7, sing-box 1.12.8 。

    也尝试过最简单的配置:

    ```json
    {
    "type": "tun",
    "address": ["192.168.0.1/30"],
    "auto_route": true,
    "strict_route": true,
    "stack": "system",
    "sniff": true
    }
    ```

    也尝试过 [强迫症专属 sing-box 配置模板(更新至 1.12 版本)]( https://blog.rewired.moe/post/sing-box-config/) , 还是不行, 错误信息如下:

    ```
    +0800 2025-09-24 19:22:46 ERROR [2536688451 1ms] connection: open connection to 43.137.191.78:80 using outbound/direct[direct]: dial tcp 43.137.191.78:80: connect: network is unreachable
    +0800 2025-09-24 19:22:47 ERROR [438338950 0ms] connection: open connection to 199.16.158.8:443 using outbound/hysteria[proxy]: dial udp 62.210.127.217:35511: connect: network is unreachable
    ```
    silencefly
        3
    silencefly  
       20 小时 51 分钟前
    wheat0r
        4
    wheat0r  
       20 小时 38 分钟前
    @beginor 启动之后 tun 网卡出来了吗?有地址吗?
    iwfd965
        5
    iwfd965  
       20 小时 32 分钟前
    "inbounds": [
    {
    "type": "mixed",
    "listen": "127.0.0.1",
    "listen_port": 1080
    },
    {
    "type": "tun",
    "tag": "tun-in",
    "address": ["172.19.0.1/30"],
    "route_exclude_address": [
    "127.0.0.0/8",
    "192.168.0.0/16",
    "10.0.0.0/8",
    "172.16.0.0/12",
    "100.64.0.0/10",
    "169.254.0.0/16",
    "224.0.0.0/4",
    "255.255.255.255/32",
    "fc00::/7",
    "fe80::/10",
    "ff00::/8"
    ],
    "auto_route": true,
    "strict_route": true,
    "stack": "mixed",
    "platform": {
    "http_proxy": {
    "enabled": true,
    "server": "127.0.0.1",
    "server_port": 1080,
    "bypass_domain": [
    "127.0.0.0/8",
    "192.168.0.0/16",
    "10.0.0.0/8",
    "172.16.0.0/12",
    "100.64.0.0/10",
    "169.254.0.0/16",
    "224.0.0.0/4",
    "255.255.255.255/32",
    "fc00::/7",
    "fe80::/10",
    "ff00::/8"
    ]
    }
    }
    }
    ],
    beginor
        6
    beginor  
    OP
       17 小时 59 分钟前
    @wheat0r 没看到 tun 网卡, 应该还是哪里是配置不正确
    beginor
        7
    beginor  
    OP
       17 小时 59 分钟前
    @iwfd965 感谢回复,贴进去了, 还是一样的错误
    beginor
        8
    beginor  
    OP
       17 小时 58 分钟前
    @silencefly 感谢回复,明天照着这个再试一下
    wheat0r
        9
    wheat0r  
       17 小时 55 分钟前
    @beginor #6 权限不够吧
    iwfd965
        10
    iwfd965  
       17 小时 55 分钟前 via iPhone
    @beginor 可以检查一下其他模块配置,我目前自用正常
    SenLief
        11
    SenLief  
       17 小时 39 分钟前
    不建议用 sing-box ,它的配置文件一直还在变动,为何不用稳定的 mihomo 呢?
    beginor
        12
    beginor  
    OP
       6 小时 5 分钟前
    @wheat0r sudo 运行的, 应该不是权限问题。

    @iwfd965 好的, 谢谢, 我再查一下。

    @SenLief 已经在用了,就别劝退了
    关于   ·   帮助文档   ·   自助推广系统   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   5086 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 23ms · UTC 09:12 · PVG 17:12 · LAX 02:12 · JFK 05:12
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.