[GH-ISSUE #3235] 默认服务端开启了IPV6监听,但是没有监听IPV4,所有客户端无法连接 #2598

Closed
opened 2026-05-05 13:40:29 -06:00 by gitea-mirror · 8 comments
Owner

Originally created by @fschenkun22 on GitHub (Jan 2, 2023).
Original GitHub issue: https://github.com/fatedier/frp/issues/3235

Bug Description

服务器配置如下:

[common]
bind_port = 17000
token = 123456

使用Linux 命令 netstat -ant 查看端口占用情况

[root@first ~]# netstat -ant
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State      
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN     
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN     
tcp        0      0 172.24.209.225:36876    100.100.15.4:443        TIME_WAIT  
tcp6       0      0 ::1:25                  :::*                    LISTEN     
tcp6       0      0 :::17000                :::*                    LISTEN     

只能看到监听了tcp6的端口 ,但是ipv4的默认没有监听,所以所有客户端都无法进行连接。
文档中没有发现对应监听IPV4 或者 IPV6 的配置项

frpc Version

0.46.0

frps Version

0.46.0

System Architecture

linux/amd64 ;Linux first 3.10.0-1160.71.1.el7.x86_64 #1 SMP Tue Jun 28 15:37:28 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

Configurations

server端配置:

[common]
bind_port = 17000

客户端配置:

[common]
server_addr = "my server ip"
server_port = 17000
token = 123456

[desk]
type = tcp
local_ip = 127.0.0.1
local_port = 3389
remote_port = 43389

Logs

客户端连接时超时,因为服务端没有监听IPV4 所以出现超时

2023/01/02 11:08:06 [W] [service.go:133] login to server failed: dial tcp "my server ip":17000: i/o timeout
dial tcp "my server ip":17000: i/o timeout

Steps to reproduce

  1. 因为这个现象只在我这个环境下产生,所以无法确定是否能还原此问题

...

Affected area

  • Docs
  • Installation
  • Performance and Scalability
  • Security
  • User Experience
  • Test and Release
  • Developer Infrastructure
  • Client Plugin
  • Server Plugin
  • Extensions
  • Others
Originally created by @fschenkun22 on GitHub (Jan 2, 2023). Original GitHub issue: https://github.com/fatedier/frp/issues/3235 ### Bug Description 服务器配置如下: ``` [common] bind_port = 17000 token = 123456 ``` 使用Linux 命令 netstat -ant 查看端口占用情况 ``` [root@first ~]# netstat -ant Active Internet connections (servers and established) Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN tcp 0 0 172.24.209.225:36876 100.100.15.4:443 TIME_WAIT tcp6 0 0 ::1:25 :::* LISTEN tcp6 0 0 :::17000 :::* LISTEN ``` 只能看到监听了tcp6的端口 ,但是ipv4的默认没有监听,所以所有客户端都无法进行连接。 文档中没有发现对应监听IPV4 或者 IPV6 的配置项 ### frpc Version 0.46.0 ### frps Version 0.46.0 ### System Architecture linux/amd64 ;Linux first 3.10.0-1160.71.1.el7.x86_64 #1 SMP Tue Jun 28 15:37:28 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux ### Configurations server端配置: ``` [common] bind_port = 17000 ``` 客户端配置: ``` [common] server_addr = "my server ip" server_port = 17000 token = 123456 [desk] type = tcp local_ip = 127.0.0.1 local_port = 3389 remote_port = 43389 ``` ### Logs 客户端连接时超时,因为服务端没有监听IPV4 所以出现超时 ``` 2023/01/02 11:08:06 [W] [service.go:133] login to server failed: dial tcp "my server ip":17000: i/o timeout dial tcp "my server ip":17000: i/o timeout ``` ### Steps to reproduce 1. 因为这个现象只在我这个环境下产生,所以无法确定是否能还原此问题 2. 3. ... ### Affected area - [ ] Docs - [ ] Installation - [ ] Performance and Scalability - [ ] Security - [ ] User Experience - [ ] Test and Release - [ ] Developer Infrastructure - [ ] Client Plugin - [ ] Server Plugin - [ ] Extensions - [X] Others
Author
Owner

@superzjg commented on GitHub (Jan 2, 2023):

日志信息中出现的"my server ip"字样,我感到很困惑,能解释一下吗?猜测日志信息如果你贴上来没有进行修改,那么配置的server_addr = "my server ip"并不是你为了暴露隐私而改的,而是就是这样设置的(那么肯定连不上)。

<!-- gh-comment-id:1368959017 --> @superzjg commented on GitHub (Jan 2, 2023): 日志信息中出现的"my server ip"字样,我感到很困惑,能解释一下吗?猜测日志信息如果你贴上来没有进行修改,那么配置的server_addr = "my server ip"并不是你为了暴露隐私而改的,而是就是这样设置的(那么肯定连不上)。
Author
Owner

@fschenkun22 commented on GitHub (Jan 3, 2023):

就是隐私 “my server ip” 替代了我现在真实ip 加了引号

<!-- gh-comment-id:1369408190 --> @fschenkun22 commented on GitHub (Jan 3, 2023): > 就是隐私 “my server ip” 替代了我现在真实ip 加了引号
Author
Owner

@superzjg commented on GitHub (Jan 3, 2023):

netstat -ant

就是隐私 “my server ip” 替代了我现在真实ip 加了引号

我也用命令netstat -ant看了,确实跟你说的情况一致,只有:::54235 LISTEN,但是我的frpc可以通过ipv4的54235端口连接,连接以后再次使用命令可看到有一个格式为::ffff:175.0.XX.XX:54235 ESTABLISHED状态的连接,这种格式有点特殊,其中175.0.XX.XX为ipv4地址。并且另外的服务,比如frps的仪表盘端口和filebrowser的监听也是同样的显示,但是平时使用都是ipv4连接。所以不能以此命令显示的为准。

<!-- gh-comment-id:1369471452 --> @superzjg commented on GitHub (Jan 3, 2023): > netstat -ant > > > > > 就是隐私 “my server ip” 替代了我现在真实ip 加了引号 我也用命令netstat -ant看了,确实跟你说的情况一致,只有:::54235 LISTEN,但是我的frpc可以通过ipv4的54235端口连接,连接以后再次使用命令可看到有一个格式为::ffff:175.0.XX.XX:54235 ESTABLISHED状态的连接,这种格式有点特殊,其中175.0.XX.XX为ipv4地址。并且另外的服务,比如frps的仪表盘端口和filebrowser的监听也是同样的显示,但是平时使用都是ipv4连接。所以不能以此命令显示的为准。
Author
Owner

@Becods commented on GitHub (Jan 5, 2023):

尝试将net.ipv6.bindv6only设置为0

通常情况下 go 绑定的 tcp6ipv6ipv4 都可以被访问到的

https://github.com/nodejs/node/issues/9390

https://stackoverflow.com/questions/20657650/socket-listener-for-ipv6-and-ipv4

<!-- gh-comment-id:1372084876 --> @Becods commented on GitHub (Jan 5, 2023): 尝试将`net.ipv6.bindv6only`设置为`0` 通常情况下 `go` 绑定的 `tcp6` 是 `ipv6` 和 `ipv4` 都可以被访问到的 https://github.com/nodejs/node/issues/9390 https://stackoverflow.com/questions/20657650/socket-listener-for-ipv6-and-ipv4
Author
Owner

@cinling commented on GitHub (Feb 11, 2023):

以前我也遇到过类似的情况,我碰到的原因是服务器的防火墙或网关禁止这个端口的访问,可以尝试开放端口或关闭防火墙来解决
原因并不是因为 frps 只监听 ipv6(tcp6)导致的,而是因为端口无法访问,显示 tcp6,用ipv4的地址也是可以连接的

希望可以帮到其他人

<!-- gh-comment-id:1426588287 --> @cinling commented on GitHub (Feb 11, 2023): 以前我也遇到过类似的情况,我碰到的原因是服务器的防火墙或网关禁止这个端口的访问,可以尝试开放端口或关闭防火墙来解决 原因并不是因为 frps 只监听 ipv6(tcp6)导致的,而是因为端口无法访问,显示 tcp6,用ipv4的地址也是可以连接的 希望可以帮到其他人
Author
Owner

@crystal0913 commented on GitHub (Jan 6, 2025):

开放一下端口试试:

firewall-cmd --permanent --zone=public --add-port=<your_bind_port >/tcp
systemctl reload firewalld
<!-- gh-comment-id:2573053480 --> @crystal0913 commented on GitHub (Jan 6, 2025): 开放一下端口试试: ``` firewall-cmd --permanent --zone=public --add-port=<your_bind_port >/tcp systemctl reload firewalld ```
Author
Owner

@cinling commented on GitHub (Jan 6, 2025):

这是来自QQ邮箱的假期自动回复邮件。
 
我也许不在,但我回尽快回复你的

<!-- gh-comment-id:2573054275 --> @cinling commented on GitHub (Jan 6, 2025): 这是来自QQ邮箱的假期自动回复邮件。   我也许不在,但我回尽快回复你的
Author
Owner

@linQian99 commented on GitHub (Jan 9, 2025):

我是发现萌新的我不知道云服务还要自己加规则允许某个端口....

<!-- gh-comment-id:2579238566 --> @linQian99 commented on GitHub (Jan 9, 2025): 我是发现萌新的我不知道云服务还要自己加规则允许某个端口....
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#2598
No description provided.