227 连接到 vsftpd FTP 服务器时进入被动模式 (0,0,0,0,...)

227 连接到 vsftpd FTP 服务器时进入被动模式 (0,0,0,0,...)

正如标题所述,我无法将 Windows 10 主机连接到 VirtualBox 客户端(Ubuntu 18.04)上的 FTP 服务器。在客户端,vsftpd 服务器运行良好,我可以毫无问题地连接。

因此,我尝试将相关端口转发到主机 (NAT),并尝试通过 FileZilla 连接到服务器。它确实登录了,但始终无法检索目录列表。我尝试停用防火墙,授予文件夹所有访问权限,但没有任何改变。

我读到这可能是被动模式的问题:
运行 Windows 2008 Server R2 x64 的 VirtualBox 客户机的 FTP 文件访问问题

所以我添加了以下几行我的vsftpd.conf

pasv_enable=YES
pasv_min_port=8020
pasv_max_port=8020
port_enable=YES
pasv_address=127.0.0.1

我转发了端口 8020,但现在在 FileZilla 上出现以下错误:

无法建立数据连接:WSAEADDRNOTAVAIL-无法分配请求的地址

FileZilla 的完整响应:

Status: Connecting to 127.0.0.1:2100...
Status: Connection established, waiting for welcome message...
Status: Server does not support non-ASCII characters.
Status: Logged in
Status: Retrieving directory listing...
Command:    PWD
Response:   257 "/home/cakephp" is the current directory
Command:    TYPE I
Response:   200 Switching to Binary mode.
Command:    PASV
Response:   227 Entering Passive Mode (0,0,0,0,31,84).
Command:    LIST
Error:  The data connection could not be established:
WSAEADDRNOTAVAIL - Cannot assign requested address
Error:  Connection timed out after 20 seconds of inactivity
Error:  Failed to retrieve directory listing
Status: Disconnected from server

我对此有点困惑,有人有什么建议吗?提前谢谢


编辑1:
毫无希望地,我也尝试从 Windows 命令提示符进行访问。它确实连接了,但当我进入ls当前文件夹时,出现以下错误:

500 illegal PORT command.
425 use PORT or PASV first.
但我猜这是因为ftp.exe 不支持被动模式

万一有帮助,你可以在这里找到我当前的整个 vsftpd 配置文件。另外,我可以使用 Putty 从主机无缝访问客户 SSH 服务器。

编辑2:
我设置listen_ipv6YES,改为pasv_max_port8030 以增加被动端口数量并转发它们。我从 FileZilla 获得以下日志:

Status:  Connecting to 127.0.0.1:2100...
Status: Connection established, waiting for welcome message...
Status: Server does not support non-ASCII characters.
Status: Logged in
Status: Retrieving directory listing...
Command:    PWD
Response:   257 "/home/cakephp" is the current directory
Command:    TYPE I
Response:   200 Switching to Binary mode.
Command:    PASV
Response:   227 Entering Passive Mode (0,0,0,0,31,90).
Command:    LIST
Error:  The data connection could not be established: WSAEADDRNOTAVAIL - Cannot assign requested address
Error:  Connection timed out after 20 seconds of inactivity
Error:  Failed to retrieve directory listing

答案1

响应:227 进入被动模式 (0,0,0,0,31,84)。

0,0,0,0很可能是由于 vsftpd 中的一个已知错误造成的。

如果是这种情况,要解决此问题,请确保服务器不监听 IPv6 地址:

listen_ipv6=NO
listen=YES

有关详细信息,请参阅 Server Fault 上的类似问题:
即使 pasv_address 正确,Vsftpd 也会使用 0,0,0,0 地址进行被动回复

相关内容