设置SELinux标志

设置SELinux标志

💡 原文英文,约400词,阅读约需2分钟。
📝

内容提要

在学习SELinux时,发现开启强制模式后配置反向代理困难。使用命令`setsebool httpd_can_network_connect on`可以临时允许httpd连接网络,但重启后会恢复默认。要永久设置,需使用`setsebool -P httpd_can_network_connect on`,使httpd_t域能够发起网络连接。

🎯

关键要点

  • 在学习SELinux时,开启强制模式后配置反向代理变得困难。
  • 使用命令`setsebool httpd_can_network_connect on`可以临时允许httpd连接网络,但重启后会恢复默认。
  • 要永久设置httpd连接网络权限,需使用命令`setsebool -P httpd_can_network_connect on`。
  • 可以通过命令`semanage boolean -l | grep httpd_can_network_connect`检查SELinux标志的默认值。
  • httpd_can_network_connect标志允许httpd_t域发起网络连接,默认情况下被限制。
  • 在强制模式下,httpd_t域需要被允许调用connect()以使用网络服务。

延伸问答

如何临时允许httpd连接网络?

使用命令`setsebool httpd_can_network_connect on`可以临时允许httpd连接网络。

如何永久设置httpd的网络连接权限?

使用命令`setsebool -P httpd_can_network_connect on`可以永久设置httpd的网络连接权限。

如何检查SELinux标志的默认值?

可以使用命令`semanage boolean -l | grep httpd_can_network_connect`来检查SELinux标志的默认值。

httpd_can_network_connect标志的作用是什么?

httpd_can_network_connect标志允许httpd_t域发起网络连接,默认情况下被限制。

在SELinux强制模式下,httpd如何使用网络服务?

在强制模式下,httpd_t域需要被允许调用connect()以使用网络服务。

为什么在重启后httpd的网络连接权限会恢复默认?

因为临时设置的权限在重启后会回到默认状态,除非使用-P选项进行永久设置。

➡️

继续阅读