avatar

LeapHeap Journal

Record moments.

  • 首页
  • 归档
  • 分类
  • 标签
  • 关于
主页 [备忘]红帽系Linux禁用SELinux和FirewallD
文章

[备忘]红帽系Linux禁用SELinux和FirewallD

发表于 2025-06-15 更新于 2025-06- 15
作者 LeapHeap
11~14 分钟 阅读

While generally not recommended for production environments due to security implications, you can disable SELinux and Firewalld on Rocky Linux 9.5/9.6. This might be useful for specific troubleshooting scenarios or if you're implementing an alternative security solution.

Important Note: Disabling SELinux and Firewalld significantly reduces your system's security posture. Only do this if you understand the risks and have a clear reason to do so. For most situations, it's better to configure SELinux and Firewalld to allow necessary traffic and operations rather than disabling them entirely.

Disabling SELinux on Rocky Linux 9.x

SELinux can be temporarily disabled or permanently disabled.

1. Check SELinux Status:

Before making changes, check the current status of SELinux:

sestatus

You'll typically see "SELinux status: enabled" and "Current mode: enforcing" if it's active.

2. Temporarily Disable SELinux (until next reboot):

This is useful for quick testing as changes will revert after a reboot.

sudo setenforce 0

Or:

sudo setenforce permissive

"Permissive" mode means SELinux will log security denials but won't enforce them. This is often a good intermediate step for troubleshooting.

Verify the status again:

sestatus

It should now show "Current mode: permissive" or "Current mode: disabled".

3. Permanently Disable SELinux:

This change will persist across reboots.

* Edit the SELinux configuration file:

sudo nano /etc/selinux/config

* Find the line SELINUX=enforcing and change it to SELINUX=disabled:

# This file controls the state of SELinux on the system.

# SELINUX= can take one of these three values:

# enforcing - SELinux security policy is enforced.

# permissive - SELinux prints warnings instead of enforcing.

# disabled - No SELinux policy is loaded.

SELINUX=disabled

# SELINUXTYPE= can take one of these two values:

# targeted - Targeted processes are protected,

# mls - Multi Level Security protection.

SELINUXTYPE=targeted

* Save and close the file. In nano, press Ctrl+X, then Y to confirm save, and Enter.

* Reboot the system for the changes to take effect:

sudo reboot

* After rebooting, verify SELinux is disabled:

sestatus

It should now show "SELinux status: disabled".

Disabling Firewalld on Rocky Linux 9.x

Firewalld is the default firewall management tool on Rocky Linux.

1. Check Firewalld Status:

sudo systemctl status firewalld

You'll see "Active: active (running)" if it's enabled.

2. Temporarily Stop Firewalld (until next reboot):

This stops the firewall immediately but it will start again after a reboot if enabled.

sudo systemctl stop firewalld

Verify it's stopped:

sudo systemctl status firewalld

It should show "Active: inactive (dead)".

3. Permanently Disable Firewalld:

This will stop Firewalld and prevent it from starting automatically at boot.

* Stop the Firewalld service:

sudo systemctl stop firewalld

* Disable Firewalld from starting on boot:

sudo systemctl disable firewalld

* Optional: Mask Firewalld (prevents other services from starting it):

This is an extra step to ensure Firewalld doesn't get started by other dependencies.

sudo systemctl mask --now firewalld

* Verify Firewalld is disabled:

sudo systemctl status firewalld

It should show "Active: inactive (dead)" and "Loaded: ... disabled ..."

Re-enabling SELinux and Firewalld (if needed):

* To re-enable SELinux:

Edit /etc/selinux/config and change SELINUX=disabled back to SELINUX=enforcing. Then, reboot your system. You might also need to run sudo touch /.autorelabel before rebooting to relabel the filesystem, especially if SELinux was disabled for a long time.

* To re-enable Firewalld:

sudo systemctl unmask firewalld # If you masked it

sudo systemctl enable firewalld

sudo systemctl start firewalld

Again, exercise caution when disabling these security features on any system, especially in production environments.

日志, 技术
许可协议:  CC BY 4.0
分享

相关文章

3月 7, 2026

在PVE里使用虚拟串口与虚拟机进行命令行交互

起因 在pve中,如果给虚拟机直通了物理显卡,此虚拟机在加载显卡驱动后就会默认使用直通显卡输出视频流,因此pve对于这个虚拟机的基于虚拟显卡的VNC控制台就无法使用了,虚拟机进入“Headless”状态。因此,为了在这种情况下仍然能通过控制台与虚拟机交互,就需要使用虚拟串口。 实战操作 添加硬件接口

3月 7, 2026

使用Docker部署网页版MeshCommander

简介 MeshCommander作为一款方便的第三方英特尔AMT客户端,本质上是一个可通过NPM部署的网页应用,但是官网只发布了官方打包好的桌面客户端。为了方便异地访问时直接在内网使用,故在路由器上部署一个由他人打包好的MeshCommander网页客户端。 前置条件 一台已经安装了Docker的主

3月 7, 2026

使用nginx给Halo后端补上favicon.ico

Halo默认不使用传统的favicon.ico,而是动态载入图标文件,因此某些浏览器认为网站没有图标。所以我使用nginx反代时手动指定nginx返回favicon.ico。 # 精确匹配 favicon.ico 请求 location = /favicon.ico { #

下一篇

给PVE添加内网IP自签名证书并在其他设备上信任

上一篇

开启Openclash导致WireGuard不能连接的问题的解决

最近更新

  • 在PVE里使用虚拟串口与虚拟机进行命令行交互
  • 使用Docker部署网页版MeshCommander
  • 使用nginx给Halo后端补上favicon.ico
  • 修复微软游戏服务导致的地平线5Xbox版异常
  • 在PVE/Debian上部署UPS状态监控的网页插件

热门标签

Halo 服务器 Web 博客 OpenWrt

目录

©2026 LeapHeap Journal. 保留部分权利。

使用 Halo 主题 Chirpy