在 CentOS 中,防火墙一般使用 firewalld(CentOS 7 及以后),也可能使用 iptables(旧版本或自定义环境)。下面分别说明如何查看规则。
systemctl status firewalld
或
firewall-cmd --state
firewall-cmd --list-all
firewall-cmd --zone=public --list-all
firewall-cmd --list-services
firewall-cmd --list-ports
firewall-cmd --list-rich-rules
firewall-cmd --list-all --permanent
iptables -L -n -v
iptables -t nat -L -n -v
iptables -L -n -v --line-numbers
systemctl start firewalld
systemctl enable firewalld
systemctl stop firewalld
systemctl disable firewalld
yum install iptables-services
systemctl start iptables
如果你愿意,可以告诉我:
cat /etc/redhat-release)我可以给你更精确的命令。