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

1 天前
 beginor

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

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

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

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

749 次点击
所在节点    问与答
13 条回复
wheat0r
1 天前
注意这几点:
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
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
1 天前
wheat0r
1 天前
@beginor 启动之后 tun 网卡出来了吗?有地址吗?
iwfd965
1 天前
"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
1 天前
@wheat0r 没看到 tun 网卡, 应该还是哪里是配置不正确
beginor
1 天前
@iwfd965 感谢回复,贴进去了, 还是一样的错误
beginor
1 天前
@silencefly 感谢回复,明天照着这个再试一下
wheat0r
1 天前
@beginor #6 权限不够吧
iwfd965
1 天前
@beginor 可以检查一下其他模块配置,我目前自用正常
SenLief
1 天前
不建议用 sing-box ,它的配置文件一直还在变动,为何不用稳定的 mihomo 呢?
beginor
1 天前
@wheat0r sudo 运行的, 应该不是权限问题。

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

@SenLief 已经在用了,就别劝退了
beginor
3 小时 20 分钟前
统一回复,感谢各位 V 友的热心回复, 最终在这里抄了一份配置出来

https://github.com/OneOhCloud/OneBox/blob/main/src/config/version_1_12/tun-config.ts

PS: 以 tun 模式启动之后, 在 macOS 上是看不到 vpn 或者或者网卡, 但是全部应用(包括不支持代理的命令行)都可以走代理!

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/1161589

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX