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

相关文章

8月 8, 2026

[备忘] ddns-go docker容器内获取服务器主网卡的稳定ipv6

排除临时v6地址的noprefixroute标记即可。在获取v6地址方式选择by command,使用以下命令: ip -6 addr show dev enp6s0 scope global | awk '/inet6/ && $0 !~ /noprefixroute/ && $2 !~ /^fd

8月 7, 2026

[备忘] OpenClash部署配置简记

背景:2026年8月5日晚从nikki因版本过旧原因迁移到OpenClash新版端。以下是在官方默认配置下做的改动。 插件设置 操作模式 由于个人有依赖UDP的FH5联机需求,所以设置为fakeip-mixed,TUN栈选择Mixed,这样保证UDP流量进TUN透明代理。这也是之前某Youtuber

7月 30, 2026

解决OpenWrt掉IPv6公网的问题

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

下一篇

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

上一篇

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

最近更新

  • [备忘] ddns-go docker容器内获取服务器主网卡的稳定ipv6
  • [备忘] OpenClash部署配置简记
  • 解决OpenWrt掉IPv6公网的问题
  • 《红猪》观影笔记
  • Alicks杂记

热门标签

Halo 服务器 Web 博客 OpenWrt

目录

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

使用 Halo 主题 Chirpy