1. 查看防火墙

  1. systemctl status firewalld # 查看防火墙状态, 是开启还是关闭

通过执行上面的命令,执行结果,绿色字体 active( running) 表示系统防火墙开启状态,如下图所示:
image.png
通过 iptables -L -n 查看防火墙规则, -n 表示不将 ip 解析成域名, 查看防火墙规则情况,防火墙详情信息。如下图所示:
image.png

2. 关闭防火墙

2.1 临时关闭

执行 systemctl stop firewalld 临时关闭防火墙, 重启服务后会失效。关闭后,查看防火墙状态已经不在是 actived (running) 状态了。
image.png

2.2 临时开启

执行 systemctl start firewalld 临时关闭防火墙, 重启服务后会失效。关闭后,查看防火墙状态恢复了 actived (running) 状态了。
image.png

2.3 永久关闭

执行 systemctl disable firewalld永久关不防火墙,需重启后生效。可以通过 systemctl is-enabled firewalld 查看防火墙是否为永久关闭或打开 如下图所示:
image.png
重启之后,查看防火墙状态,如下图所示:
image.png

2.4 永久启用

执行 systemctl enabled firewalld 永久开启防火墙。systemctl is-enabled firewalld 查看防火墙是否 永久开启和关闭。
image.png

3. 其他

  1. systemctl # 列出所有的系统服务
  2. systemctl list-units # 列出所有的启动 unit
  3. systemctl list-units --type service # 列出类型为 .service 的已经启动的 unit
  4. systemctl is-enabled sshd # 查看开机启动状态

执行 systemctl 后,查看所有的服务信息,如下图所示:
image.png

附录

创作不易,欢迎打赏。你的支持,是我持续创作的动力哦。如果文章表述不清或错误,欢迎大家留言。我会及时反馈给大家,希望帮助到大家。

打赏二维码.png