SELinux与CentOS防火墙(firewalld)配合配置步骤如下:
检查并设置SELinux状态
sestatussetenforce 1/etc/selinux/config,设置SELINUX=enforcing,重启生效。配置firewalld基础规则
systemctl start firewalldfirewall-cmd --permanent --add-service=httpfirewall-cmd --permanent --add-port=31415/tcpfirewall-cmd --reload。SELinux与防火墙协同配置
semanage添加SELinux端口规则,例如:semanage port -a -t http_port_t -p tcp 31415(需先安装policycoreutils-python)。/var/log/audit/audit.log,使用audit2why分析SELinux拒绝记录,调整策略。注意:配置前建议备份重要数据,生产环境需谨慎测试规则兼容性。
参考来源: