vsFTPd 和 iptables - 如何在 CentOS 5.5 中配置它们?

yeg*_*256 4 centos ftp vsftpd

我在 CentOS 5.5 中的两台服务器上安装了 vsFTPd ,并将此规则添加到它们的iptables

-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 21 -j ACCEPT
Run Code Online (Sandbox Code Playgroud)

看起来这还不够,因为当我尝试将文件从一台服务器上传到另一台服务器时,我得到了以下结果(IP 地址被屏蔽):

# ftp 99.99.99.99
Connected to 99.99.99.99 (99.99.99.99).
220 (vsFTPd 2.0.5)
Name (99.99.99.99:root): vinny
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> ls
227 Entering Passive Mode (99,99,99,99,107,74)
ftp: connect: No route to host
Run Code Online (Sandbox Code Playgroud)

我在网上找到了几篇关于我必须添加到的第二条规则的文章iptables,但我没有找到正确的语法。能否请你帮忙?

附:我默认安装了 vsFTPd /etc/vsftpd/vsftpd.conf,如果可能的话,我不想更改它的配置文件 ( ) 中的任何内容。

PiL*_*PiL 6

编辑 /etc/sysconfig/iptables-config 并添加以下行:

IPTABLES_MODULES="ip_conntrack_ftp"

保存并重启iptables。
那是因为被动模式使用非标准端口进行通信,因此您需要保持 ftp 连接的 trak 和 iptables 将在必要时允许它们。