CentOS 防火墙(通常是 firewalld)无法启动,常见原因和排查方法如下:
CentOS 7 及以后默认是 firewalld
CentOS 6 及以前是 iptables
systemctl status firewalld
rpm -q firewalld
若未安装:
yum install firewalld -y
systemctl start firewalld
systemctl is-enabled firewalld
若为 disabled:
systemctl enable firewalld
systemctl start firewalld
如果系统还在跑 iptables:
systemctl status iptables
解决:
systemctl stop iptables
systemctl disable iptables
systemctl start firewalld
查看错误:
systemctl start firewalld
journalctl -xe
常见错误:
/etc/firewalld/ 文件损坏可重置:
mv /etc/firewalld /etc/firewalld.bak
systemctl start firewalld
报错示例:
Failed to connect to D-Bus
解决:
yum install dbus
systemctl start dbus
getenforce
若为 Enforcing,可临时测试:
setenforce 0
systemctl start firewalld
systemctl status firewalld
journalctl -xe
firewall-cmd --state
如果你愿意,可以把 具体报错信息 或 journalctl -xe 的输出贴出来,我可以帮你精准定位原因。