Netcat (nc6) - 仅限 IPv6 的最小 TCP 服务器和客户端

Netcat (nc6) - 仅限 IPv6 的最小 TCP 服务器和客户端

我正在尝试使用 netcat (或更确切地说 nc6)建立一个基本的仅 IPv6 回显服务器。客户端和服务器都在同一个本地网络中。然而,客户立即退出:


IPv6 服务器:

$ nc6 -6 -vv --continuous --exec cat -l -p 5555
nc6: listening on :: 5555 ...

IPv6 客户端:

$ nc6 -6 -vv fe80::213:33ff:feab:ff5d 5555
nc6: fe80::213:33ff:feab:ff5d (fe80::213:33ff:feab:ff5d) 5555 [5555] open
nc6: using stream socket
nc6: using buffer size of 8192
nc6: error reading from remote: Transport endpoint is not connected
nc6: connection closed (sent 0, rcvd 0)
nc6: readwrite returned -1
nc6: closed local
nc6: closed remote
$ 

有什么问题吗?
我是否应该将服务器配置为仅侦听其接口之一上的传入连接? (如何?)


IPv4 版本工作得很好:

IPv4 服务器:

nc6 -vv --continuous --exec cat -l -p 5555
nc6: listening on :: 5555 ...
nc6: listening on 0.0.0.0 5555 ...
nc6: connect to 192.168.1.35 5555 from xyrobert.local (192.168.1.35) 37928 [37928]
nc6: using stream socket
nc6[7502]: executing 'cat'
nc6[7502]: using buffer size of 8192
nc6[7502]: read 4 bytes from remote
nc6[7502]: wrote 4 bytes to local
nc6[7502]: read 4 bytes from local
nc6[7502]: wrote 4 bytes to remote

IPv4 客户端:

nc6 -vv 192.168.1.35 5555
nc6: kearney.local (192.168.1.35) 5555 [5555] open
nc6: using stream socket
nc6: using buffer size of 8192
Hi!
nc6: read 4 bytes from local
nc6: wrote 4 bytes to remote
nc6: read 4 bytes from remote
Hi!
nc6: wrote 4 bytes to local

答案1

连接到 IPv6 链路本地地址时,您需要指定通过哪个链路到达该地址,如从客户端系统看到的那样。每个链接都使用相同的链接本地地址,因此需要明确告知客户端要使用哪个链接(接口)。因此,如果您要访问的系统是通过eth0客户端系统连接的,则您需要连接到fe80::213:33ff:feab:ff5d%eth0.

使用可路由的 IPv6 地址要容易得多,因为本地路由表将用于确定通过哪个接口发送数据包。

相关内容