在 CentOS 中,防火墙服务通常是 firewalld(CentOS 7 及以后),也可能是 iptables(老版本)。下面分别说明如何关闭防火墙。
systemctl status firewalld
systemctl stop firewalld
systemctl disable firewalld
✅ 验证是否已关闭:
systemctl status firewalld
显示为 inactive (dead) 即表示已关闭。
service iptables stop
chkconfig iptables off
关闭服务后,仍建议检查规则是否已清空:
iptables -L
如果还有规则,可清空(谨慎操作):
iptables -F
firewall-cmd --permanent --add-port=80/tcp
firewall-cmd --reload
如果你能告诉我:
cat /etc/centos-release)我可以给你更合适、更安全的方案 ✅