在 CentOS 中,防火墙的查看方式取决于系统使用的防火墙服务。CentOS 7 及以后默认使用 firewalld,而 CentOS 6 及更早版本使用 iptables。下面分别说明。
systemctl status firewalld
或
firewall-cmd --state
firewall-cmd --list-all
示例输出:
public (active)
target: default
interfaces: eth0
sources:
services: ssh dhcpv6-client
ports:
protocols:
masquerade: no
forward-ports:
icmp-blocks:
rich rules:
firewall-cmd --list-all-zones
firewall-cmd --list-services
firewall-cmd --list-ports
systemctl is-enabled firewalld
service iptables status
iptables -L -n -v
iptables -t nat -L -n -v
systemctl status firewalld
active (running) → 使用 firewalldnot found 或 inactive,再看:systemctl status iptables
systemctl stop firewalld
systemctl disable firewalld
firewall-cmd --reload
如果你愿意,可以告诉我:
cat /etc/centos-release)我可以给你更精确的命令或排错步骤。