-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug] TUN模式下,DNAT入站流量无法回包出站的问题 #1493
Comments
今天在虚拟化平台构建了一个简单的测试环境,对这个问题进行专项测试 在vyos配置相同的防火墙策略、snat masquerade策略和dnat策略,将内网服务器22端口映射到wan的2222端口 抓包Meta接口看不到任何流量,应该是入站流量和出站流量没有经过mihomo处理。 很匪夷所思 如果说这两个环境有区别,比较大的区别可能在我正式环境的vyos拥有eth0、eth1、eth2、eth3四个端口 我猜测有没有可能mihomo面对比较多的网络接口时出现了什么bug导致流量被错误导入到tun设备? 补充一下我mihomo在vyos设备上创建的ip rule规则和2022路由表
经过比较正式环境与测试环境上述量表内容相同,另,mihomo配置也相同 |
又在正式环境里测试了将内网端口映射到eth0上(而非pppoe0)的情况,从连接eth0的上游设备上是可以正常访问的。 现在看来原因逐渐清晰起来,当我映射到pppoe0上时: 至于这个流量是否真的出站了,目前我无法确定,理论上他应该可以出站,而我在外部服务器上抓不到包也可能是由于数据包的state不对而被云服务器的防火墙当作一个new的连接给drop掉了,这个我要再测试一下 而当我映射到eth0上时,由于eth0上是一个私网地址,所以出站流量不会被mihomo劫持,也自然在Meta接口抓不到包。 |
在openclash项目里查到两个issue,应该目前是通过读取openwrt的端口映射配置,然后把相关端口的访问提前在iptables里retune掉了。很不优雅。。 |
这个问题是否与#281也有关? |
我这边测试只要是dnat到wan ip的内网服务,无论tcp/udp,都是我说的这个状态。 |
开启tun后,端口转发从外部访问失效 |
是的,因为这种实际上hairpin nat做了一个源地址转换,你访问的a.com实际仍然是192.168.1.99 |
试试 |
这个参数什么意思其实不太理解,能否解释一下? |
我暂时把docker container改为host了 |
我暂时跑了tproxy模式,其实tproxy效率还更好一些。 |
大佬们咋解决的啊 ,有点看不懂啊 ,docker 部署host模式的外网访问不了nas |
ufw开了吗 |
Verify steps
Operating System
Linux
System Version
vyos 1.5
Mihomo Version
Mihomo Meta alpha-43f21c0 linux amd64 with go1.23.0 Mon Sep 2 08:24:57 UTC 2024
Use tags: with_gvisor
Configuration File
Description
我是在vyos上通过container host模式运行的mihomo 1.18.8
我的情况是vyos上配置了dnat映射,经过抓包发现
当从外部网络访问我映射的服务时
4.之后这个数据包就进入了Meta接口,从Meta接口抓包可以看到
当我关闭mihomo时相关数据包可以在pppoe0和br0上被正常捕获,我确认这与我vyos的防火墙无关,因为关闭防火墙全通策略下也是这样的表现。
我不知道到4这一步时,正常的表现应该是:
还是:
2.内网服务器响应的数据包进入Meta接口,然后再从pppoe0出去
但无论如何,确实外部网络的主机无法收到任何回包。
内网主机正常访问外网表现为完全正常。
Reproduction Steps
vyos dnat配置
vyos mihomo容器配置
在mihomo alpha、v1.18.8、v1.18.5版本测试表现相同
Logs
The text was updated successfully, but these errors were encountered: