Skip to content
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

开启 OpenClash 影响NAT类型 #2288

Closed
Alano-i opened this issue Apr 19, 2022 · 39 comments
Closed

开启 OpenClash 影响NAT类型 #2288

Alano-i opened this issue Apr 19, 2022 · 39 comments
Labels

Comments

@Alano-i
Copy link

Alano-i commented Apr 19, 2022

OpenWrt 已开启 全锥形 NAT
OpenClash 关闭时,网心云上显示网络类型为映射公网
但是当启动 OpenClash ,就变成端口映射型了,降级了。

请问是设置不当还是本身存在bug?

@vernesong
Copy link
Owner

直连的会有这个问题,建议绕过国内

@Alano-i
Copy link
Author

Alano-i commented Apr 21, 2022

直连的会有这个问题,建议绕过国内

使用的fake-ip增强模式,没有绕过国内。能不能取消掉UDP流量转发来实现啊,刚试了下不知道是时间太短没反应过来还是本身这种方法不行,网心那边还是端口限制型。
image

@TGSAN
Copy link

TGSAN commented May 3, 2022

一样,连接国外STUN服务器,关闭OpenClash立刻FullCone,开了OpenClash就变成PortRestrictedCone。即使在Clash规则里面让STUN直连也是一样,兼容模式和TUN模式都一样,试了下 Windows 上 Clash 没这个问题,OpenClash需要关闭UDP代理或者勾选“仅允许常用端口流量”,让STUN流量完全不走OpenClash才可以。

@AnzhiZhang
Copy link

在 OpenClash 的全局设置中开启 仅允许常用端口流量 即可。

@github-actions
Copy link
Contributor

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

@github-actions github-actions bot added the Stale label Aug 19, 2022
@TGSAN
Copy link

TGSAN commented Aug 19, 2022

看上去最新版本依然没解决这个问题的样子,如果需要STUN走代理的话就无解了(即使代理服务端已经是支持FullCone的情况)

@github-actions github-actions bot removed the Stale label Aug 20, 2022
@link-duan
Copy link

我的问题比较简单,就希望 UPnP 能正常使用,公网通过端口映射访问不走代理。但是现在访问不通,用的 miniupnp ,有人解决过这个问题吗?

@github-actions
Copy link
Contributor

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

@github-actions github-actions bot added the Stale label Oct 23, 2022
@TGSAN
Copy link

TGSAN commented Oct 23, 2022

最近试了在openclash里换上新版本的clash内核和meta内核,发现和之前一样,但是在单独使用这些版本内核的情况下nat可以fullcone

@github-actions github-actions bot removed the Stale label Oct 24, 2022
@github-actions
Copy link
Contributor

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

@github-actions github-actions bot added the Stale label Dec 24, 2022
@paladin4fan
Copy link
Contributor

奇怪 我两台路由器同样的系统 都是clash内核 一个国外服务器direct可以继续fullcone 另一个不行

@github-actions github-actions bot removed the Stale label Dec 26, 2022
@chelomei
Copy link

大陆ip绕过核心模式,tun混合模式,国内外流量都能实现fullcone
大陆流量不绕过核心,同样设置的tun混合模式,国外流量仍可以实现fullcone,国内流量降为PortRestrictedCone

@paladin4fan
Copy link
Contributor

大陆ip绕过核心模式,tun混合模式,国内外流量都能实现fullcone 大陆流量不绕过核心,同样设置的tun混合模式,国外流量仍可以实现fullcone,国内流量降为PortRestrictedCone

你的国外流量应该是走代理节点了 代理节点替你Fullcone的
如果是进了TUN内核又判定direct的国外流量 就会和不绕过核心的大陆流量一样被改成PortRestrictedCone
现在好像Tun模式是无解

@superdejavu
Copy link

我的udp流量老是直连,开了全局也还是直连,请教是为什么呢

@TGSAN
Copy link

TGSAN commented Jan 1, 2023

大陆ip绕过核心模式,tun混合模式,国内外流量都能实现fullcone 大陆流量不绕过核心,同样设置的tun混合模式,国外流量仍可以实现fullcone,国内流量降为PortRestrictedCone

