#查看状态
shell > systemctl status firewalld
#开机禁用
shell > systemctl disable firewalld
#开机启用
shell > systemctl enable firewalld
#启动
shell > systemctl start firewalld
#关闭
shell > systemctl stop firewalld
使用 firewalld-cmd 配置 firewall
#查看帮助
shell > firewall-cmd --help
#查看版本
shell > firewall-cmd --version
#显示状态
shell > firewall-cmd --state
#查看所有打开的端口
shell > firewall-cmd --zone=public --list-ports
#重新载入配置
shell > firewall-cmd --reload
#查看区域信息
shell > firewall-cmd --get-active-zones
#查看指定接口所属区域
shell > firewall-cmd --get-zone-of-interface=eth0
#拒绝所有包
shell > firewall-cmd --panic-on
#取消拒绝状态
shell > firewall-cmd --panic-off
#查看是否拒绝
shell > firewall-cmd --query-panic
#开放一个对外端口(例子为常用的HTTP 80 端口)
shell > firewall-cmd --zone=public --add-port=80/tcp --permanent (--permanent是否永久生效,否则只是临时的,重启后就失效)
#查看端口状态
shell > firewall-cmd --zone=public --query-port=80/tcp
#删除一个对外端口
shell > firewall-cmd --zone=public --remove-port=80/tcp --permanent
# 检查是否允许伪装IP
shell > firewall-cmd --query-masquerade
# 允许防火墙伪装IP
shell > firewall-cmd --permanent --add-masquerade
# 禁止防火墙伪装IP
shell > firewall-cmd --permanent --remove-masquerade
# 将80端口的流量转发至8080
shell > firewall-cmd --permanent --add-forward-port=port=80:proto=tcp:toport=8080
# 将80端口的流量转发至192.168.0.1
shell > firewall-cmd --permanent --add-forward-port=port=80:proto=tcp:toaddr=192.168.1.0.1
# 将80端口的流量转发至192.168.0.1的8080端口
shell > firewall-cmd --permanent --add-forward-port=port=80:proto=tcp:toaddr=192.168.0.1:toport=8080
# 在防火墙未启动的情况下执行命令
shell > firewall-offline-cmd