若防火墙已关闭(通过systemctl stop firewalld或systemctl disable firewalld操作),可通过以下步骤恢复其正常运行:
使用systemctl start firewalld命令启动防火墙服务,执行后防火墙会立即开始工作,允许/拒绝流量基于当前配置。
sudo systemctl start firewalld 若希望系统重启后防火墙仍保持开启状态,需启用开机自启功能:
sudo systemctl enable firewalld 执行后,防火墙会在每次系统启动时自动运行。
通过以下命令确认防火墙是否已成功恢复:
sudo systemctl status firewalld(显示active (running)表示正在运行);sudo firewall-cmd --state(显示running表示防火墙已激活)。sudo systemctl status firewalld sudo firewall-cmd --state iptables -F),需重新配置规则(如开放必要端口),否则防火墙可能仍不允许流量通过;systemctl stop firewalld),调试完成后立即恢复。以上步骤适用于CentOS 7及以上版本(使用firewalld作为默认防火墙工具)。若系统使用旧版iptables,恢复方法需调整(如启动iptables服务),但当前主流版本均以firewalld为主。