安装firewalld 防火墙命令:
yum install firewalld
安装完成,查看防火墙状态为 not running,即未运行,输入命令开启:
查看状态:firewall-cmd --state
或 systemctl status firewalld.service
开启:systemctl start firewalld.service
添加开放端口:
firewall-cmd --zone=public --add-port=12345/tcp --permanent
`
Centos7.9 防火墙相关命令:
查看防火墙状态
systemctl status firewalld.service
打开防火墙
systemctl start firewalld.service
关闭防火墙
systemctl stop firewalld.service
重启防火墙
systemctl restart firewalld.service
查看防火墙已启用的端口:
firewall-cmd –list-ports
开放端口:
firewall-cmd –zone=public –add-port=80/tcp –permanent
关闭端口:
firewall-cmd –zone=public –remove-port=80/tcp –permanent
–permanent:永久生效(如果没有此参数,则只能维持当前服务生命周期内,重新启动后失效)
重启(添加/关闭端口后,需要重启才能生效)
systemctl restart firewalld.service