在CentOS系统中,使用firewalld作为默认的防火墙管理工具。为了设置合理的防火墙规则,你需要根据你的实际需求和网络环境来进行配置。以下是一些建议:
sudo systemctl status firewalld
如果尚未安装,请使用以下命令进行安装:
sudo yum install firewalld
sudo firewall-cmd --set-default-zone=public
sudo firewall-cmd --permanent --add-service=ssh
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="192.168.1.0/24" connection state ESTABLISHED,RELATED accept'
请将192.168.1.0/24
替换为你的内部网络的IP地址范围。
sudo firewall-cmd --reload
sudo firewall-cmd --list-all
sudo firewall-cmd --permanent --remove-service=http
然后重新加载防火墙配置。
请注意,这些只是一些建议性的规则。你需要根据自己的实际需求和网络环境进行调整。在配置防火墙时,请务必谨慎,以免意外阻止重要的连接或导致安全风险。