centos7 防火墙端口开启和关闭及查看
一、防火墙的开启、关闭、禁用命令
(1)设置开机启用防火墙:systemctl enable firewalld.service
(2)设置开机禁用防火墙:systemctl disable firewalld.service
(3)启动防火墙:systemctl start firewalld
(4)关闭防火墙:systemctl stop firewalld
(5)检查防火墙状态:systemctl status firewalld
二、配置防火墙端口
防火墙开启某端口:
firewall-cmd --zone=public --add-port=8888/tcp --permanent
防火墙关闭某端口:
firewall-cmd --zone=public --remove-port=8888/tcp --permanent
防火墙查看某个端口状态:
firewall-cmd --query-port=8888/tcp
查看已经开放的端口:
firewall-cmd --list-ports
重启防火墙:
firewall-cmd --reload
关闭防火墙:
systemctl stop firewalld.service
开启防火墙:
systemctl start firewalld.service
设置开机自启
systemctl enable firewalld.service
设置开启不自启
systemctl disable firewalld.service