1.开启firewall服务
systemctl start firewalld
2.关闭firewall服务
systemctl stop firewalld
3.移除firewall服务
systemctl disable firewalld
4.查看firewall状态
systemctl status firewalld
5.显示网络接口ens160的对应区域
firewall-cmd --get-zone-of-interface=ens160
public #说明ens160的区域是public
6.开放指定端口
firewall-cmd --zone=public --add-port=80/tcp --permanent
7.批量开放端口
firewall-cmd --zone=public --add-port=30000-30050/tcp --permanent
8.对指定ip开放指定端口
firewall-cmd --permanent --add-rich-rule="rule family="ipv4" source address="ip地址" port protocol="tcp" port="端口" accept"
9.对指定ip开放所有端口
firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="ip地址" accept'
10.拒绝指定ip访问指定端口
firewall-cmd --permanent --add-rich-rule="rule family="ipv4" source address="ip地址" port protocol="tcp" port="端口" reject"
11.禁用指定端口
firewall-cmd --zone=public --remove-port=80/tcp --permanent
12.将80端口流量转发到8080端口
firewall-cmd --add-forward-port=port=80:proto=tcp:toport=8080
13.将80端口流量转发到192.168.1.1
firewall-cmd --add-forward-port=proto=80:proto=tcp:toaddr=192.168.1.1
14.将80端口流量转发到192.168.1.1的8080端口
firewall-cmd --add-forward-port=proto=80:proto=tcp:toaddr=192.168.1.1:toport=8080
15.重载防火墙配置
firewall-cmd --reload
16.查看所有开放得端口
firewall-cmd --list-ports
17.查看防火墙所有规则
iptables -L -n