MetaCubeX / mihomo

A simple Python Pydantic model for Honkai: Star Rail parsed data from the Mihomo API.
https://wiki.metacubex.one
MIT License
15.16k stars 2.52k forks source link

Meta的TUN模式NAT有问题 #281

Open TGSAN opened 1 year ago

TGSAN commented 1 year ago

测试协议:SS、Trojan、DIRECT

Meta版本开启TUN模式后,使用NatTypeTester测试结果为UnsupportedServer,很难进行端口穿透,经过连接测试估测为Symmetric NAT,为了排除代理服务器和协议影响,不使用RULE模式,采用DIRECT模式结果仍然是这样。

原版Clash开启TUN模式后,NAT类型为FullCone,可以轻松进行端口穿透。

Meta版本开启TUN模式:

UDP使用SS协议:

Meta版本开启TUN模式:

UDP使用SS协议:

ArchGuyWu commented 1 year ago

@TGSAN 估计规则匹配有问题,建议检查日志

TGSAN commented 1 year ago

@TGSAN 估计规则匹配有问题,建议检查日志

第二段中: “不使用RULE模式,采用DIRECT模式结果仍然是这样”

ArchGuyWu commented 1 year ago

@TGSAN 你测试时使用的服务器域名是什么?

TGSAN commented 1 year ago
12-02 12:28:06INFO
[UDP] 198.18.0.1:64382 --> stun.miwifi.com:3478 using DIRECT
12-02 12:31:24INFO
[UDP] 198.18.0.1:64382 --> stun.stunprotocol.org:3478 using DIRECT
12-02 12:32:03INFO
[UDP] 198.18.0.1:50950 --> stun.qq.com:3478 using DIRECT

stun.miwifi.com:3478/stun.stunprotocol.org:3478/stun.qq.com:3478 这三个

ArchGuyWu commented 1 year ago

@TGSAN qq那个域名是国内的,所以会匹配成直连

TGSAN commented 1 year ago

@TGSAN qq那个域名是国内的,所以会匹配成直连

没有使用规则模式,是直连模式

ArchGuyWu commented 1 year ago

@ArchGuyWu 你看,全都是直连

TGSAN commented 1 year ago

@ArchGuyWu 你看,全都是直连

因为是直连模式,不是规则模式

ArchGuyWu commented 1 year ago

@TGSAN 你之前不是说的全局吗?

TGSAN commented 1 year ago

全局选DIRECT和直连都一样

ArchGuyWu commented 1 year ago

@TGSAN 那你全局下选一个代理节点测试看看,如果节点没问题,应该会是fullcone

TGSAN commented 1 year ago

Meta版本开启TUN模式:

UDP使用SS协议:

  • NatTypeTester 测试结果为 UnsupportedServer
  • 实际端口穿透测试(通过WebRTC): 对端 FullCone:可以连接 对端 RestrictedCone:可以连接 对端 PortRestrictedCone:无法连接 对端 Symmetric:无法连接 结论:猜测实际为Symmetric NAT

UDP使用Trojan协议:

结果同上

UDP使用DIRECT直连:

结果同上

Meta版本开启TUN模式:

UDP使用SS协议:

  • NatTypeTester 测试结果为 FullCone
  • 实际端口穿透测试(通过WebRTC): 对端 FullCone:可以连接 对端 RestrictedCone:可以连接 对端 PortRestrictedCone:可以连接 对端 Symmetric:可以连接 结论:猜测实际为FullCone

UDP使用Trojan协议:

结果同上

UDP使用DIRECT直连:

结果同上

@ArchGuyWu

ArchGuyWu commented 1 year ago

@TGSAN 看了一下你先前的回复,大概明白了,direct模式下NAT等级取决于自身网络,所以用不用clash区别不大,需使用代理节点才能提高NAT等级

TGSAN commented 1 year ago

@TGSAN 看了一下你先前的回复,大概明白了,direct模式下NAT等级取决于自身网络,所以用不用clash区别不大,需使用代理节点才能提高NAT等级

是,但是原始网络环境已经是FullCone了,开启TUN模式直连不应导致降级。同时代理服务端支持FullCone的情况下开启TUN也不应降级。

ArchGuyWu commented 1 year ago

@TGSAN 请问你原始网络环境的拓扑是怎样的?需要确认测试工具有没有误报

ArchGuyWu commented 1 year ago

@ArchGuyWu 如果是家用网络环境,无公网且测试机设为DMZ则应该是fullcone

ArchGuyWu commented 1 year ago

@ArchGuyWu

ArchGuyWu commented 1 year ago

@ArchGuyWu

PingZi-Wing commented 1 year ago

我这里meta开启tun模式(clash verge windows),使用NatTypeTester测试结果一样也为UnsupportedServer,看了下分流日志udp分流是正确的(走了代理)。另外使用V2rayN测试NAT类型为FullCone,排除节点本身的udp问题,看来meta核心在这块的确有点问题

TGSAN commented 1 year ago

我这里meta开启tun模式(clash verge windows),使用NatTypeTester测试结果一样也为UnsupportedServer,看了下分流日志udp分流是正确的(走了代理)。另外使用V2rayN测试NAT类型为FullCone,排除节点本身的udp问题,看来meta核心在这块的确有点问题

其实用DIRECT模式复现是最能说明问题的,之前发现这个问题其实是发现STUN测试NAT类型有问题,然后想着直接加一条规则,把STUN全走直连试试,结果还是有问题。

DawnAleax commented 11 months ago

pc端拿cfw测你会发现可以实现fullcone

ENTNEAZ commented 8 months ago

是否是配置文件里的 tun: endpoint-independent-nat 配置问题

https://wiki.metacubex.one/config/inbound/tun/#endpoint-independent-nat

SunJun8 commented 4 months ago

🤔