libnyanpasu / clash-nyanpasu

Clash Nyanpasu~(∠・ω< )⌒☆​
https://nyanpasu.elaina.moe
GNU General Public License v3.0
9.18k stars 582 forks source link

BUG-仅开启“TUN模式”时 存在DNS泄露,但开了系统代理则不会 #1440

Closed toyo2333 closed 1 month ago

toyo2333 commented 2 months ago

复现步骤 / Step to reproduce

1、win11,管理员权限运行程序,然后打开“TUN模式”(但不勾选“系统代理”); 2、完成后,开启全局代理模式,浏览器打开 https://ipleak.net/https://browserleaks.com/dns 这两个测试站点 3、完成测试后,观察2个不同测试工具的测试结果

预期行为 / Expected behaviour

测试结果里不应该出现 本地运营商的 DNS 服务器IP (即不出现DNS泄露)---应该全部仅是远端服务器的出口IP的 DNS 服务器

实际行为 / Actual Behaviour

出现了本地运营商的 DNS 服务器 IP (意味着 DNS 泄露)。

作为对比:如果关闭“ TUN 模式”,打开 “系统代理” ,测试结果正常 则不会出现本地 本地运营商的 DNS 服务器 IP(DNS 泄露),如果 同时打开 “ TUN 模式” 和 “系统代理” 也没问题。问题值出现在 仅开启 “ TUN 模式” 时候

应用日志 / App logs

没有找到日志,但可以必然复现,以下是配置文件里 DNS 和 TUN 的配置:

tun:
  enable: true
  stack: mixed
  dns-hijack:
    - "any:53"
    - "tcp://any:53"
  auto-route: true
  auto-redirect: true
  auto-detect-interface: true

dns:
  enable: true
  prefer-h3: true
  ipv6: true
  enhanced-mode: fake-ip
  fake-ip-filter:
    - "*"
    - "+.lan"
    - "+.local"
  nameserver:
    - https://1.12.12.12/dns-query
    - https://223.5.5.5/dns-query
  nameserver-policy:
    "geosite:cn,private":
      - https://1.12.12.12/dns-query
      - https://223.5.5.5/dns-query

备注 / Addition details

No response

环境信息 / Environment information

clash 内核 是 meta v1.18.7 meta clash客户端是:Clash Nyanpasu 1.5.1 系统 win11 最新版

自查步骤 / Verify steps

greenhat616 commented 2 months ago

您确保已使用最新 Pre-release 版本测试,并且该问题在最新 Pre-release 版本中并未解决 / This bug have not solved in latest Pre-release version

请使用最新开发版再次测试。此外,请说明 TUN 模式是否使用了服务模式启动?如果否,尝试以服务模式启动,看看能否正确工作。

toyo2333 commented 2 months ago

您确保已使用最新 Pre-release 版本测试,并且该问题在最新 Pre-release 版本中并未解决 / This bug have not solved in latest Pre-release version

请使用最新开发版再次测试。此外,请说明 TUN 模式是否使用了服务模式启动?如果否,尝试以服务模式启动,看看能否正确工作。

我刚刚测试了最新的:Clash.Nyanpasu_1.5.2-alpha+020e1e3_x64_portable,问题存在。

然后我尝试安装了服务,并打开了服务模式,问题依然存在。

toyo2333 commented 2 months ago

您确保已使用最新 Pre-release 版本测试,并且该问题在最新 Pre-release 版本中并未解决 / This bug have not solved in latest Pre-release version

请使用最新开发版再次测试。此外,请说明 TUN 模式是否使用了服务模式启动?如果否,尝试以服务模式启动,看看能否正确工作。

另外 我在新版本Clash.Nyanpasu_1.5.2-alpha+020e1e3_x64_portable 发现2个新问题:

第一个是: 我有一个节点是 使用 IPv6 链接的 Hysteria 2 节点,timeout了。但我换回1.5.1 则一切正常。 第二个是:比较明显的主观感受,就是APP启动 UI刷新,还有网页打开的速度变慢了(就开上面2个测试工具网站都慢),我已换回旧版本了,一切正常。

还是回到这个issue本身的 DNS泄露问题吧。我现在只能开着系统代理用tun模式,我不知道是不是应该正确正常操作,因为我看别的一些关于tun的教程 是 关掉 系统代理情况下用的。

