百分百源码网-让建站变得如此简单! 登录 注册 签到领金币!

主页 | 如何升级VIP | TAG标签

当前位置: 主页>网站教程>服务器> FTP连接错误:Failed to retrieve directory listing 解决办法
分享文章到:

FTP连接错误:Failed to retrieve directory listing 解决办法

发布时间:01/15 来源: 浏览: 关键词:
用 FillaZilla 客户端连接 vsftp 软件建立了FTP服务器时,出现错误“Failed to retrieve directory listing”,以下是问题解决办法。

在服务器上用vsftp软件建立了FTP服务,但是在使用FillaZilla客户端连接该FTP时,却出现了如下的错误信息服务:

 代码如下
Status:    Resolving address of smilejay.com
Status:    Connecting to 192.3.170.172:21...
Status:    Connection established, waiting for welcome message...
Response:    220 (vsFTPd 2.2.2)
Command:    USER anonymous
Response:    331 Please specify the password.
Command:    PASS **************
Response:    230 Login successful.
Command:    SYST
Response:    215 UNIX Type: L8
Command:    FEAT
Response:    211-Features:
Response:     EPRT
Response:     EPSV
Response:     MDTM
Response:     PASV
Response:     REST STREAM
Response:     SIZE
Response:     TVFS
Response:     UTF8
Response:    211 End
Command:    OPTS UTF8 ON
Response:    200 Always in UTF8 mode.
Status:    Connected
Status:    Retrieving directory listing...
Command:    PWD
Response:    257 "/"
Command:    TYPE I
Response:    200 Switching to Binary mode.
Command:    PAS
Response:    227 Entering Passive Mode (192,3,170,172,132,153).
Command:    LIST
Error:    Connection timed out
Error:    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=9900
pasv_max_port=9903
port_enable=YES   # default NO. When enabled, active mode connects are allowed.


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

打赏

打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,你说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

百分百源码网 建议打赏1~10元,土豪随意,感谢您的阅读!

共有38人阅读,期待你的评论!发表评论
昵称: 网址: 验证码: 点击我更换图片
最新评论

本文标签

广告赞助

能出一分力是一分吧!

订阅获得更多模板

本文标签

广告赞助

订阅获得更多模板