在 CentOS 中,防火墙通常是 firewalld(CentOS 7 及以上)。下面按常见情况说明:
systemctl stop firewalld
systemctl disable firewalld
systemctl status firewalld
systemctl start firewalld
systemctl enable firewalld
service iptables stop
chkconfig iptables off
firewall-cmd --state
not running 表示已停止⚠️ 生产环境不建议直接关闭防火墙
更推荐做法是放通需要的端口,例如:
firewall-cmd --permanent --add-port=80/tcp
firewall-cmd --reload
如果你能告诉我 CentOS 版本号 或 是想临时关还是永久关,我可以给你更精确的命令。