大老张学编程 2020-05-09
1, 查看防火墙状态:
firewall-cmd --state
systemctl status firewalld.service
2, 开启防火墙:
systemctl start firewalld.service
3,设置开机自启:
systemctl enable firewalld.service
4, 重启防火墙:
systemctl restart firewalld.service
如果上面命令执行超时,用下面的试试
firewall-cmd --reload
5, 查看防火墙设置开机自启是否成功:
systemctl is-enabled firewalld.service;echo $?
6,关闭防火墙:
systemctl stop firewalld.service
7,开端口命令:
打开单个端口:firewall-cmd --zone=public --add-port=80/tcp --permanent
打开多个端口:firewall-cmd --zone=public --add-port=20000-29999/tcp --permanent
--permanent 为永久生效,不加为单次有效(重启失效)
8,查看开启端口:
netstat -ntlp 或:firewall-cmd --list-ports
9,关闭端口命令:
firewall-cmd --zone= public --remove-port=80/tcp --permanent
10、查看端口是否打开
firewall-cmd --zone= public --query-port=80/tcp