我不清楚 这两种情况有什么区别,但目前来看,不符合我的预期,我不希望出现 DNS 泄露 尤其是开了全局模式代理模式的情况下。

greenhat616 commented 2 months ago

第一个是: 我有一个节点是 使用 IPv6 链接的 Hysteria 2 节点,timeout了。但我换回1.5.1 则一切正常。 第二个是:比较明显的主观感受,就是APP启动 UI刷新,还有网页打开的速度变慢了(就开上面2个测试工具网站都慢),我已换回旧版本了,一切正常。

这些和 mihomo(Clash Meta) 或其他 Clash 内核有关系,GUI 不负责具体的流量问题。

还是回到这个issue本身的 DNS泄露问题吧。我现在只能开着系统代理用tun模式,我不知道是不是应该正确正常操作,因为我看别的一些关于tun的教程 是 关掉 系统代理情况下用的。

这样可以确认 TUN 没受到权限问题影响,且没有劫持 DNS 成功。系统代理的作用是设置操作系统的代理服务器,可能这将 DNS 流量也发送过去了。

你可以参考一下这个问题,看看是否能解决:https://github.com/MetaCubeX/mihomo/issues/470#issue-1641270251

greenhat616 commented 2 months ago

如果需要 GUI 自动接管 DNS 设置的话,请关注这个问题:https://github.com/LibNyanpasu/nyanpasu-service/issues/26 。 之后会顺带支持其他的操作系统,但由于权限问题,仅限服务模式可用。

toyo2333 commented 2 months ago

第一个是: 我有一个节点是 使用 IPv6 链接的 Hysteria 2 节点,timeout了。但我换回1.5.1 则一切正常。 第二个是:比较明显的主观感受,就是APP启动 UI刷新,还有网页打开的速度变慢了(就开上面2个测试工具网站都慢),我已换回旧版本了,一切正常。

这些和 mihomo(Clash Meta) 或其他 Clash 内核有关系,GUI 不负责具体的流量问题。

还是回到这个issue本身的 DNS泄露问题吧。我现在只能开着系统代理用tun模式,我不知道是不是应该正确正常操作,因为我看别的一些关于tun的教程 是 关掉 系统代理情况下用的。

这样可以确认 TUN 没受到权限问题影响,且没有劫持 DNS 成功。系统代理的作用是设置操作系统的代理服务器,可能这将 DNS 流量也发送过去了。

你可以参考一下这个问题,看看是否能解决:MetaCubeX/mihomo#470 (comment)

