问题描述

  • 使用ftp命令测试发现,可以正常登录,但不能使用lsdir等命令
PS C:\Users\dadei> ftp 192.168.0.15
连接到 192.168.0.15。
220 Welcome to lmes FTP service.
200 Always in UTF8 mode.
用户(192.168.0.15:(none)): dduan
331 Please specify the password.
密码:
230 Login successful.
ftp> ls
200 PORT command successful. Consider using PASV.
425 Failed to establish connection.

问题原因

200 PORT command successful. Consider using PASV.
425 Failed to establish connection.

提示信息可以知道,主要问题在端口被防火墙控住

解决办法

CentOS、RedHat

  • 修改/etc/selinux/config文件中的SELINUX="为disabled",然后重启
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of three values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected.
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted

Ubuntu

  • /etc/vsftpd/vsftpd.conf添加如下内容
# 开启被动模式
pasv_enable=YES
# 被动模式最小端口
pasv_min_port=6000
# 被动模式最大端口
pasv_max_port=7000
  • 将6000-7000端口也写入到iptables中白名单中
sudo iptables -A INPUT -p tcp --dport 6000:7000 -j ACCEPT
Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