Wrigs

RHEL_Firewalld_Config

Nov 6th, 2026
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Markdown 6.32 KB | Software | 0 0

Installing and Configuring firewalld on RHEL 10

Overview

firewalld is the default dynamic firewall management service used on Red Hat Enterprise Linux (RHEL). It provides a flexible interface for managing Linux firewall rules through zones, services, ports, rich rules, and direct rules.

This document explains how to install, enable, and configure firewalld on a RHEL 10 system.


Prerequisites

Before beginning, ensure:

  • You have root or sudo privileges.
  • The system is running RHEL 10.
  • The system has access to configured package repositories.

Verify the operating system version:

cat /etc/redhat-release

1. Install firewalld

Check whether firewalld is already installed:

rpm -q firewalld

If it is not installed, install it using DNF:

sudo dnf install -y firewalld

Verify the installation:

firewall-cmd --version

2. Enable and Start the Service

Enable firewalld to start automatically during boot:

sudo systemctl enable firewalld

Start the service:

sudo systemctl start firewalld

Verify the service status:

sudo systemctl status firewalld

A healthy service should display a status of:

active (running)

3. Verify Firewall Status

Check whether firewalld is running:

sudo firewall-cmd --state

Expected output:

running

Display current firewall settings:

sudo firewall-cmd --list-all

4. Understanding Zones

Zones define the trust level assigned to network connections.

Display all available zones:

sudo firewall-cmd --get-zones

Display the active zone:

sudo firewall-cmd --get-active-zones

Show the default zone:

sudo firewall-cmd --get-default-zone

Typical zones include:

Zone Purpose
public Default for untrusted networks
home Trusted home network
work Trusted work environment
internal Internal organizational network
trusted All traffic accepted
drop All incoming traffic dropped
block Incoming traffic rejected

5. Change the Default Zone

To set the default zone to public:

sudo firewall-cmd --set-default-zone=public

Verify the change:

sudo firewall-cmd --get-default-zone

6. Allow Network Services

Open common services using predefined service definitions.

Allow SSH

sudo firewall-cmd --permanent --add-service=ssh

Allow HTTP

sudo firewall-cmd --permanent --add-service=http

Allow HTTPS

sudo firewall-cmd --permanent --add-service=https

Apply changes:

sudo firewall-cmd --reload

Verify:

sudo firewall-cmd --list-services

7. Open Specific Ports

To allow TCP port 8080:

sudo firewall-cmd --permanent --add-port=8080/tcp

To allow UDP port 514:

sudo firewall-cmd --permanent --add-port=514/udp

Reload configuration:

sudo firewall-cmd --reload

Verify open ports:

sudo firewall-cmd --list-ports

8. Remove Services or Ports

Remove HTTP access:

sudo firewall-cmd --permanent --remove-service=http

Remove TCP port 8080:

sudo firewall-cmd --permanent --remove-port=8080/tcp

Reload configuration:

sudo firewall-cmd --reload

9. Configure Source-Based Rules

Allow a specific subnet in the internal zone:

sudo firewall-cmd \
  --permanent \
  --zone=internal \
  --add-source=192.168.10.0/24

Reload:

sudo firewall-cmd --reload

View zone details:

sudo firewall-cmd --zone=internal --list-all

10. Configure Rich Rules

Rich rules provide more granular control.

Example: Allow SSH only from a management workstation.

sudo firewall-cmd \
  --permanent \
  --add-rich-rule='rule family="ipv4" source address="192.168.10.50" service name="ssh" accept'

Reload configuration:

sudo firewall-cmd --reload

Display rich rules:

sudo firewall-cmd --list-rich-rules

11. Runtime vs Permanent Configuration

firewalld supports two configuration types.

Type Description
Runtime Active until reboot
Permanent Saved across reboots

Example runtime change:

sudo firewall-cmd --add-service=http

Example permanent change:

sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --reload

12. Reload or Restart firewalld

Reload rules without disrupting existing connections:

sudo firewall-cmd --reload

Restart the service:

sudo systemctl restart firewalld

13. Troubleshooting

Verify service status:

sudo systemctl status firewalld

View logs:

sudo journalctl -u firewalld

Check currently active configuration:

sudo firewall-cmd --list-all

Validate a zone configuration:

sudo firewall-cmd --zone=public --list-all

Common Administrative Commands

# Display active zones
firewall-cmd --get-active-zones

# Display default zone
firewall-cmd --get-default-zone

# List open services
firewall-cmd --list-services

# List open ports
firewall-cmd --list-ports

# Reload configuration
firewall-cmd --reload

# Show all settings
firewall-cmd --list-all

Security Best Practices

  1. Open only the services and ports required by the application.
  2. Use service definitions instead of individual ports whenever possible.
  3. Use rich rules to restrict administrative access.
  4. Regularly review firewall configuration.
  5. Use permanent rules for production environments.
  6. Test rule changes before deployment.
  7. Maintain SSH access while making firewall modifications.

Conclusion

firewalld provides a flexible and dynamic firewall management framework for RHEL 10. By using zones, services, ports, and rich rules, administrators can build secure and maintainable host-based firewall configurations while minimizing operational complexity.

Tags: firewalld RHEL
Add Comment
Please, Sign In to add comment