你的国外流量应该是走代理节点了 代理节点替你Fullcone的 如果是进了TUN内核又判定direct的国外流量 就会和不绕过核心的大陆流量一样被改成PortRestrictedCone 现在好像Tun模式是无解

兼容模式也会影响NAT,可能和TUN模式无关,另外试了下在Windows上带GUI的Clash客户端使用原版内核是可以FullCone的(但是Meta内核不行)

@paladin4fan
Copy link
Contributor

paladin4fan commented Jan 1, 2023

大陆ip绕过核心模式,tun混合模式,国内外流量都能实现fullcone 大陆流量不绕过核心,同样设置的tun混合模式,国外流量仍可以实现fullcone,国内流量降为PortRestrictedCone

你的国外流量应该是走代理节点了 代理节点替你Fullcone的 如果是进了TUN内核又判定direct的国外流量 就会和不绕过核心的大陆流量一样被改成PortRestrictedCone 现在好像Tun模式是无解

兼容模式也会影响NAT,可能和TUN模式无关,另外试了下在Windows上带GUI的Clash客户端使用原版内核是可以FullCone的(但是Meta内核不行)

我用了三台同个固件的软路由试了下 只有一台兼容模式下对国外direct规则也是fullcone的 剩下两台啥内核都是降级 Meta内核每一台都是降级
NatTypeTester测试NAT3 PyStun3测试NAT2
不知道这个唯一一台成功的是为什么 是因为运营商还是因为我配了mwan3分流

@github-actions
Copy link
Contributor

github-actions bot commented Mar 3, 2023

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

@jacobsenxin
Copy link

同样遇到此问题,请问您最后是如何解决的,我是switch主机,关闭openclash是NAT A,打开走代理是NAT F,走直连是NAT B

@TGSAN
Copy link

TGSAN commented Sep 17, 2023

同样遇到此问题,请问您最后是如何解决的,我是switch主机,关闭openclash是NAT A,打开走代理是NAT F,走直连是NAT B

无解,只能让流量不要过OpenClash才可以,不过NAT F应该是节点问题

@0daysseus
Copy link

0daysseus commented Sep 21, 2023

可以增加一个代理绕过端口的功能吗,类似于passwall,把stun的流量给绕过。我用的的redir-host兼容模式meta核,使用natmap只有把指定的tcp stun服务器的ip添加到本地ip地址绕过才可以打洞成功(udp的不需要,可以直接打成功,并且观察到开启openclash,tcp只有80和443可以打成功),或者openclash延迟启动,等打完洞再启动。。。。

@TGSAN
Copy link

TGSAN commented Sep 23, 2023

可以增加一个代理绕过端口的功能吗,类似于passwall,把stun的流量给绕过。我用的的redir-host兼容模式meta核,使用natmap只有把指定的tcp stun服务器的ip添加到本地ip地址绕过才可以打洞成功(udp的不需要,可以直接打成功,并且观察到开启openclash,tcp只有80和443可以打成功),或者openclash延迟启动,等打完洞再启动。。。。

之前有开一个新的issue #3480 里面是希望可以单独指定TCP或者UDP的那些端口需要走内核

@stackia
Copy link

stackia commented Jan 28, 2024

在 OpenClash 插件设置 - 开发者选项,加入这两条 nftables 规则,把所有 STUN 流量绕过即可(3478-3497 是苹果 FaceTime 的 STUN 端口范围)

nft insert rule inet fw4 openclash_mangle position 0 meta nfproto ipv4 udp dport 3478-3497 counter return
nft insert rule inet fw4 openclash_mangle_v6 position 0 meta nfproto ipv6 udp dport 3478-3497 counter return

@paladin4fan
Copy link
Contributor

在 OpenClash 插件设置 - 开发者选项,加入这两条 nftables 规则,把所有 STUN 流量绕过即可(3478-3497 是苹果 FaceTime 的 STUN 端口范围)

nft insert rule inet fw4 openclash_mangle position 0 meta nfproto ipv4 udp dport 3478-3497 counter return
nft insert rule inet fw4 openclash_mangle_v6 position 0 meta nfproto ipv6 udp dport 3478-3497 counter return

问题是很多需求fullcone的人是用来打游戏的 而游戏是不是用的标准stun端口呢

@stackia
Copy link

