在CentOS系统下配置VSFTPD(Very Secure FTP Daemon)的防火墙,通常需要确保FTP服务所需的端口是开放的。VSFTPD默认使用以下端口:
以下是配置防火墙以允许VSFTPD流量的步骤:
CentOS 7及以上版本默认使用firewalld作为防火墙管理工具。如果尚未安装,可以使用以下命令安装:
sudo yum install firewalld
确保firewalld服务已启动并设置为开机自启:
sudo systemctl start firewalld
sudo systemctl enable firewalld
使用firewall-cmd命令开放FTP所需的端口:
sudo firewall-cmd --permanent --add-port=21/tcp
sudo firewall-cmd --permanent --add-port=20/tcp
使更改生效:
sudo firewall-cmd --reload
可以使用以下命令检查端口是否已成功开放:
sudo firewall-cmd --list-all
你应该能在输出中看到开放的端口列表,包括21和20。
如果SELinux处于 enforcing 模式,可能需要配置SELinux策略以允许FTP流量。可以临时将SELinux设置为 permissive 模式来测试:
sudo setenforce 0
如果FTP服务正常工作,可以配置SELinux策略以永久允许FTP流量。编辑SELinux策略文件(例如 /etc/selinux/config),将 SELINUX=enforcing 改为 SELINUX=permissive,然后重启系统。
确保VSFTPD配置文件 /etc/vsftpd/vsftpd.conf 中的设置正确。以下是一些常见的配置项:
listen=YES
listen_ipv6=NO
anonymous_enable=NO
local_enable=YES
write_enable=YES
local_umask=022
dirmessage_enable=YES
xferlog_enable=YES
connect_from_port_20=YES
chroot_local_user=YES
allow_writeable_chroot=YES
使配置生效:
sudo systemctl restart vsftpd
通过以上步骤,你应该能够在CentOS系统下成功配置VSFTPD的防火墙。