温馨提示×

centos防火墙怎么查状态

小樊
51
2026-09-30 00:20:05
栏目: 智能运维

在 CentOS 中,防火墙一般是 firewalld(CentOS 7 及以上),也可以用 iptables。下面按常见情况说明:


一、CentOS 7 / 8 / Stream(使用 firewalld)

1️⃣ 查看防火墙状态

systemctl status firewalld

或简写:

firewall-cmd --state
  • running:防火墙正在运行
  • not running:防火墙未运行

2️⃣ 查看是否开机自启

systemctl is-enabled firewalld

二、CentOS 6 及更早(使用 iptables)

查看 iptables 状态

service iptables status

或:

/etc/init.d/iptables status

三、查看防火墙规则(firewalld)

firewall-cmd --list-all

查看已开放端口:

firewall-cmd --list-ports

查看已开放服务:

firewall-cmd --list-services

四、确认当前用的是哪种防火墙

systemctl status firewalld
systemctl status iptables

哪个是 active (running) 就是用哪个。


如果你是想 看端口是否通 / 是否被防火墙拦,也可以告诉我具体场景(如:80、3306、SSH 连不上),我可以一步步帮你查。

0 踩