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
分享

相关文章

7月 30, 2026

解决OpenWrt掉IPv6公网的问题

背景:电信宽带,已改桥接,有公网v6。由于存在v6续约超时的bug,所以写一个脚本自动重启wan接口。 创建watchdog主程序 nano /usr/bin/ipv6-watchdog 写入内容: #!/bin/sh ######################################

7月 8, 2026

解决WD机场的Mihomo订阅DNS无法查询的问题

目前WD下发的mihomo配置文件里的dns配置里有一句: proxy-server-nameserver: - udp://127.0.0.1:2053 这原本是为了防止代理服务器自身的域名被dns污染,默认你有一个mosdns/smartdns的本地dns分流器,新版mihomo

3月 7, 2026

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

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

下一篇

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

上一篇

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

最近更新

  • 解决OpenWrt掉IPv6公网的问题
  • 《红猪》观影笔记
  • Alicks杂记
  • 解决WD机场的Mihomo订阅DNS无法查询的问题
  • 目前家庭服务器的基本状况

热门标签

Halo 服务器 Web 博客 OpenWrt

目录

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

使用 Halo 主题 Chirpy