在Linux系统上配置FTP服务器的防火墙规则,通常需要使用iptables或firewalld这样的工具。以下是使用这两种工具的简要步骤:
sudo iptables -L
sudo iptables -A INPUT -p tcp --dport 21 -j ACCEPT
sudo iptables -A INPUT -p tcp --dport 20 -j ACCEPT
sudo iptables -A INPUT -p tcp --dport 30000:31000 -j ACCEPT
sudo iptables-save /etc/iptables/rules.v4
sudo sh -c "iptables-save /etc/iptables/rules.v4 > /etc/network/if-pre-up.d/iptables"
sudo chmod +x /etc/network/if-pre-up.d/iptables
sudo apt-get install firewalld
sudo yum install firewalld
sudo systemctl start firewalld
sudo systemctl enable firewalld
sudo firewall-cmd --permanent --add-port=21/tcp
sudo firewall-cmd --permanent --add-port=20/tcp
sudo firewall-cmd --permanent --add-port=30000-31000/tcp
sudo firewall-cmd --reload
sudo firewall-cmd --list-all
请注意,以上命令可能需要root权限才能执行。请根据实际情况调整端口号和IP地址。在配置防火墙规则之前,请确保了解每个命令的作用,以免意外阻止合法的网络流量。建议在修改防火墙规则之前备份原有的规则,以便在出现问题时能够恢复。