[Bug] 0.46.075-079 版本从本机发往大陆地区地址的 IPv6 数据包代理异常
Verify Steps
- [x] Tracker 我已经在 Issue Tracker 中找过我要提出的问题
- [x] Branch 我知道 OpenClash 的 Dev 分支切换开关位于插件设置-版本更新中,或者我会手动下载并安装 Dev 分支的 OpenClash
- [x] Latest 我已经使用最新 Dev 版本测试过,问题依旧存在
- [x] Relevant 我知道 OpenClash 与 内核(Core)、控制面板(Dashboard)、在线订阅转换(Subconverter)等项目之间无直接关系,仅相互调用
- [x] Definite 这确实是 OpenClash 出现的问题
- [ ] Contributors 我有能力协助 OpenClash 开发并解决此问题
- [ ] Meaningless 我提交的是无意义的催促更新或修复请求
OpenClash Version
v0.46.079
Bug on Environment
Immortalwrt
OpenWrt Version
ImmortalWrt 24.10.1
Bug on Platform
Linux-arm64
Describe the Bug
在0.46.075和079版本,从本机发往大陆地区地址的 IPv6 的数据包无法正确送达目标主机,导致opkg 无法连接 v6 软件源更新( #4329 )等问题。回退到064版本可以正常访问。
使用 curl 访问 v6 地址,注意到返回结果为路由器自身的 luci 界面,而非目标网站:
$ curl -6 -kkvvv www.baidu.com
> GET / HTTP/1.1
> Host: www.baidu.com
> User-Agent: curl/8.7.1
> Accept: */*
>
< HTTP/1.1 403 Forbidden
< Connection: Keep-Alive
< Transfer-Encoding: chunked
< Keep-Alive: timeout=20
< x-luci-login-required: yes
< content-type: text/html
< cache-control: no-cache
< expires: 0
< x-frame-options: SAMEORIGIN
< x-xss-protection: 1; mode=block
< x-content-type-options: nosniff
<
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>
OpenWrt
- LuCI</title>
...
在 nftables 中插入追踪规则,查看数据包在防火墙中的流向(DST_IP_1和DST_IP_2 分别为大陆地区和大陆地区以外的 IPv6 地址):
nft add table ip6 trace_table
nft add chain ip6 trace_table output_chain '{ type filter hook output priority -300 ; ip6 daddr DST_IP_1 meta nftrace set 1 ; ip6 daddr DST_IP_2 meta nftrace set 1 ; }'
运行 nft monitor trace | tee trace.log 启动监控,在另一个终端分别运行 curl -6 -kkvvv DST_IP_1 和 curl -6 -kkvvv DST_IP_2 。
trace-064-local-curl-chn.log trace-064-local-curl-google.log trace-079-local-curl-chn.log trace-079-local-curl-google.log
从追踪结果观察,在 064 和 079 版本下,发往大陆和大陆以外的 IPv6 包经过的规则如下:
| 064 | 079 | |
|---|---|---|
| 大陆 | openclash_output_v6 命中绕过大陆规则,返回 - 从 wan 输出 | openclash_mangle_output_v6 标记 0x162 - 策略路由走 lo 回到本机 - openclash_mangle_v6 命中绕过大陆规则,返回 - 输入本机 |
| 非大陆 | openclash_output_v6 转发到 clash 代理端口 - 从 lo 回到 clash 代理 | openclash_mangle_output_v6 标记 0x162 - 策略路由走 lo 回到本机 - openclash_mangle_v6 命中 tproxy 进入 clash 代理 |
可见在064版本中先判断了目标ip是否属于大陆,然后决定输出还是回到clash;而在079版本中,数据包全部先输入回到了本机,再判断目标是否属于大陆,此时绕过核心导致数据包进入本机,而非由wan口输出。相应的解决方案则应该将分流判断逻辑回退到与064版本相同。
To Reproduce
安装OpenClash 0.46.075或更高版本,配置插件设置如下:
- 流量控制
- 路由本机代理
- IPv6 设置
- IPv6 流量代理
- IPv6 代理模式: TProxy
- UDP 流量转发
- 允许 IPv6 类型 DNS 解析
- 实验性:绕过指定区域 IPv6: 绕过中国大陆
启动 OpenClash,在路由器上运行 curl -6 -kkvvv www.baidu.com ,观察返回结果。
OpenClash Log
见最下方附件
OpenClash Config
见重现步骤
Expected Behavior
从路由器本机发往大陆地区地址的 IPv6 数据包正确路由到目的地,而非输入返回本机
Additional Context
新版本试了一下还是有一样的问题呢
现在防火墙那规则应该是一样的了
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 5 days