centos7操作防火墙

查看防火墙状态

sudo systemctl status firewalld

启动防火墙(重启后失效)

sudo systemctl start firewalld

 

关闭防火墙(重启后失效)

sudo systemctl stop firewalld

 

启动防火墙(持续生效)

sudo systemctl enable firewalld

 

关闭防火墙(持续生效)

sudo systemctl disable firewalld

 

查看所有放通的端口

firewall-cmd--zone=public --list-ports

 

更新防火墙规则

firewall-cmd --reload

 

放通80的TCP端口

firewall-cmd --zone=public --add-port=80/tcp --permanent

 

放通80的UDP端口

firewall-cmd --zone=public --add-port=80/tcp --permanent