我按文档和issue回答者的 建议,加上了 strict-route: true (https://wiki.metacubex.one/config/inbound/tun/#strict-route

但问题依旧存在。

toyo2333 commented 2 months ago

第一个是: 我有一个节点是 使用 IPv6 链接的 Hysteria 2 节点,timeout了。但我换回1.5.1 则一切正常。

第一个是: 我有一个节点是 使用 IPv6 链接的 Hysteria 2 节点,timeout了。但我换回1.5.1 则一切正常。 第二个是:比较明显的主观感受,就是APP启动 UI刷新,还有网页打开的速度变慢了(就开上面2个测试工具网站都慢),我已换回旧版本了,一切正常。

这些和 mihomo(Clash Meta) 或其他 Clash 内核有关系,GUI 不负责具体的流量问题。

还是回到这个issue本身的 DNS泄露问题吧。我现在只能开着系统代理用tun模式,我不知道是不是应该正确正常操作,因为我看别的一些关于tun的教程 是 关掉 系统代理情况下用的。

这样可以确认 TUN 没受到权限问题影响,且没有劫持 DNS 成功。系统代理的作用是设置操作系统的代理服务器,可能这将 DNS 流量也发送过去了。

你可以参考一下这个问题,看看是否能解决:MetaCubeX/mihomo#470 (comment)

第一个是: 我有一个节点是 使用 IPv6 链接的 Hysteria 2 节点,timeout了。但我换回1.5.1 则一切正常。 ---这个问题 不是内核问题。因为 我用的都是 meta v1.18.7 meta ,但nyanpasu旧版本1.5.1正常,而最新nyanpasu1.5.2开发预览 版 同一个配置的节点 就timeout了

greenhat616 commented 2 months ago

第一个问题你要证否,请拿出 nyanpasu 1.6.0 开发版生成的运行时配置和 1.5.1 生成的运行时配置的差异出来说明,才好判断。 再重复一次,不管是测速还是通过代理访问任何站点,走的都是内核自己的接口。 Ref: https://wiki.metacubex.one/api/#proxiesproxies_namedelay

我按文档和issue回答者的 建议,加上了 strict-route: true (https://wiki.metacubex.one/config/inbound/tun/#strict-route)

但问题依旧存在。

确认运行时配置正确加入了么?是的话,试一下手动修改操作系统 DNS 看看,

toyo2333 commented 2 months ago

第一个问题你要证否,请拿出 nyanpasu 1.6.0 开发版生成的运行时配置和 1.5.1 生成的运行时配置的差异出来说明,才好判断。 再重复一次,不管是测速还是通过代理访问任何站点,走的都是内核自己的接口。 ----- 再次检查确认,是开发板GUI里的ipv6开关没开,开了就正常了。我的。

确认运行时配置正确加入了么?是的话,试一下手动修改操作系统 DNS 看看, -----加入了,不太想去修改操作系统的配置。不折腾了。改回系统代理继续用了。另外,我没有mac,我也不太确定这个问题mac上是否出现。暂时先这样把。

toyo2333 commented 1 month ago

破案了。更新一下,我使用内核直接运行,不会泄露DNS 用 clash-nyanpasu 1.6.0 跑,仅开TUN 就会泄露 ,除了用上面的网站验证外,还可以打开 https://ip-api.com/ ,结果显示ip是节点的ip,但最下面那个DNS 就是本地运营商的。

再贴一下配置,这个配置

mixed-port: 7890
ipv6: true
allow-lan: true
unified-delay: false
tcp-concurrent: true
external-controller: 127.0.0.1:9090
external-ui: ui
external-ui-url: "https://github.com/MetaCubeX/metacubexd/archive/refs/heads/gh-pages.zip"

geodata-mode: true
geox-url:
  geoip: "https://mirror.ghproxy.com/https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest/geoip-lite.dat"
  geosite: "https://mirror.ghproxy.com/https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest/geosite.dat"
  mmdb: "https://mirror.ghproxy.com/https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest/country-lite.mmdb"
  asn: "https://mirror.ghproxy.com/https://github.com/xishang0128/geoip/releases/download/latest/GeoLite2-ASN.mmdb"

find-process-mode: strict
global-client-fingerprint: chrome

profile:
  store-selected: true
  store-fake-ip: true

sniffer:
  enable: true
  sniff:
    HTTP:
      ports: [80, 8080-8880]
      override-destination: true
    TLS:
      ports: [443, 8443]
    QUIC:
      ports: [443, 8443]
  skip-domain:
    - "Mijia Cloud"
    - "+.push.apple.com"

tun:
  enable: true
  stack: mixed
  dns-hijack:
    - "any:53"
    - "tcp://any:53"
  auto-route: true
  auto-redirect: true
  auto-detect-interface: true
  strict-route: true

dns:
  enable: true
  prefer-h3: true
  ipv6: true
  enhanced-mode: fake-ip
  fake-ip-filter:
    - "*"
    - "+.lan"
    - "+.local"
  nameserver:
    - https://1.12.12.12/dns-query
    - https://223.5.5.5/dns-query
  proxy-server-nameserver:
    - https://1.12.12.12/dns-query
    - https://223.5.5.5/dns-query
  nameserver-policy:
    "geosite:cn,private":
      - https://1.12.12.12/dns-query
      - https://223.5.5.5/dns-query
    "geosite:geolocation-!cn":
      - https://dns.cloudflare.com/dns-query
      - https://dns.google/dns-query
greenhat616 commented 1 month ago

请提供处理后的运行配置 图片

toyo2333 commented 1 month ago

请提供处理后的运行配置


mode: global
mixed-port: 7890
allow-lan: false
log-level: info
ipv6: true
secret: xxx
external-controller: 127.0.0.1:17650
dns:
proxy-server-nameserver:
- https://1.12.12.12/dns-query
- https://223.5.5.5/dns-query
fake-ip-filter:
- '*'
- +.lan
- +.local
enable: true
ipv6: true
prefer-h3: true
nameserver-policy:
geosite:geolocation-!cn:
- https://dns.cloudflare.com/dns-query
- https://dns.google/dns-query
geosite:cn,private:
- https://1.12.12.12/dns-query
- https://223.5.5.5/dns-query
enhanced-mode: fake-ip
nameserver:
- https://1.12.12.12/dns-query
- https://223.5.5.5/dns-query
fake-ip-range: 198.18.0.1/16
fallback: []
tun:
enable: true
stack: gvisor
dns-hijack:
- any:53
auto-route: true
auto-detect-interface: true
unified-delay: false
tcp-concurrent: true
proxies:
- network: tcp
client-fingerprint: chrome
name: node
xxx
...

proxy-groups:



原配置文件中的:strict-route: true 没有了。其他的我没有一一对比,太多了。
greenhat616 commented 1 month ago

图片 图片

你是不是打开了字段过滤,且没有选中tun

toyo2333 commented 1 month ago

图片 图片

你是不是打开了字段过滤,且没有选中tun

这里没有改过。我去看了下,是开启的

greenhat616 commented 1 month ago

那你这运行配置不可能筛选掉 strict-route 的。

toyo2333 commented 1 month ago

那你这运行配置不可能筛选掉 strict-route 的。

那我就不清楚了。

greenhat616 commented 1 month ago

图片

另,完全关闭那个功能也能杜绝 GUI 删除配置。

toyo2333 commented 1 month ago

破案了。更新一下,我使用内核直接运行,不会泄露DNS

用 clash-nyanpasu 1.6.0 跑,仅开TUN 就会泄露 ,除了用上面的网站验证外,还可以打开 https://ip-api.com/ ,结果显示ip是节点的ip,但最下面那个DNS 就是本地运营商的。

再贴一下配置,这个配置


mixed-port: 7890

ipv6: true

allow-lan: true

unified-delay: false

tcp-concurrent: true

external-controller: 127.0.0.1:9090

external-ui: ui

external-ui-url: "https://github.com/MetaCubeX/metacubexd/archive/refs/heads/gh-pages.zip"

geodata-mode: true

geox-url:

  geoip: "https://mirror.ghproxy.com/https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest/geoip-lite.dat"

  geosite: "https://mirror.ghproxy.com/https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest/geosite.dat"

  mmdb: "https://mirror.ghproxy.com/https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest/country-lite.mmdb"

  asn: "https://mirror.ghproxy.com/https://github.com/xishang0128/geoip/releases/download/latest/GeoLite2-ASN.mmdb"

find-process-mode: strict

global-client-fingerprint: chrome

profile:

  store-selected: true

  store-fake-ip: true

sniffer:

  enable: true

  sniff:

    HTTP:

      ports: [80, 8080-8880]

      override-destination: true

    TLS:

      ports: [443, 8443]

    QUIC:

      ports: [443, 8443]

  skip-domain:

    - "Mijia Cloud"

    - "+.push.apple.com"

tun:

  enable: true

  stack: mixed

  dns-hijack:

    - "any:53"

    - "tcp://any:53"

  auto-route: true

  auto-redirect: true

  auto-detect-interface: true

  strict-route: true

dns:

  enable: true

  prefer-h3: true

  ipv6: true

  enhanced-mode: fake-ip

  fake-ip-filter:

    - "*"

    - "+.lan"

    - "+.local"

  nameserver:

    - https://1.12.12.12/dns-query

    - https://223.5.5.5/dns-query

  proxy-server-nameserver:

    - https://1.12.12.12/dns-query

    - https://223.5.5.5/dns-query

  nameserver-policy:

    "geosite:cn,private":

      - https://1.12.12.12/dns-query

      - https://223.5.5.5/dns-query

    "geosite:geolocation-!cn":

      - https://dns.cloudflare.com/dns-query

      - https://dns.google/dns-query

这个就是我的配置。同一份配置。内核OK。 GUI不行。 谢谢你们跟进。我还是用内核吧。 新版本在我这也存在一些bug 和性能问题。

toyo2333 commented 1 month ago

图片

另,完全关闭那个功能也能杜绝 GUI 删除配置。

我完全关闭了那个开关。可以了。那个开关“开启Clash字段过滤“ 作用到底是什么?是允许GUI修改运行配置?