V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX  ›  bigwin  ›  全部回复第 1 页 / 共 1 页
回复总数  7
9 天前
回复了 sherlock2435 创建的主题 程序员 sing-box mixed 模式下的 DNS 解析问题
按文档示例配置,不会劫持 dns 吗?
```
{
"inbounds": [
{
"type": "mixed",
"tag": "in"
}
],
"route": {
"rules": [
{
"inbound": "in",
"action": "resolve",
"strategy": "prefer_ipv4"
},
{
"inbound": "in",
"action": "sniff",
"timeout": "1s"
}
]
}
}
```
在 sniff 后面加上
```
{
"protocol": "dns",
"action": "hijack-dns"
},
```
@Bronya 好的,感谢
@bigwin 算了,发不出来就不发了
@bigwin 怪了,图片发不出来,再试一下
https://i.111666.best/image/kUBKVphJEm70yad4Gg5Tp0.jpg
@bigwin 补充日志截图 https://i.mji.rip/2025/08/18/ebb29cf583de05723fa5548c2cb897ab.jpeg
关于为什么,sing-box 很多流行的“配置模板”中未在 route.rules 中添加 action:resolve ,不添加这个字段可以等价为在 mihomo 的所有 ip 规则后添加 no-resolve ,此时对于域名匹配来说,你的 ip 规则都是无效的)。
我刚才看了一下日志,不添加 action:resolve ,是因为 tun 入站可以直接匹配基于 ip 的规则,所以不需要 action:resolve 。只有 mixed 入站,才需要 action:resolve 。目前市面上流行的大多数 sing-box 配置模板,都是基于 tun 入站的,自然也就不需要 action:resolve 。
附上日志截图:![image]( https://i.111666.best/image/dfBV7hflnMqz95oHIXwEKU.jpg)
补充一点,如果想分流精准,可以在 dns 部分开启"reverse_mapping": true ,用于在路由时,通过 ip 反查域名,这个目前确实没有在主流的配置模板中见到。根据官方文档来看,macos 不支持这个字段,其它系统都可以尝试开启
关于   ·   帮助文档   ·   自助推广系统   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   5862 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 27ms · UTC 03:01 · PVG 11:01 · LAX 20:01 · JFK 23:01
Developed with CodeLauncher
♥ Do have faith in what you're doing.