查看防火墙状态 linux
时间: 2024-01-06 07:24:48 浏览: 74
浅析linux查看防火墙状态和对外开放的端口状态
5星 · 资源好评率100%
你可以通过以下两种方法来查看Linux防火墙的状态:
1. 使用systemctl命令:
```shell
systemctl status firewalld
```
如果防火墙已关闭,你将会看到类似以下的输出:
```
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
Active: inactive (dead)
Docs: man:firewalld(1)
```
如果防火墙已打开,你将会看到类似以下的输出:
```
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2021-09-20 10:00:00 EDT; 1h ago
Docs: man:firewalld(1)
Main PID: 1234 (firewalld)
Tasks: 2 (limit: 4915)
Memory: 10.0M
CGroup: /system.slice/firewalld.service
└─1234 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid
```
2. 使用service命令:
```shell
service firewalld status
```
如果防火墙已关闭,你将会看到类似以下的输出:
```
firewalld is stopped
```
如果防火墙已打开,你将会看到类似以下的输出:
```
firewalld (pid 1234) is running...
```
阅读全文