Kcptun: 默认监听总是在IPv6的UDP端口上

Created on 28 Jul 2016  ·  10Comments  ·  Source: xtaci/kcptun

以下面范例提供的服务端启动命令来运行服务端,启动后,用telnet连接554端口总是失败,kcptun客户端同样无法连接成功。
./server_linux_amd64 -t "127.0.0.1:8388" -l ":554" -mode fast2
然后用lsof查看进程的端口状况才发现是在IPv6的udp 554端口上侦听,而本人的系统(CentOS 7.1 x64)是禁用IPv6(日常应用不支持)的。
如果在-l参数中用明确的ip地址(例如127.0.0.1),则可以顺利在IPv4的ip和端口上建立侦听,而无论是使用 -l 0:554还是 -l 0.0.0.0:554,都会是在IPv6的udp端口554上建立侦听,不知道该咋办了,在服务端参数中没有找到强制设定通过IPv4连接的开关。
求支持。 :)

IPv6

Most helpful comment

我映像当中,golang 都监听在 ipv6,但是同时支持 ipv4/ipv6,所以这个并不是问题!
验证多次,文档我想不起来了。

https://groups.google.com/forum/#!topic/golang-nuts/F5HE7Eqb6iM

on linux, by default, net.ipv6.bindv6only is 0, so ipv4 packets could also be received from
ipv6 sockets with ipv4-mapped ipv6 address. thus you only need to listen on tcp6 socket
and we can support both ipv4 and ipv6.

All 10 comments

你确定? 应该不是啊, 你把netstat打印出来看看, 还有sysctl net.ipv6.conf.all.disable_ipv6

的确很奇怪的问题呀,我用netstat(没加参数)打印后没有查到-l参数指定的端口。
sysctl net.ipv6.conf.all.disable_ipv6也执行成功了,已经通过多种方式确认过系统中的IPv6已经关闭。但还是无法在正确的协议下侦听,下面是使用lsof -i 后进行过滤的结果,可以看到还是在IPv6下的UDP端口上侦听
server_li 8954 root 3u IPv6 333520 0t0 UDP *:554

如果在 -l参数中指定其他的ip地址(不是默认的空或者0或者0.0.0.0),那么都可以成功在IPv4下建立侦听。
我在两台不同的CentOS 7 x64系统中都是同样的情况。

我也碰到这个问题,怎么样都是监听ipv6的端口。finalspeed也是这个问题

我这里也是只监听在ipv6的端口,我的vps上ipv6是启用的,但是kcptun启动后没有ipv4的端口,这如何破?
lsof -i的结果如下:
server_li 4789 root 3u IPv6 34380 0t0 UDP *:20027

遇到这个问题的朋友们可以去看这个问题中倒数第三层的解决方法,我自己按照该方法已经成功解决了问题。 :)
https://github.com/xtaci/kcptun/issues/102

我映像当中,golang 都监听在 ipv6,但是同时支持 ipv4/ipv6,所以这个并不是问题!
验证多次,文档我想不起来了。

https://groups.google.com/forum/#!topic/golang-nuts/F5HE7Eqb6iM

on linux, by default, net.ipv6.bindv6only is 0, so ipv4 packets could also be received from
ipv6 sockets with ipv4-mapped ipv6 address. thus you only need to listen on tcp6 socket
and we can support both ipv4 and ipv6.

我也发现了,楼上说的应该是对的,我这里再尝试的时候,虽然监听的也是ipv6,但是手机,电脑设置后都能成功连上。所以应该没问题,楼上上各位还有问题的可以用手机或电脑连接试试。

"listen": ":port"当拥有多IP时不能监听所有IPv4的端口,只能用默认的IPv4和IPv6地址连接。
不过为啥"listen": "0.0.0.0:port"也还是不行呢?也只能用默认IPv4地址连接。

个人今天也遇到这个问题,总是开启在udp6上,在ubuntu上不行,centos上正常。之后我是这样操作的。(不知是否是偶然)
echo "kcptun 12345/udp" >>/etc/serivces
其中12345为kcptun的端口。
通过以下进行检查:nc -vuz 127.0.0.1 12345
Connection to 127.0.0.1 12345 port [udp/kcptun] succeeded!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

1563172697 picture 1563172697  ·  5Comments

sosmygirl picture sosmygirl  ·  6Comments

trivita picture trivita  ·  3Comments

raszzh picture raszzh  ·  5Comments

ng-life picture ng-life  ·  5Comments