在 CentOS 系统中,通常默认使用的防火墙软件是 firewalld。以下是开启 CentOS 防火墙的步骤:
sudo systemctl start firewalld
sudo systemctl enable firewalld
sudo firewall-cmd --state
如果输出为“running”,则表示防火墙已启用。
在启用防火墙之前,根据需要允许必要的端口,以便系统正常工作。例如,允许 HTTP 和 HTTPS 流量通过防火墙:
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
在对防火墙规则进行更改后,需要重新加载它以使更改生效:
sudo firewall-cmd --reload
可以使用以下命令查看当前防火墙规则:
sudo firewall-cmd --list-all
以上步骤即可完成 CentOS 防火墙的开启。请注意,具体命令可能会因 CentOS 版本的不同而略有差异,建议根据实际情况进行调整。
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
推荐阅读:CentOS防火墙开启步骤是什么