mihomo 内核极简防 DNS 泄漏配置(2025 年)2.0 版

经过上个帖子的讨论,对初始版本进行了优化,这次给出完整的dns配置,可直接用于覆写。

版本 1(适用于最新版 mihomo 内核)

dns:
  enable: true
  ipv6: true      #如网络环境不支持IPv6请设为false
  enhanced-mode: fake-ip
  fake-ip-range: 198.18.0.1/16
  fake-ip-filter:     #使用geosite域名集合以精简配置,也可使用规则集(ruleset)
    - geosite:private
    - geosite:category-ntp
  use-hosts: false     #如有特殊需求请设为true
  use-system-hosts: false     #如有特殊需求请设为true
  nameserver:
    - https://1.1.1.1/dns-query
    - https://8.8.8.8/dns-query
  proxy-server-nameserver:
    - https://223.5.5.5/dns-query
    - https://223.6.6.6/dns-query
  direct-nameserver:
    - https://223.5.5.5/dns-query
    - https://223.6.6.6/dns-query
  respect-rules: true

版本 2(不使用direct-nameserver,改用nameserver-policy

dns:
  enable: true
  ipv6: true
  enhanced-mode: fake-ip
  fake-ip-range: 198.18.0.1/16
  fake-ip-filter:
    - geosite:private
    - geosite:category-ntp
  use-hosts: false
  use-system-hosts: false
  nameserver:
    - https://1.1.1.1/dns-query
    - https://8.8.8.8/dns-query
  proxy-server-nameserver:
    - https://223.5.5.5/dns-query
    - https://223.6.6.6/dns-query
  nameserver-policy:
    #还可增加其他条目,让特定网址走特定DNS解析
    geosite:cn:     #也可使用规则集(ruleset)
      - https://223.5.5.5/dns-query
      - https://223.6.6.6/dns-query
  respect-rules: true

版本 3(综合前面两个版本的完全体,一般人用不到)

dns:
  enable: true
  ipv6: true
  enhanced-mode: fake-ip
  fake-ip-range: 198.18.0.1/16
  fake-ip-filter:
    - geosite:private
    - geosite:category-ntp
  use-hosts: false
  use-system-hosts: false
  nameserver:
    - https://1.1.1.1/dns-query
    - https://8.8.8.8/dns-query
  proxy-server-nameserver:
    - https://223.5.5.5/dns-query
    - https://223.6.6.6/dns-query
  nameserver-policy:
    geosite:cn:
      - https://223.5.5.5/dns-query
      - https://223.6.6.6/dns-query
  respect-rules: true
  direct-nameserver:
    - https://223.5.5.5/dns-query
    - https://223.6.6.6/dns-query
  direct-nameserver-follow-policy: true    #优先让nameserver-policy的设定生效
154 个赞

佬,手机端的clash meta能用吗 :face_blowing_a_kiss:

1 个赞

同问大佬~

这个版本使用的库还是会把DNS Leak Test - BrowserLeaks 设置在直连里么

2 个赞

这是rules分流规则决定的

Clash Meta for Android 使用的是 mihomo 内核,答案是可以。

@grvdd

2 个赞

两个版本有什么区别吗

佬,fake-ip是不是必须TUN也开启才能用?

[quote=“EndlessEnding, post:1, topic:1212835”]

  respect-rules: true

[/quote] ```
respect-rules: true

执行 DNS 解析的路径略微不同,使用direct-nameserver无法满足有的人的特殊需求。

1 个赞

谢谢大佬分享

1 个赞

太强啦 谢谢大佬

对,在不开启 Tun(虚拟网卡)的情况下,DNS 解析没有被劫持到 mihomo 内核,就是普通模式。

感谢分享。

1 个赞

感谢佬的分享

1 个赞

感谢大佬

1 个赞

感谢分享。

不愿意用fake-ip模式

默认 redir-host 模式会更加广泛,fakeip 某些情况还是有些问题

是的,更喜欢 redir-host 一点,这样 ping 的时候,能看到真实的 ip