I currently observed with ClashX that if a website both resolves in IPv4 and IPv6, the IPv4 address will have a precedence over the IPv6 one. But in some environments, only IPv6 address is reachable, and access from IPv4 is forbidden, so providing an option for IPv6 precedence is reasonable. Would you please offer this feature?
My routing config is as follows:
Rule:
- DOMAIN-SUFFIX,npupt.com,DIRECT
- IP-CIDR,2606:4700:30::6818:7212/80,DIRECT
# LAN
- DOMAIN-SUFFIX,local,DIRECT
- IP-CIDR,127.0.0.0/8,DIRECT
- IP-CIDR,172.16.0.0/12,DIRECT
- IP-CIDR,192.168.0.0/16,DIRECT
- IP-CIDR,10.0.0.0/8,DIRECT
- IP-CIDR,17.0.0.0/8,DIRECT
- IP-CIDR,100.64.0.0/10,DIRECT
# Final
- GEOIP,CN,DIRECT
- MATCH,Proxy
And as I see, npupt.com is connected over IPv4 instead of IPv6. I am in a network with dual-stack address and DNS, and npupt.com resolves to both A record and AAAA record.
Keywords IPv6, IPv6 precedence, IPv6 优先
only IPv6 address is reachable, and access from IPv4 is forbidden
What do you mean forbidden?
If forbidden means TCP connection can't be established. I think clash has already solved this problem.
If you mean some host reply HTTP 403 on IPv4 but reply HTTP 200 on IPv6, I think this is their own issue. Clash should do nothing under this circumstance.
forbidden means the latter one, replies 403 on IPv4. But most OS/browser/proxies provided such feature, either by default or by option, and Clash's behavior is different from existing software.
I think the author currently assumes all connections supports v4/6 dual-stack. However this seems to be a reasonable request, thanks.
我也遇到了同样的问题。
我在Cloudflare上托管了我的域名并且启用了CDN加速,CDN服务器默认部署在海外。
由于一些原因,在近段时间内我的网络无法通过IPV4环境连接到海外的CDN服务器,此时clash能返回正确的ipv4地址下的”i/o timeout“记录。当然,IPV4下结果是连接失败,但此时我是可以通过IPV6线路进行的连接访问的。这个时候无奈只能关闭clash代理,直连上网。
我设想的逻辑是这样的:一旦ipv4线路阻塞(指无法连接返回timeout),触发fallback机制去尝试解析AAAA记录进行IPV6连接,正如楼上所说这可能是一个有益且有意义的功能。
或许,在未来的版本中,可以在配置文件中提供一个开关,设置IPV4/6的优先级,同时配备fallback机制。
最后,谢谢各位辛勤的贡献者,对你们表示感谢~
现在我遇到的问题就是开着clash for windows,ipv6测试就过不了。
这是我dns这块的设置
dns:
enable: true
ipv6: true
listen: :53
enhanced-mode: fake-ip
nameserver:
- 192.168.2.1
fallback:
- tls://1.0.0.1:853
- tls://dns.google:853

我也遇到了同样的问题。
我在Cloudflare上托管了我的域名并且启用了CDN加速,CDN服务器默认部署在海外。
由于一些原因,在近段时间内我的网络无法通过IPV4环境连接到海外的CDN服务器,此时clash能返回正确的ipv4地址下的”i/o timeout“记录。当然,IPV4下结果是连接失败,但此时我是可以通过IPV6线路进行的连接访问的。这个时候无奈只能关闭clash代理,直连上网。我设想的逻辑是这样的:一旦ipv4线路阻塞(指无法连接返回timeout),触发fallback机制去尝试解析AAAA记录进行IPV6连接,正如楼上所说这可能是一个有益且有意义的功能。
或许,在未来的版本中,可以在配置文件中提供一个开关,设置IPV4/6的优先级,同时配备fallback机制。
最后,谢谢各位辛勤的贡献者,对你们表示感谢~
我认为你想错了
我有一个纯v6的v2ray节点,节点地址是ipv6地址(非域名)。这个节点用v2ray(路由器)客户端时,显示超时,但是并不影响翻墙体验。
而当这个节点加入clash时,不知一直显示超时,而且完全无法连接。
所以这不应当是dns解析之类的,应该是clash内部的流量包转发有问题
Most helpful comment
我认为你想错了
我有一个纯v6的v2ray节点,节点地址是ipv6地址(非域名)。这个节点用v2ray(路由器)客户端时,显示超时,但是并不影响翻墙体验。
而当这个节点加入clash时,不知一直显示超时,而且完全无法连接。
所以这不应当是dns解析之类的,应该是clash内部的流量包转发有问题