fatedier / frp

A fast reverse proxy to help you expose a local server behind a NAT or firewall to the internet.
Apache License 2.0
84.97k stars 13.19k forks source link

frps能否强制只监听ipv4端口 #452

Closed iceking2001 closed 6 years ago

iceking2001 commented 7 years ago

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)

fatedier commented 7 years ago

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

qingyuan0o0 commented 6 years ago

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

qingyuan0o0 commented 6 years ago

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

xiahuaijia commented 6 years ago

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

leiwenchang commented 5 years ago

阿里云的安全组只有IPV4,没有IPV6,所以监听IPV6的:::地址无法开放出外网。测试通过局域网是可以访问,但是安全组没办法通过。

LiuGaoyong commented 5 years ago

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

hao222 commented 4 years ago

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

RenJunFeng commented 3 years ago

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

Waterkin commented 2 years ago

同无法解决 2022

zhjou commented 2 years ago

ubuntu 20.04 LTS, bind_addr = 0.0.0.0 还是不行

gldsly commented 1 year ago

腾讯云服务器也发现这个问题了。不知道为啥在云服务器上访问 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 
netfun2000 commented 1 year ago

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

VCE1 commented 1 year ago

我在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  

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

shuguang101 commented 4 months ago

刚刚也遇到了这个问题,调查了一下,是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

xingon commented 3 months ago

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