如何修复 RHEL/CentOS 7 中的“firewall-cmd:找不到命令”错误
firewall-cmd是firewalld(firewalld守护进程)的命令行前端,它是一个具有D-Bus接口的动态防火墙管理工具。
同时支持IPv4和IPv6;它还支持网络防火墙区域、网桥和 ipset。它允许在区域中执行定时防火墙规则、记录拒绝的数据包、自动加载内核模块以及许多其他功能。
Firewalld 使用运行时和永久配置选项,您可以使用firewall-cmd 进行管理。在本文中,我们将解释如何解决 RHEL/CentOS 7 Linux 系统上的“firewall-cmd:找不到命令”错误。
另请阅读:在 Linux 中配置和管理防火墙的有用“FirewallD”规则
我们在新推出的 AWS (Amazon Web Services) EC2 (弹性云计算) RHEL 7.4 Linux实例,如下图所示。
要修复此错误,您需要使用 yum 包管理器在 RHEL/CentOS 7 上安装 firewalld,如下所示。
sudo yum install firewalld
接下来,启动firewalld并使其在系统启动时自动启动,然后检查其状态。
sudo systemctl start firewalld
sudo systemctl enable firewalld
sudo systemctl status firewalld
现在,您可以运行 firewall-cmd 在防火墙中打开一个端口(本例中为 5000),如下所示,始终重新加载防火墙配置以使更改生效。
sudo firewall-cmd --zone=public --add-port=5000/tcp --permanent
sudo firewall-cmd --reload
要阻止上述端口,请运行以下命令。
sudo firewall-cmd --zone=public --remove-port=5000/tcp --permanent
sudo firewall-cmd --reload
您可能还想阅读这些有用的防火墙指南:
- 如何在 Linux 中启动/停止以及启用/禁用 FirewallD 和 Iptables 防火墙
- 如何在 CentOS/RHEL 7 中配置 FirewallD
- 在 Linux 中配置和管理防火墙的有用“FirewallD”规则
- 使用 FirewallD 和 Iptables 进行防火墙要点和网络流量控制
- 如何在 Linux 中阻止对特定 IP 和网络范围的 SSH 和 FTP 访问
在本文中,我们解释了如何解决 RHEL/CentOS 7 上的“firewall-cmd:找不到命令”。要提出任何问题或分享一些想法,请使用下面的评论表。