linux中查看防火墙状态
时间: 2023-09-28 07:11:19 浏览: 147
在Linux中,可以通过以下命令查看防火墙状态:
1. 查看iptables状态:
```bash
sudo iptables -L
```
如果返回以下信息,则说明iptables已经启用:
```
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
```
2. 查看firewalld状态:
```bash
sudo systemctl status firewalld
```
如果返回以下信息,则说明firewalld已经启用:
```
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2021-11-15 10:53:58 CST; 1 day 4h ago
Docs: man:firewalld(1)
Main PID: 1112 (firewalld)
Tasks: 2 (limit: 26213)
Memory: 18.5M
CGroup: /system.slice/firewalld.service
└─1112 /usr/bin/python3 -Es /usr/sbin/firewalld --nofork --nopid
Nov 15 10:53:58 localhost.localdomain systemd[1]: Starting firewalld - dynamic firewall daemon...
Nov 15 10:53:58 localhost.localdomain systemd[1]: Started firewalld - dynamic firewall daemon.
```
注意:上述命令需要在root权限下运行。
阅读全文