1.安装firewalld
yum install firewalld firewalld-config
2.查看防火墙状态
systemctl status firewalld
Active: active (running) 表示开启
Active: inactive (dead) 表示关闭
3. 启动防火墙
systemctl start firewalld.service
4.重启防火墙
firewall-cmd --reload 或者 service firewalld restart
5.禁用防火墙
systemctl stop firewalld
6.设置开机启动
systemctl enable firewalld
7.停止并禁用开机启动
systemctl disable firewalld
8.开启防火墙后开放指定端口,例如22
firewall-cmd --zone=public --add-port=22/tcp --permanent
--permanent永久生效,没有此参数防火墙重启便失效
9.关闭之前开放的指定端口
firewall-cmd --zone=public --remove-port=22/tcp --permanent
10.查看端口列表
firewall-cmd --permanent --list-port