1、查看已开放的端口 ; firewall-cmd –list-ports
2、 查看端口是否被占用 ; netstat -tunpl | grep “端口”
3、开放单个端口(开放后需要要重启防火墙才生效) ;
firewall-cmd –zone=public –add-port=8080/tcp –permanent
#(–permanent 为永久生效,不加为单次有效(重启失效))
4、开放多个端口(开放后需要要重启防火墙才生效)
firewall-cmd –zone=public –add-port=20000-29999/tcp –permanent
#(–permanent 为永久生效,不加为单次有效(重启失效))
5、关闭端口(关闭后需要要重启防火墙才生效)
firewall-cmd –zone=public –remove-port=8080/tcp –permanent
6、查看端口是否打开 ; firewall-cmd –zone= public –query-port=80/tcp
7、查看防火墙状态 ; systemctl status firewalld
8、开启防火墙 ; systemctl start firewalld
9、停止防火墙 ; systemctl stop firewalld
10、重启防火墙 ; systemctl restart firewalld
11、设置开机启动防火墙 ; systemctl enable firewalld
12、查看防火墙设置开机自启是否成功 ; systemctl is-enabled firewalld;echo $?
13、 禁止防火墙开机启动 ; systemctl disable firewalld