天天看点

CentOS 7 防火墙的系列操作

 1、开启防火墙(firewall)

systemctl start firewalld      
CentOS 7 防火墙的系列操作

2、查看防火墙(firewall)状态

firewall-cmd --state      
CentOS 7 防火墙的系列操作

3、 停止防火墙(firewall)

systemctl stop firewalld.service      
CentOS 7 防火墙的系列操作

 4、重启防火墙(firewall)

firewall-cmd --reload      
CentOS 7 防火墙的系列操作

 5、开放指定端口

firewall-cmd --zone=public --add-port=3306/tcp --permanent      
CentOS 7 防火墙的系列操作

 命令含义:

--zone #作用域

--add-port=3306/tcp #添加端口,格式为:端口/通讯协议

--permanent #永久生效,没有此参数重启后失效

 6、查看端口号

netstat -ntlp //查看当前所有tcp端口·
netstat -ntulp |grep 3306 //查看所有3306端口使用情况·      
CentOS 7 防火墙的系列操作

 7、禁止firewall开机启动

systemctl disable firewalld.service      
CentOS 7 防火墙的系列操作

继续阅读