tun模式存在dns泄漏
完整性要求
- [x] 我读完了 issue 模板中的所有注释,确保填写符合要求。
- [x] 我保证阅读了文档,了解所有我编写的配置文件项的含义,而不是大量堆砌看似有用的选项或默认值。
- [x] 我提供了完整的配置文件和日志,而不是出于自己的判断只给出截取的部分。
- [x] 我搜索了 issues, 没有发现已提出的类似问题。
- [x] 问题在 Release 最新的版本上可以成功复现
描述
开启tun模式会出现dns泄漏的问题
重现方式
把v2rayN的config.json 文件复制到xray目录下面 用 .\xray.exe -c config.json 然后访问各种检测dns泄漏网站会出现dns泄漏的问题
客户端配置
{ "log": { "loglevel": "debug", "dnsLog": true }, "dns": { "servers": [ { "address": "223.5.5.5", "domains": [ "geosite:cn", "geosite:private" ], "skipFallback": true }, { "address": "8.8.8.8" } ], "queryStrategy": "UseIPv4", "disableCache": false }, "inbounds": [ { "tag": "tun-in", "protocol": "tun", "settings": { "name": "xray0", "mtu": 1500, "gateway": [ "10.0.0.1/16", "fc00::1/64" ], "dns": [ "1.1.1.1", "8.8.8.8" ], "userLevel": 0, "autoSystemRoutingTable": [ "0.0.0.0/0", "::/0" ], "autoOutboundsInterface": "auto" }, "sniffing": { "enabled": true, "destOverride": [ "http", "tls", "quic" ] } }, { "tag": "mixed-in", "protocol": "socks", "listen": "127.0.0.1", "port": 16890, "settings": { "auth": "noauth", "udp": true } } ], "outbounds": [ { "tag": "proxy", "protocol": "shadowsocks", "settings": { "servers": [ { "address": "", "port": , "method": "2022-blake3-aes-128-gcm", "password": "" } ] }, "streamSettings": { "network": "tcp" } }, { "tag": "direct", "protocol": "freedom", "settings": {} }, { "tag": "block", "protocol": "blackhole", "settings": {} }, { "tag": "dns-out", "protocol": "dns" } ], "routing": { "domainStrategy": "AsIs", "rules": [ { "type": "field", "inboundTag": [ "tun-in" ], "port": "53", "outboundTag": "dns-out" }, { "type": "field", "outboundTag": "direct", "process": [ "self/", "xray/" ] }, { "type": "field", "outboundTag": "block", "network": "udp", "port": "443" }, { "type": "field", "outboundTag": "proxy", "domain": [ "geosite:google" ] }, { "type": "field", "outboundTag": "direct", "domain": [ "geosite:cn", "geosite:private" ] }, { "type": "field", "outboundTag": "direct", "ip": [ "geoip:cn", "geoip:private" ] }, { "type": "field", "outboundTag": "proxy", "network": "tcp,udp" } ] } }
服务端配置
由于是机场无法提供
客户端日志
新建 文本文档.txt 太大超过65536个字符
服务端日志
机场节点无法提供
请自行关闭Windows的智能多宿主解析
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows NT\DNSClient]
"DisableSmartNameResolution"=dword:00000001
使用 Windows TUN 时有管理员权限,要不自动把“智能多宿主解析”给关了吧,@LjhAUMEM @yiguodev
缓解无效 @Meo597
补充一下,我也试了同时禁用LLMNR 和关闭智能多宿主解析也没用
目前可以确定的是裸核模式下这个问题很难解决,还是建议放弃吧。
- 目前已测试并验证 macOS 下无法解决。
- 根据上面的反馈来看,Windows 下同样无法解决。
- Linux 可通过 D-Bus 接管系统 DNS,未验证。
- 参考了其他社区(~~mihomo~~)的实现,无有效手段。
难道不是你分流的原因吗? 你把 CN 的规则去掉,让所有流量都走 proxy 再测一次试试。
难道不是你分流的原因吗? 你把 CN 的规则去掉,让所有流量都走 proxy 再测一次试试。
跟分流没多大关系…… 改成全局还是会漏
难道不是你分流的原因吗? 你把 CN 的规则去掉,让所有流量都走 proxy 再测一次试试。
跟分流没多大关系…… 改成全局还是会漏
我关掉 Chrome 的代理插件,用 ProxyCap 拦截 Chrome 流量,导入到 XRay 的 Socks5 Inbound。 测试了一下,没发现泄露。 可能 Tun 在 Win 下天生就水土不服吧。(当然了,这是 Microslop 的问题)
你换 ProxyCap 吧。
缓解无效 @Meo597
可能跟 TUN 无关是你自己没配置好导致的,那个 REG 生效了意味着查询不会多发一份走 TUN 网卡出去 错误的配置该漏还是会漏
log里xray本身的dns系统没有往外发任何直连请求 肯定是系统还是什么地方的请求从TUN漏出去的
关了多宿主解析配好 xray 理论上防的住 是不是 https 查询漏的,他 dns 出站没改写到国外
总之先让 xray 不分流再看看吧
使用 Windows TUN 时有管理员权限,要不自动把“智能多宿主解析”给关了吧
不建议这么操作,修改注册表可能被识别为病毒,而且如果本地有 ipv6 似乎也不会遵循这个设置
关了多宿主解析配好 xray 理论上防的住 是不是 https 查询漏的,他 dns 出站没改写到国外
总之先让 xray 不分流再看看吧
{ "log": { "loglevel": "debug", "dnsLog": true }, "dns": { "servers": [ { "address": "8.8.8.8", "domains": [ "geosite:cn", "geosite:private" ], "skipFallback": true }, { "address": "8.8.8.8" } ], "queryStrategy": "UseIP", "disableCache": false }, "inbounds": [ { "tag": "tun-in", "protocol": "tun", "settings": { "name": "xray-tun", "mtu": 1500, "gateway": [ "172.18.0.1/30", "fdfe:dcba:9876::1/64" ], "autoSystemRoutingTable": [ "0.0.0.0/0", "::/0" ], "autoOutboundsInterface": "auto", "dns": [ "172.18.0.2", "fdfe:dcba:9876::2" ] }, "sniffing": { "enabled": true, "destOverride": [ "http", "tls", "quic" ] } } ], "outbounds": [ { "tag": "proxy", "protocol": "shadowsocks", "settings": { "servers": [ { "address": "", "port": , "method": "2022-blake3-aes-128-gcm", "password": "" } ] }, "streamSettings": { "network": "tcp" } }, { "tag": "direct", "protocol": "freedom", "settings": {} }, { "tag": "block", "protocol": "blackhole", "settings": {} }, { "tag": "dns-out", "protocol": "dns" } ], "routing": { "domainStrategy": "AsIs", "rules": [ { "type": "field", "inboundTag": [ "tun-in" ], "port": "53", "outboundTag": "dns-out" }, { "type": "field", "outboundTag": "direct", "process": [ "self/", "xray/" ] }, { "type": "field", "outboundTag": "block", "network": "udp", "port": "443" }, { "type": "field", "outboundTag": "proxy", "network": "tcp,udp" } ] } }
建议抓包
建议抓包
我之前用的是直接连 tun 时添加 namespace "." → nameservers 172.18.0.1 的 NRPT 规则,让 DNS 客户端对所有域名只允许用 tun DNS。 这样差不多基本能连上tun的dns泄漏都没了,但是这个问题就是会造成很多节点tun模式用不了,很多什么机场的正常Trojans hy2节点不开tun可以访问 但是开了什么网页都打不开
这个问题本质是裸核模式下,系统并不会将所有 DNS 流量都托管给 Tun Device ,与分流规则关系不大。目前在 macOS 和 Windows 上,无法通过常规手段“强行”接管系统 DNS 。 目前实测 macOS NE 模式下,已知的 DNS Leak 检测网站都不会检出泄漏。
脏方法:看看设置出口网卡的dns为127.0.0.1。
powershell -command "Get-NetAdapter | Get-DnsClientServerAddress"
@yiguodev 或许修改系统 DNS 为 TUN 的 gateway(直接发给 Xray)可以解决问题?
macOS 上已经尝试了 System Configuration 的方案,不行。