想请问一下大家 Clash 是如何进行域名和 IP 规则匹配的 - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
340746

想请问一下大家 Clash 是如何进行域名和 IP 规则匹配的

  •  
  •   340746 Mar 2 1050 views
    This topic created in 59 days ago, the information mentioned may be changed or developed.

    我的 DNS 配置如下

     dns: enable: true #是否启用,如为 false ,则使用系统 DNS 解析 cache-algorithm: lru #支持的算法:lru: Least Recently Used, 默认值 arc: Adaptive Replacement Cache prefer-h3: true #DOH 优先使用 http/3 listen: 0.0.0.0:1053 #DNS 服务监听,支持 udp, tcp ipv6: true #是否解析 IPV6, 如为 false, 则回应 AAAA 的空解析 enhanced-mode: fake-ip #mihomo 的 DNS 处理模式 fake-ip-range: 198.18.0.1/16 #fakeip 下的 IP 段设置,tun 的默认 IPV4 地址 也使用此值作为参考 fake-ip-filter: #fakeip 过滤,以下地址不会下发 fakeip 映射用于连接 - 'geosite:private' fake-ip-filter-mode: blacklist #可选 blacklist/whitelist ,默认 blacklist ,whitelist 即只有匹配成功才返回 fake-ip use-hosts: false #是否回应配置中的 hosts ,默认 true use-system-hosts: true #是否查询系统 hosts ,默认 true respect-rules: true #dns 连接遵守路由规则,需配置 proxy-server-nameserver default-nameserver: #默认 DNS, 用于解析 DNS 服务器 的域名,必须为 IP, 可为加密 DNS - tls://1.12.12.12:853 - tls://223.5.5.5:853 nameserver-policy: "geosite:private,cn,geolocation-cn": system "geoip:cn": system proxy-server-nameserver: #代理节点域名解析服务器,仅用于解析代理节点的域名,如果不填则遵循 nameserver-policy 、nameserver 和 fallback 的配置 - https://dns.alidns.com/dns-query - https://dns.pub/dns-query direct-nameserver: #用于 direct 出口域名解析的 DNS 服务器,如果不填则遵循 nameserver-policy 、nameserver 和 fallback 的配置 - system direct-nameserver-follow-policy: false #是否遵循 nameserver-policy ,默认为不遵守,仅当 direct-nameserver 不为空时生效 nameserver: #默认的域名解析服务器 - https://dns.cloudflare.com/dns-query - https://dns.google/dns-query 

    我打算让国内的网站直接走系统 DNS,其他网站走国外 DNS
    规则部分的配置如下:

    rules: - IP-CIDR,0.0.0.0/32,REJECT - DOMAIN-REGEX,^ad\..*,REJECT - DOMAIN-REGEX,.*\.ad\..*,REJECT - GEOSITE,category-ads-all,REJECT - DOMAIN-KEYWORD,teracloud,DIRECT - GEOSITE,geolocation-cn,DIRECT - GEOSITE,private,DIRECT - GEOIP,cn,DIRECT - GEOSITE,CATEGORY-AI-!CN,人工智能 - GEOSITE,DLSITE,日本网站 - DOMAIN-SUFFIX,jp,日本网站 - GEOSITE,category-cryptocurrency,加密货币 - GEOSITE,youtube,国外媒体 - MATCH,自动选择 

    但是在使用 Clash 时能观察到 udp://8.8.4.4:443 走 DIRECT
    查了一下日志:

    Log(logLevel: LogLevel.info, payload: [TCP] mihomo --> dns.google:443 match Match using 自动选择[中国 - 台湾 - Pittqiao Network Information Co., Ltd. - 148], dateTime: 2026-03-02 17:13:37) Log(logLevel: LogLevel.debug, payload: probing TLS: opening TLS connection: tls: either ServerName or InsecureSkipVerify must be specified in the tls.Config, dateTime: 2026-03-02 17:13:37) Log(logLevel: LogLevel.debug, payload: [https://dns.google:443/dns-query] using HTTP/3 for this upstream: QUIC was faster, dateTime: 2026-03-02 17:13:37) Log(logLevel: LogLevel.debug, payload: [Rule] use default rules, dateTime: 2026-03-02 17:13:37) Log(logLevel: LogLevel.debug, payload: 自动选择 UDP is not supported, dateTime: 2026-03-02 17:13:37) Log(logLevel: LogLevel.info, payload: [UDP] mihomo --> 8.8.4.4:443 doesn't match any rule using DIRECT, dateTime: 2026-03-02 17:13:37) 

    想问一下大家为什么日志前面说 Google 的 dn 走 Match 了,后面的 IP 又走直连
    Clash 匹配域名和 IP 是什么顺序,什么情况下直接匹配域名,什么情况下解析出 IP 再进行匹配
    我配置的 Googledns 是 DOH 加密,那现在 udp://8.8.4.4:443 走直连是否还能起到加密的作用

    340746
        1
    340746  
    OP
       Mar 2
    似乎解决了
    问题形成:
    设置 prefer-h3: true 导致 doh 请求走 quic 协议,quic 协议用的 udp,某些代理没有声明支持 udp 导致只能走直连
    解决方法:
    在覆写里修改 prefer-h3: false 或者为每个代理添加 udp 支持
    About     Help     Advertise     Blog     API     FAQ     Solana     965 Online   Highest 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 23ms UTC 23:13 PVG 07:13 LAX 16:13 JFK 19:13
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86