[GH-ISSUE #452] frps能否强制只监听ipv4端口 #345

Closed
opened 2026-05-05 12:08:44 -06:00 by gitea-mirror · 16 comments
Owner

Originally created by @iceking2001 on GitHub (Sep 4, 2017).
Original GitHub issue: https://github.com/fatedier/frp/issues/452

Issue is only used for submiting bug report and documents typo. If there are same issues or answers can be found in documents, we will close it directly.
(为了节约时间,提高处理问题的效率,不按照格式填写的 issue 将会直接关闭。)

Use the commands below to provide key information from your environment:
You do NOT have to include this information if this is a FEATURE REQUEST

What version of frp are you using (./frpc -v or ./frps -v)?
./frps

What operating system and processor architecture are you using (go env)?
centos 7.3 x64

Configures you used:
frps_full.ini 默认配置

Steps to reproduce the issue:

  1. 启动 ./frps -c ./frps_full.ini
  2. 无法访问 http://[server_ip]:7500
  3. netstat -nap|grep frps 发现监听的是ipv6:
    tcp6 0 0 :::7500 :::* LISTEN 2311/./frps
    tcp6 0 0 :::8080 :::* LISTEN 2311/./frps
    tcp6 0 0 :::7000 :::* LISTEN 2311/./frps
    tcp6 0 0 :::443 :::* LISTEN 2311/./frps
    udp6 0 0 :::7000 :::* 2311/./frps
  4. 配置aliyun主机的ipv6支持也无效。所以,能否强制只监听ipv4端口

Describe the results you received:
无法访问dashboard

Describe the results you expected:

Additional information you deem important (e.g. issue happens only occasionally):

Can you point out what caused this issue (optional)

Originally created by @iceking2001 on GitHub (Sep 4, 2017). Original GitHub issue: https://github.com/fatedier/frp/issues/452 Issue is only used for submiting bug report and documents typo. If there are same issues or answers can be found in documents, we will close it directly. (为了节约时间,提高处理问题的效率,不按照格式填写的 issue 将会直接关闭。) Use the commands below to provide key information from your environment: You do NOT have to include this information if this is a FEATURE REQUEST **What version of frp are you using (./frpc -v or ./frps -v)?** ./frps **What operating system and processor architecture are you using (`go env`)?** centos 7.3 x64 **Configures you used:** frps_full.ini 默认配置 **Steps to reproduce the issue:** 1. 启动 ./frps -c ./frps_full.ini 2. 无法访问 http://[server_ip]:7500 3. netstat -nap|grep frps 发现监听的是ipv6: tcp6 0 0 :::7500 :::* LISTEN 2311/./frps tcp6 0 0 :::8080 :::* LISTEN 2311/./frps tcp6 0 0 :::7000 :::* LISTEN 2311/./frps tcp6 0 0 :::443 :::* LISTEN 2311/./frps udp6 0 0 :::7000 :::* 2311/./frps 4. 配置aliyun主机的ipv6支持也无效。所以,能否强制只监听ipv4端口 **Describe the results you received:** 无法访问dashboard **Describe the results you expected:** **Additional information you deem important (e.g. issue happens only occasionally):** **Can you point out what caused this issue (optional)**
Author
Owner

@fatedier commented on GitHub (Sep 4, 2017):

首先你要确定是否是由于这个原因造成的,还是说是因为其他原因。你要提供推理和分析的结果。

<!-- gh-comment-id:326945950 --> @fatedier commented on GitHub (Sep 4, 2017): 首先你要确定是否是由于这个原因造成的,还是说是因为其他原因。你要提供推理和分析的结果。
Author
Owner

@qingyuan0o0 commented on GitHub (Nov 29, 2017):

我也碰到类似的问题,在ubuntu本地是有ipv6的网络,但是在客户端连接后,在Ubuntu中使用
netstat -an|grep : 发现显示的都是tcp6 udp6,呈现出客户端的连接
frps.ini的设置
[common]
local_ip = 0.0.0.0
bind_port = 7000
客户端配置大致是下图
image
但是显示
image

<!-- gh-comment-id:347767292 --> @qingyuan0o0 commented on GitHub (Nov 29, 2017): 我也碰到类似的问题,在ubuntu本地是有ipv6的网络,但是在客户端连接后,在Ubuntu中使用 netstat -an|grep : 发现显示的都是tcp6 udp6,呈现出客户端的连接 frps.ini的设置 [common] local_ip = 0.0.0.0 bind_port = 7000 客户端配置大致是下图 ![image](https://user-images.githubusercontent.com/18437931/33361360-b95d0b8a-d512-11e7-9d07-c6bfa61af7b9.png) 但是显示 ![image](https://user-images.githubusercontent.com/18437931/33361394-dee67af8-d512-11e7-9913-b7bdb25ce878.png)
Author
Owner

@qingyuan0o0 commented on GitHub (Nov 29, 2017):

额,虽然显示是这样,但是后续测试中发现,居然可以正常访问。。。ipv4的

<!-- gh-comment-id:347768342 --> @qingyuan0o0 commented on GitHub (Nov 29, 2017): 额,虽然显示是这样,但是后续测试中发现,居然可以正常访问。。。ipv4的
Author
Owner

@xiahuaijia commented on GitHub (Jun 21, 2018):

遇到同样问题 ,阿里云主机突然监听ipv6 无法访问

<!-- gh-comment-id:398987903 --> @xiahuaijia commented on GitHub (Jun 21, 2018): 遇到同样问题 ,阿里云主机突然监听ipv6 无法访问
Author
Owner

@LiuGaoyong commented on GitHub (Jul 22, 2019):

所以,这个问题怎么解决??

<!-- gh-comment-id:513649623 --> @LiuGaoyong commented on GitHub (Jul 22, 2019): 所以,这个问题怎么解决??
Author
Owner

@hao222 commented on GitHub (Aug 27, 2020):

腾讯云监听了ipv6,但是我设置放在同一个安全组下的,其他大部分是ipv4 只有mysql是ipv6, 然后本地客户端访问不了,connected refused

<!-- gh-comment-id:681889621 --> @hao222 commented on GitHub (Aug 27, 2020): 腾讯云监听了ipv6,但是我设置放在同一个安全组下的,其他大部分是ipv4 只有mysql是ipv6, 然后本地客户端访问不了,connected refused
Author
Owner

@RenJunFeng commented on GitHub (Oct 12, 2020):

如何解决?我本地运行也是这样,设置了
[common]
bind_addr = 0.0.0.0 也是不行

<!-- gh-comment-id:706887418 --> @RenJunFeng commented on GitHub (Oct 12, 2020): 如何解决?我本地运行也是这样,设置了 [common] bind_addr = 0.0.0.0 也是不行
Author
Owner

@marcuswang6 commented on GitHub (Apr 5, 2022):

同无法解决 2022

<!-- gh-comment-id:1088228493 --> @marcuswang6 commented on GitHub (Apr 5, 2022): 同无法解决 2022
Author
Owner

@zhjou commented on GitHub (May 1, 2022):

ubuntu 20.04 LTS, bind_addr = 0.0.0.0 还是不行

<!-- gh-comment-id:1114282775 --> @zhjou commented on GitHub (May 1, 2022): ubuntu 20.04 LTS, bind_addr = 0.0.0.0 还是不行
Author
Owner

@gldsly commented on GitHub (Nov 29, 2022):

腾讯云服务器也发现这个问题了。不知道为啥在云服务器上访问 127 + frps 监听的端口 全是无数据,然后就 502 错误了

[root@VM-xVO5pN310rIk ~]# netstat -anp | grep frps
tcp6       0      0 :::57709                :::*                    LISTEN      23200/./frps        
tcp6       0      0 :::58096                :::*                    LISTEN      23200/./frps        
tcp6       0      0 :::7000                 :::*                    LISTEN      23200/./frps        
tcp6       0      0 :::50022                :::*                    LISTEN      23200/./frps        
tcp6       0      0 103.175.14.37:50022     101.229.151.233:61677   ESTABLISHED 23200/./frps        
tcp6       0      0 103.175.14.37:7000      223.166.231.179:15322   ESTABLISHED 23200/./frps        
[root@VM-xVO5pN310rIk ~]# 
[root@VM-xVO5pN310rIk ~]# 
[root@VM-xVO5pN310rIk ~]# wget http://127.0.0.1:50022
--2022-11-29 05:29:27--  http://127.0.0.1:50022/
Connecting to 127.0.0.1:50022... connected.
HTTP request sent, awaiting response... No data received.
Retrying.

--2022-11-29 05:29:28--  (try: 2)  http://127.0.0.1:50022/
Connecting to 127.0.0.1:50022... connected.
HTTP request sent, awaiting response... No data received.
Retrying.

--2022-11-29 05:29:30--  (try: 3)  http://127.0.0.1:50022/
Connecting to 127.0.0.1:50022... connected.
HTTP request sent, awaiting response... No data received.
Retrying.

No data received.
Retrying.

^C
[root@VM-xVO5pN310rIk ~]# 

客户端是正常的,配置测试信息如下

local_ip = 127.0.0.1
local_port = 7709
remote_port = 57709
➜  Downloads 
➜  Downloads 
➜  Downloads 
➜  Downloads wget http://127.0.0.1:7709
--2022-11-29 13:31:26--  http://127.0.0.1:7709/
正在连接 127.0.0.1:7709... 已连接。
已发出 HTTP 请求,正在等待回应... 404 Not Found
2022-11-29 13:31:26 错误 404:Not Found。

➜  Downloads 
<!-- gh-comment-id:1330102465 --> @gldsly commented on GitHub (Nov 29, 2022): 腾讯云服务器也发现这个问题了。不知道为啥在云服务器上访问 127 + frps 监听的端口 全是无数据,然后就 502 错误了 ```bash [root@VM-xVO5pN310rIk ~]# netstat -anp | grep frps tcp6 0 0 :::57709 :::* LISTEN 23200/./frps tcp6 0 0 :::58096 :::* LISTEN 23200/./frps tcp6 0 0 :::7000 :::* LISTEN 23200/./frps tcp6 0 0 :::50022 :::* LISTEN 23200/./frps tcp6 0 0 103.175.14.37:50022 101.229.151.233:61677 ESTABLISHED 23200/./frps tcp6 0 0 103.175.14.37:7000 223.166.231.179:15322 ESTABLISHED 23200/./frps [root@VM-xVO5pN310rIk ~]# [root@VM-xVO5pN310rIk ~]# [root@VM-xVO5pN310rIk ~]# wget http://127.0.0.1:50022 --2022-11-29 05:29:27-- http://127.0.0.1:50022/ Connecting to 127.0.0.1:50022... connected. HTTP request sent, awaiting response... No data received. Retrying. --2022-11-29 05:29:28-- (try: 2) http://127.0.0.1:50022/ Connecting to 127.0.0.1:50022... connected. HTTP request sent, awaiting response... No data received. Retrying. --2022-11-29 05:29:30-- (try: 3) http://127.0.0.1:50022/ Connecting to 127.0.0.1:50022... connected. HTTP request sent, awaiting response... No data received. Retrying. No data received. Retrying. ^C [root@VM-xVO5pN310rIk ~]# ``` 客户端是正常的,配置测试信息如下 ```bash local_ip = 127.0.0.1 local_port = 7709 remote_port = 57709 ➜ Downloads ➜ Downloads ➜ Downloads ➜ Downloads wget http://127.0.0.1:7709 --2022-11-29 13:31:26-- http://127.0.0.1:7709/ 正在连接 127.0.0.1:7709... 已连接。 已发出 HTTP 请求,正在等待回应... 404 Not Found 2022-11-29 13:31:26 错误 404:Not Found。 ➜ Downloads ```
Author
Owner

@netfun2000 commented on GitHub (Apr 5, 2023):

今天用阿里云安装frps,同样出现了这个问题。frps显示ipv6
本机可以访问frps端口,外网无法访问。

<!-- gh-comment-id:1497180764 --> @netfun2000 commented on GitHub (Apr 5, 2023): 今天用阿里云安装frps,同样出现了这个问题。frps显示ipv6 本机可以访问frps端口,外网无法访问。
Author
Owner

@VCE1 commented on GitHub (Jul 19, 2023):

我在Ubuntu 20上也遇到了这个问题,尽管我已经在/etc/sysctl.conf中设置了以下内容:

net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1

并且在frps.ini中填写了bind_addr = 0.0.0.0,但是frps仍然监听IPv6地址,

tcp6       0      0 :::25565                :::*                    LISTEN      1626612/frps  

不知道具体的原因,但是能正常访问。

<!-- gh-comment-id:1642452589 --> @VCE1 commented on GitHub (Jul 19, 2023): 我在Ubuntu 20上也遇到了这个问题,尽管我已经在/etc/sysctl.conf中设置了以下内容: ```conf net.ipv6.conf.all.disable_ipv6 = 1 net.ipv6.conf.default.disable_ipv6 = 1 ``` 并且在frps.ini中填写了bind_addr = 0.0.0.0,但是frps仍然监听IPv6地址, ```conf tcp6 0 0 :::25565 :::* LISTEN 1626612/frps ``` 不知道具体的原因,但是能正常访问。
Author
Owner

@shuguang101 commented on GitHub (May 7, 2024):

刚刚也遇到了这个问题,调查了一下,是golang的问题。 golang 0.0.0.0 确实会监听ipv6, 这与nginx,apache等软件的行为并不相同。从直观上来说当用户指定一个ipv4地址时不应该去监听ipv6, 但golang无论是使用0.0.0.0或[::] 都会同时监听ipv4和ipv6, 并且为了backwards compatibility不会对这个行为进行修改。。。。。
https://github.com/golang/go/issues/48723
https://github.com/golang/go/issues/17615

<!-- gh-comment-id:2098224628 --> @shuguang101 commented on GitHub (May 7, 2024): 刚刚也遇到了这个问题,调查了一下,是golang的问题。 golang 0.0.0.0 确实会监听ipv6, 这与nginx,apache等软件的行为并不相同。从直观上来说当用户指定一个ipv4地址时不应该去监听ipv6, 但golang无论是使用0.0.0.0或[::] 都会同时监听ipv4和ipv6, 并且为了backwards compatibility不会对这个行为进行修改。。。。。 https://github.com/golang/go/issues/48723 https://github.com/golang/go/issues/17615
Author
Owner

@xingon commented on GitHub (Jun 30, 2024):

同样的问题啊,Fasttunnel也是这样的,其实就是配置0.0.0.0的时候他默认使用的TCP,应该显式使用TCP4才行,

<!-- gh-comment-id:2198528513 --> @xingon commented on GitHub (Jun 30, 2024): 同样的问题啊,Fasttunnel也是这样的,其实就是配置0.0.0.0的时候他默认使用的TCP,应该显式使用TCP4才行,
Author
Owner

@zasray commented on GitHub (Oct 29, 2024):

腾讯云 2024-10-29,还是这样子!无法解决

<!-- gh-comment-id:2443020971 --> @zasray commented on GitHub (Oct 29, 2024): 腾讯云 2024-10-29,还是这样子!无法解决
Author
Owner

@tomjerrygood commented on GitHub (Feb 18, 2025):

me too。远端fprs服务端在ipv4环境。我在的客户端frpc.ini 配置了
server_addr = Ipv4域名(a.b.c)
bind_address = 0.0.0.0,
本地frpc 运行优先解析ipv6,所以总是不能连接到服务器。
执行
/system/etc/frpc$ /system/etc/frpc/frpc -c /system/etc/frpc/frpc.ini
显示错误
2025/02/18 05:35:48 [W] [service.go:128] login to server failed: dial tcp: lookup a.b.c on [::1]:53: read udp [::1]:42425->[::1]:53: read: connection refused
dial tcp: lookup green86.asuscomm.com on [::1]:53: read udp [::1]:42425->[::1]:53: read: connection refused

服务器域名改为固定ipv4 地址就能连接成功。但是域名是动态的,不能固定IP地址。
希望大佬能否给出强制IPv4的选项

<!-- gh-comment-id:2664656509 --> @tomjerrygood commented on GitHub (Feb 18, 2025): me too。远端fprs服务端在ipv4环境。我在的客户端frpc.ini 配置了 server_addr = Ipv4域名(a.b.c) bind_address = 0.0.0.0, 本地frpc 运行优先解析ipv6,所以总是不能连接到服务器。 执行 /system/etc/frpc$ /system/etc/frpc/frpc -c /system/etc/frpc/frpc.ini 显示错误 2025/02/18 05:35:48 [W] [service.go:128] login to server failed: dial tcp: lookup a.b.c on [::1]:53: read udp [::1]:42425->[::1]:53: read: connection refused dial tcp: lookup green86.asuscomm.com on [::1]:53: read udp [::1]:42425->[::1]:53: read: connection refused 服务器域名改为固定ipv4 地址就能连接成功。但是域名是动态的,不能固定IP地址。 希望大佬能否给出强制IPv4的选项
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#345
No description provided.