linux-centos 7 防火墙开启、关闭、状态查看操作命令

1、通过systemctl status firewalld查看firewalld状态,发现当前是dead状态,即防火墙未开启。
[root@centos7 ~]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
Active: inactive (dead) //防火墙关闭状态
[root@centos7 ~]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
Active: active (running) since Thu 2020-11-05 08:14:28 CST; 3s ago
Docs: man:firewalld(1) //防火墙开启状态

2、开启防火墙、关闭防火墙、查看防火墙状态
[root@centos7 ~]# systemctl start firewalld //开启防火墙

[root@centos7 ~]# firewall-cmd --state //查看防火墙状态
running //表示运行状态

[root@centos7 ~]# systemctl stop firewalld //关闭防火墙

[root@centos7 ~]# firewall-cmd --state //查看防火墙状态
not running //表示停用状态

[root@centos7 ~]# firewall-cmd --reload //重启动防火墙
success

systemctl disable firewalld.service //禁止firewall开机启动,

3、开放端口 如80
开放端口
firewall-cmd --zone=public --add-port=80/tcp --permanent
重新载入
firewall-cmd --reload
查看端口
firewall-cmd --zone=public --query-port=80/tcp
删除端口
firewall-cmd --zone=public --remove-port=80/tcp --permanent

你可能感兴趣的:(linux-centos,linux)