[GH-ISSUE #4244] xtcp希望能增加 -u,是用upnp连接打洞 #3345

Closed
opened 2026-05-05 14:09:26 -06:00 by gitea-mirror · 8 comments
Owner

Originally created by @wuai1024 on GitHub (May 27, 2024).
Original GitHub issue: https://github.com/fatedier/frp/issues/4244

Describe the feature request

目前需要将 提供端 frpc 使用 dmz 给暴漏出去,这样设置后,别的ip就无法利用剩余的端口了。

出口路由器一般会支持设置 upnp 希望能是用一个参数,让 frpc 去局域网中查找提供 upnp 服务的。

Describe alternatives you've considered

No response

Affected area

  • Docs
  • Installation
  • Performance and Scalability
  • Security
  • User Experience
  • Test and Release
  • Developer Infrastructure
  • Client Plugin
  • Server Plugin
  • Extensions
  • Others
Originally created by @wuai1024 on GitHub (May 27, 2024). Original GitHub issue: https://github.com/fatedier/frp/issues/4244 ### Describe the feature request 目前需要将 提供端 `frpc` 使用 `dmz` 给暴漏出去,这样设置后,别的ip就无法利用剩余的端口了。 出口路由器一般会支持设置 `upnp` 希望能是用一个参数,让 `frpc` 去局域网中查找提供 `upnp` 服务的。 ### Describe alternatives you've considered _No response_ ### Affected area - [ ] Docs - [ ] Installation - [ ] Performance and Scalability - [ ] Security - [ ] User Experience - [ ] Test and Release - [ ] Developer Infrastructure - [X] Client Plugin - [ ] Server Plugin - [ ] Extensions - [ ] Others
Author
Owner

@xqzr commented on GitHub (May 28, 2024):

#1823

<!-- gh-comment-id:2134728234 --> @xqzr commented on GitHub (May 28, 2024): #1823
Author
Owner

@wuai1024 commented on GitHub (May 28, 2024):

如果考虑到支持这个功能,我可以提供测试环境,或者帮忙测试。

<!-- gh-comment-id:2134783251 --> @wuai1024 commented on GitHub (May 28, 2024): 如果考虑到支持这个功能,我可以提供测试环境,或者帮忙测试。
Author
Owner

@xqzr commented on GitHub (May 28, 2024):

或者 增加选项,设置 UDP 打洞数据包的 源端口。这样,在路由器(网关)“端口映射”设置的 源端口,也有机会 获得 NAT1。

<!-- gh-comment-id:2135134542 --> @xqzr commented on GitHub (May 28, 2024): 或者 增加选项,设置 UDP 打洞数据包的 **源端口**。这样,在路由器(网关)“**端口映射**”设置的 **源端口**,也有机会 获得 NAT1。
Author
Owner

@fatedier commented on GitHub (May 29, 2024):

upnp 相关的内容在 https://github.com/fatedier/frp/issues/4112 中跟进,你可以使用对应的 PR 编译进行测试。

也可以反馈当前 p2p 打洞两端的环境和日志,有助于帮助我们进行优化。

<!-- gh-comment-id:2136454425 --> @fatedier commented on GitHub (May 29, 2024): upnp 相关的内容在 https://github.com/fatedier/frp/issues/4112 中跟进,你可以使用对应的 PR 编译进行测试。 也可以反馈当前 p2p 打洞两端的环境和日志,有助于帮助我们进行优化。
Author
Owner

@wuai1024 commented on GitHub (Jun 6, 2024):

upnp 相关的内容在 #4112 中跟进,你可以使用对应的 PR 编译进行测试。

也可以反馈当前 p2p 打洞两端的环境和日志,有助于帮助我们进行优化。

xtcpproxy 端日志:

2024-06-06 14:50:56.021 [I] [proxy/xtcp.go:72] [5e414b2fc219fc0f] [ikuai.ssh] nathole prepare success, nat type: EasyNAT, behavior: BehaviorNoChange, addresses: [2.2.2.2:9361 2.2.2.2:9361], assistedAddresses: [192.168.253.3:49192]
2024-06-06 14:50:56.030 [I] [proxy/xtcp.go:93] [5e414b2fc219fc0f] [ikuai.ssh] get natHoleRespMsg, sid [1717656655e974dc6a4af62f69], protocol [quic], candidate address [103.155.100.146:36738 103.155.100.145:36738], assisted address [192.168.6.21:49262 192.168.11.3:49262], detectBehavior: {Role:receiver Mode:1 TTL:7 SendDelayMs:0 ReadTimeoutMs:5000 CandidatePorts:[{From:36733 To:36743}] SendRandomPorts:0 ListenRandomPorts:0}
2024-06-06 14:50:56.040 [I] [proxy/xtcp.go:72] [5e414b2fc219fc0f] [ikuai.drive] nathole prepare success, nat type: EasyNAT, behavior: BehaviorNoChange, addresses: [2.2.2.2:9362 2.2.2.2:9362], assistedAddresses: [192.168.253.3:49416]
2024-06-06 14:50:56.048 [I] [proxy/xtcp.go:93] [5e414b2fc219fc0f] [ikuai.drive] get natHoleRespMsg, sid [1717656655b4ca0d05af26398f], protocol [quic], candidate address [103.155.100.134:42432 103.155.100.133:42432], assisted address [192.168.6.21:65156 192.168.11.3:65156], detectBehavior: {Role:receiver Mode:1 TTL:7 SendDelayMs:0 ReadTimeoutMs:5000 CandidatePorts:[{From:42427 To:42437}] SendRandomPorts:0 ListenRandomPorts:0}
2024-06-06 14:50:57.066 [I] [proxy/xtcp.go:109] [5e414b2fc219fc0f] [ikuai.ssh] establishing nat hole connection successful, sid [1717656655e974dc6a4af62f69], remoteAddr [3.3.3.3:49262]
2024-06-06 14:50:57.069 [I] [proxy/xtcp.go:109] [5e414b2fc219fc0f] [ikuai.drive] establishing nat hole connection successful, sid [1717656655b4ca0d05af26398f], remoteAddr [3.3.3.3:65156]

xtcpvisitors 端日志:

2024-06-06 14:50:53.202 [I] [visitor/visitor_manager.go:121] [985f1072d95b89c5] start visitor success
2024-06-06 14:50:53.202 [I] [visitor/visitor_manager.go:121] [985f1072d95b89c5] start visitor success
2024-06-06 14:50:53.202 [I] [visitor/visitor_manager.go:172] [985f1072d95b89c5] visitor added: [mac.nacos mac.ikuai mac.synology-ssh mac.hp-print mac.sonar mac.stabe-diffusion mac.sshd-frpc-ssh mac.sshd-frpc-web mac.ssh mac.drive]
2024-06-06 14:50:53.221 [I] [client/control.go:168] [985f1072d95b89c5] [mac.proxy] start proxy success
2024-06-06 14:50:53.740 [I] [visitor/xtcp.go:283] [985f1072d95b89c5] [mac.ssh] nathole prepare success, nat type: HardNAT, behavior: BehaviorIPChanged, addresses: [103.155.100.146:36738 103.155.100.145:36738], assistedAddresses: [192.168.6.21:49262 192.168.11.3:49262]
2024-06-06 14:50:53.747 [I] [visitor/xtcp.go:283] [985f1072d95b89c5] [mac.drive] nathole prepare success, nat type: HardNAT, behavior: BehaviorIPChanged, addresses: [103.155.100.134:42432 103.155.100.133:42432], assistedAddresses: [192.168.6.21:65156 192.168.11.3:65156]
2024-06-06 14:50:55.128 [I] [visitor/xtcp.go:309] [985f1072d95b89c5] [mac.ssh] get natHoleRespMsg, sid [1717656655e974dc6a4af62f69], protocol [quic], candidate address [2.2.2.2:9361], assisted address [192.168.253.3:49192], detectBehavior: {Role:sender Mode:1 TTL:0 SendDelayMs:0 ReadTimeoutMs:5000 CandidatePorts:[] SendRandomPorts:0 ListenRandomPorts:0}
2024-06-06 14:50:55.146 [I] [visitor/xtcp.go:309] [985f1072d95b89c5] [mac.drive] get natHoleRespMsg, sid [1717656655b4ca0d05af26398f], protocol [quic], candidate address [2.2.2.2:9362], assisted address [192.168.253.3:49416], detectBehavior: {Role:sender Mode:1 TTL:0 SendDelayMs:0 ReadTimeoutMs:5000 CandidatePorts:[] SendRandomPorts:0 ListenRandomPorts:0}
2024-06-06 14:50:55.166 [I] [visitor/xtcp.go:320] [985f1072d95b89c5] [mac.ssh] establishing nat hole connection successful, sid [1717656655e974dc6a4af62f69], remoteAddr [2.2.2.2:9361]
2024-06-06 14:50:55.168 [I] [visitor/xtcp.go:320] [985f1072d95b89c5] [mac.drive] establishing nat hole connection successful, sid [1717656655b4ca0d05af26398f], remoteAddr [2.2.2.2:9362]

目前 proxy 在 NAT1 环境下,visitors 在 NAT4 环境下,打洞成功!

<!-- gh-comment-id:2151672268 --> @wuai1024 commented on GitHub (Jun 6, 2024): > upnp 相关的内容在 #4112 中跟进,你可以使用对应的 PR 编译进行测试。 > > 也可以反馈当前 p2p 打洞两端的环境和日志,有助于帮助我们进行优化。 `xtcp` 中 `proxy` 端日志: ```shell 2024-06-06 14:50:56.021 [I] [proxy/xtcp.go:72] [5e414b2fc219fc0f] [ikuai.ssh] nathole prepare success, nat type: EasyNAT, behavior: BehaviorNoChange, addresses: [2.2.2.2:9361 2.2.2.2:9361], assistedAddresses: [192.168.253.3:49192] 2024-06-06 14:50:56.030 [I] [proxy/xtcp.go:93] [5e414b2fc219fc0f] [ikuai.ssh] get natHoleRespMsg, sid [1717656655e974dc6a4af62f69], protocol [quic], candidate address [103.155.100.146:36738 103.155.100.145:36738], assisted address [192.168.6.21:49262 192.168.11.3:49262], detectBehavior: {Role:receiver Mode:1 TTL:7 SendDelayMs:0 ReadTimeoutMs:5000 CandidatePorts:[{From:36733 To:36743}] SendRandomPorts:0 ListenRandomPorts:0} 2024-06-06 14:50:56.040 [I] [proxy/xtcp.go:72] [5e414b2fc219fc0f] [ikuai.drive] nathole prepare success, nat type: EasyNAT, behavior: BehaviorNoChange, addresses: [2.2.2.2:9362 2.2.2.2:9362], assistedAddresses: [192.168.253.3:49416] 2024-06-06 14:50:56.048 [I] [proxy/xtcp.go:93] [5e414b2fc219fc0f] [ikuai.drive] get natHoleRespMsg, sid [1717656655b4ca0d05af26398f], protocol [quic], candidate address [103.155.100.134:42432 103.155.100.133:42432], assisted address [192.168.6.21:65156 192.168.11.3:65156], detectBehavior: {Role:receiver Mode:1 TTL:7 SendDelayMs:0 ReadTimeoutMs:5000 CandidatePorts:[{From:42427 To:42437}] SendRandomPorts:0 ListenRandomPorts:0} 2024-06-06 14:50:57.066 [I] [proxy/xtcp.go:109] [5e414b2fc219fc0f] [ikuai.ssh] establishing nat hole connection successful, sid [1717656655e974dc6a4af62f69], remoteAddr [3.3.3.3:49262] 2024-06-06 14:50:57.069 [I] [proxy/xtcp.go:109] [5e414b2fc219fc0f] [ikuai.drive] establishing nat hole connection successful, sid [1717656655b4ca0d05af26398f], remoteAddr [3.3.3.3:65156] ``` `xtcp` 中 `visitors` 端日志: ```shell 2024-06-06 14:50:53.202 [I] [visitor/visitor_manager.go:121] [985f1072d95b89c5] start visitor success 2024-06-06 14:50:53.202 [I] [visitor/visitor_manager.go:121] [985f1072d95b89c5] start visitor success 2024-06-06 14:50:53.202 [I] [visitor/visitor_manager.go:172] [985f1072d95b89c5] visitor added: [mac.nacos mac.ikuai mac.synology-ssh mac.hp-print mac.sonar mac.stabe-diffusion mac.sshd-frpc-ssh mac.sshd-frpc-web mac.ssh mac.drive] 2024-06-06 14:50:53.221 [I] [client/control.go:168] [985f1072d95b89c5] [mac.proxy] start proxy success 2024-06-06 14:50:53.740 [I] [visitor/xtcp.go:283] [985f1072d95b89c5] [mac.ssh] nathole prepare success, nat type: HardNAT, behavior: BehaviorIPChanged, addresses: [103.155.100.146:36738 103.155.100.145:36738], assistedAddresses: [192.168.6.21:49262 192.168.11.3:49262] 2024-06-06 14:50:53.747 [I] [visitor/xtcp.go:283] [985f1072d95b89c5] [mac.drive] nathole prepare success, nat type: HardNAT, behavior: BehaviorIPChanged, addresses: [103.155.100.134:42432 103.155.100.133:42432], assistedAddresses: [192.168.6.21:65156 192.168.11.3:65156] 2024-06-06 14:50:55.128 [I] [visitor/xtcp.go:309] [985f1072d95b89c5] [mac.ssh] get natHoleRespMsg, sid [1717656655e974dc6a4af62f69], protocol [quic], candidate address [2.2.2.2:9361], assisted address [192.168.253.3:49192], detectBehavior: {Role:sender Mode:1 TTL:0 SendDelayMs:0 ReadTimeoutMs:5000 CandidatePorts:[] SendRandomPorts:0 ListenRandomPorts:0} 2024-06-06 14:50:55.146 [I] [visitor/xtcp.go:309] [985f1072d95b89c5] [mac.drive] get natHoleRespMsg, sid [1717656655b4ca0d05af26398f], protocol [quic], candidate address [2.2.2.2:9362], assisted address [192.168.253.3:49416], detectBehavior: {Role:sender Mode:1 TTL:0 SendDelayMs:0 ReadTimeoutMs:5000 CandidatePorts:[] SendRandomPorts:0 ListenRandomPorts:0} 2024-06-06 14:50:55.166 [I] [visitor/xtcp.go:320] [985f1072d95b89c5] [mac.ssh] establishing nat hole connection successful, sid [1717656655e974dc6a4af62f69], remoteAddr [2.2.2.2:9361] 2024-06-06 14:50:55.168 [I] [visitor/xtcp.go:320] [985f1072d95b89c5] [mac.drive] establishing nat hole connection successful, sid [1717656655b4ca0d05af26398f], remoteAddr [2.2.2.2:9362] ``` 目前 proxy 在 NAT1 环境下,visitors 在 NAT4 环境下,打洞成功!
Author
Owner

@fatedier commented on GitHub (Jun 6, 2024):

@wuai1024 成功的是原生版本还是 upnp PR 编译出来的版本?

我们希望收集的是默认情况下无法成功,开启 upnp 后成功的场景。

<!-- gh-comment-id:2151687502 --> @fatedier commented on GitHub (Jun 6, 2024): @wuai1024 成功的是原生版本还是 upnp PR 编译出来的版本? 我们希望收集的是默认情况下无法成功,开启 upnp 后成功的场景。
Author
Owner

@xqzr commented on GitHub (Jun 6, 2024):

proxy 在 NAT1 环境下,visitors 在 NAT4 环境下,打洞成功!

符合预期

<!-- gh-comment-id:2152693607 --> @xqzr commented on GitHub (Jun 6, 2024): > proxy 在 NAT1 环境下,visitors 在 NAT4 环境下,打洞成功! 符合预期
Author
Owner

@wuai1024 commented on GitHub (Aug 13, 2024):

@wuai1024 成功的是原生版本还是 upnp PR 编译出来的版本?

我们希望收集的是默认情况下无法成功,开启 upnp 后成功的场景。

@fatedier
这个是原生的版本,被访问端开启 DMZ 之后的表现。

我当时不知道你回复了,我后续关闭 DMZ 之后,试一下 upnp 的版本。

<!-- gh-comment-id:2285709637 --> @wuai1024 commented on GitHub (Aug 13, 2024): > @wuai1024 成功的是原生版本还是 upnp PR 编译出来的版本? > > 我们希望收集的是默认情况下无法成功,开启 upnp 后成功的场景。 @fatedier 这个是原生的版本,被访问端开启 DMZ 之后的表现。 我当时不知道你回复了,我后续关闭 DMZ 之后,试一下 upnp 的版本。
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/frp#3345
No description provided.