FTP连接出现:Failed to retrieve directory listing

想将一些博客上面的配置信息下载到本地来,所以为了方便,就临时用vsftp软件建立了FTP服务。不过,在使用FillaZilla客户端连接该FTP时,却出现了如下的错误信息:

Status:Resolving address of smilejay.comStatus:Connecting to 192.3.170.172:21...Status:Connection established, waiting for welcome message...Response:220 (vsFTPd 2.2.2)Command:USER anonymousResponse:331 Please specify the password.Command:PASS **************Response:230 Login successful.Command:SYSTResponse:215 UNIX Type: L8Command:FEATResponse:211-Features:Response: EPRTResponse: EPSVResponse: MDTMResponse: PASVResponse: REST STREAMResponse: SIZEResponse: TVFSResponse: UTF8Response:211 EndCommand:OPTS UTF8 ONResponse:200 Always in UTF8 mode.Status:ConnectedStatus:Retrieving directory listing...Command:PWDResponse:257 "/"Command:TYPE IResponse:200 Switching to Binary mode.Command:PASResponse:227 Entering Passive Mode (192,3,170,172,132,153).Command:LISTError:Connection timed outError:Failed to retrieve directory listing

简单排查原因,发现FTP 21端口也打开了的,防火墙也打开对TCP 21端口的访问,登录权限也是配置好了的。后来,将iptables防火前关闭后,就可以正常了使用了。但是,为什么呢?

在服务器端用 watch netstat -tnl 命令查看网络连接情况,然后用FileZilla去连接FTP,会看到某个时刻(其实是发送了PASV命令后),服务器端会看到多了一个奇怪的IP端口连接,连接好后就消失了。其实,这是FTP passive mode 和 active mode 的区别(不细说了看后面的参考资料吧),然后FileZilla默认使用的是passive mode(当然自己也可以去“设置”中更改)。

当然,我前面说将iptables关闭了,我也想重新把iptables重新启用,那么怎么设置访问哪个端口的规则呢?当使用passive模式时,FTP服务器端会使用一个TCP端口,可通过下面的来配置:

pasv_enable=YES  # default YES. When enabled, passive mode connects are allowed.pasv_min_port=9900pasv_max_port=9903port_enable=YES   # default NO. When enabled, active mode connects are allowed.

然后将9900、9901、9902、9903等4个端口的访问权限都在iptables中打开即可。

参考资料:

http://en.wikipedia.org/wiki/File_Transfer_Protocol

http://www.centos.org/docs/rhel-rg-en-3/s1-ftp-vsftpd-conf.html

http://stackoverflow.com/questions/4723023/vsftpd-error-listing-directories

Original article: FTP连接出现:Failed to retrieve directory listing

©2015 笑遍世界. All Rights Reserved.

勇于接受自己的失败,告诉自己,这就是自己的现实,

FTP连接出现:Failed to retrieve directory listing

相关文章:

你感兴趣的文章:

标签云: