Search Docs
1dnf install firewalld
1firewall-cmd --state
正常情况下,没有启动会显示 not running,启动后会显示 running。
not running
running
1systemctl start firewalld # 启动防火墙 2systemctl enable firewalld # 设置防火墙开机启动 3systemctl reload firewalld # 重新加载防火墙配置
1firewall-cmd --list-ports
1firewall-cmd --list-services
1firewall-cmd --list-all
1firewall-cmd --permanent --add-port=<PORT_NUMBER>/tcp 2firewall-cmd --reload # 重新加载防火墙配置 3firewall-cmd --list-ports # 查看开放的端口,验证是否成功
1firewall-cmd --permanent --zone=public --add-port=<PORT_NUMBER>/tcp # 指定区域开放端口
1systemctl stop firewalld 2firewall-cmd --state # 验证是否停止
1systemctl disable firewalld