fix: 分离 fw4 IPv4/IPv6 DNS 劫持判断 - #5209
Merged
Merged
Conversation
This was referenced Jul 8, 2026
Closed
Closed
Closed
This was referenced Jul 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题现象
fw4/nftables 环境启用 IPv6、
enable_redirect_dns=1时,IPv4 DNS 劫持规则先写入dstnat后,IPv6 DNS 劫持分支可能被同一个OpenClash DNS Hijack注释检查短路,最终 IPv6 LAN DNS 和 router-self IPv6 DNS 没有进入预期重定向路径。根因
fw4 IPv4 和 IPv6 分支都用
nft list chain inet fw4 dstnat | grep 'OpenClash DNS Hijack'判断是否已有 DNS 规则。IPv4 分支先执行后,IPv6 分支只看到同名注释就跳过,没有区分 IPv4/IPv6 规则特征。修复方案
fw4_has_dns_hijack_rule(chain, family),按meta nfproto ipv6/ip6 nexthdr区分 IPv6 DNS 规则。与已有开启态 PR 的关系
OpenClash #5191/#5193/#5197/#5198/#5202、mihomo-oix #8、mihomo #10 均不触及 fw4 IPv4/IPv6 DNS guard。该修复独立于 OIX 数据面和系统 feed 下载路径。
验证
bash -n luci-app-openclash/root/usr/share/openclash/*.shbash -n luci-app-openclash/root/etc/init.d/openclashbash -n tests/*.shbash tests/fw4_dns_hijack_guard_test.shgit diff --checkrg '<<<<<<<|=======|>>>>>>>' luci-app-openclash/root/etc/init.d/openclash tests无匹配剩余风险
未做 live nft 规则验证;本地测试用 mock
nft list覆盖 IPv4-only 和 IPv6-only 两种 guard 判定。