stackia commented Jan 28, 2024

除了标准的 STUN,大多数 p2p 协议从设计上都会使用 3478 附近端口来打洞,因为很多防火墙在 3478 上比较宽松。
我观察到的有:FaceTime、HomeKit Secure Video、微信视频聊天、Steam/PS/Xbox Networking(大多数游戏底层使用)、Zoom、Teams、Google Meet、GTA5、Parsec 等。

@vernesong
Copy link
Owner

新版加了tun的接口,nat应该没问题

@paladin4fan
Copy link
Contributor

paladin4fan commented Jan 28, 2024 via email

@TGSAN
Copy link

TGSAN commented Feb 5, 2024

新版加了tun的接口,nat应该没问题

试了下新版本tun接口可以让命中代理链的流量正常变为FullCone了,但是奇怪的是命中DIRECT的流量反而变成了PortResCone

@vernesong
Copy link
Owner

直连的没办法

@TGSAN
Copy link

TGSAN commented Feb 6, 2024

即使打了FullCone NAT的补丁也没办法吗,不过代理可以FullCone应该可以本机开代理服务然后DIRECT规则连本机了。辛苦作者开发了,感谢!

@stackia
Copy link

stackia commented Feb 6, 2024

可以试试开启 clash meta 的 endpoint-independent-nat
https://wiki.metacubex.one/config/inbound/tun/#endpoint-independent-nat

@TGSAN
Copy link

TGSAN commented Feb 6, 2024

可以试试开启 clash meta 的 endpoint-independent-nat https://wiki.metacubex.one/config/inbound/tun/#endpoint-independent-nat

一直开着,用的开发者模式的ruby_edit
image
image

@paladin4fan
Copy link
Contributor

可以试试开启 clash meta 的 endpoint-independent-nat https://wiki.metacubex.one/config/inbound/tun/#endpoint-independent-nat

一直开着,用的开发者模式的ruby_edit image image

所以当前OC的三个核心 唯一可以在开启UDP代理的时候实现direct链接fullcone的方式
就是用路由器自身的代理服务器重新代理一遍?

@TGSAN
Copy link

TGSAN commented Feb 6, 2024

所以当前OC的三个核心 唯一可以在开启UDP代理的时候实现direct链接fullcone的方式 就是用路由器自身的代理服务器重新代理一遍?

做法有点脏,但是目前看上去可行。其他方案还在研究。

@paladin4fan
Copy link
Contributor

所以当前OC的三个核心 唯一可以在开启UDP代理的时候实现direct链接fullcone的方式 就是用路由器自身的代理服务器重新代理一遍?

做法有点脏,但是目前看上去可行。其他方案还在研究。

这个方案实践过了吗 如果可以让国外direct流量变回fullcone那我也这么玩好了

@Pacio
Copy link

Pacio commented May 3, 2024

目前用的fakeip+混合模式无解啊fullcone都没了

@paladin4fan
Copy link
Contributor

目前用的fakeip+混合模式无解啊fullcone都没了

fakeip确实难搞
我用redir 可以单独把ipv4 udp链接排除出去用passwall
也算是曲线救国

@iTofu
Copy link

iTofu commented May 29, 2024

同问,fake-ip 模式有啥解决方案吗?需要 fullcone

@Todd-Zhangt
Copy link

新版加了tun的接口,nat应该没问题

试了下新版本tun接口可以让命中代理链的流量正常变为FullCone了,但是奇怪的是命中DIRECT的流量反而变成了PortResCone

大佬麻烦问一下有什么新的解决办法么?我现在用的fakeip增强模式,natmap打洞会失败 NAT类型变成NAT3。改成redir-host就正常了

@TGSAN
Copy link

TGSAN commented Jun 17, 2024

新版加了tun的接口,nat应该没问题

试了下新版本tun接口可以让命中代理链的流量正常变为FullCone了,但是奇怪的是命中DIRECT的流量反而变成了PortResCone

大佬麻烦问一下有什么新的解决办法么?我现在用的fakeip增强模式,natmap打洞会失败 NAT类型变成NAT3。改成redir-host就正常了

我不用fakeip,因为打洞和fakeip本身就很容易冲突(一个是转换地址,一个是解地址转换)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests