
In this article, we’ll explore the simple steps to enable HTTPS on your website. We’ll guide you through the process of installing SSL on RHEL9,
Learn how to configure a Linux firewall using UFW on Ubuntu and Firewalld on RHEL. Step-by-step CLI examples, best practices, and comparison tables included.
Securing your Linux server is a critical step in system administration. One of the foundational layers of server security is the firewall — a system that controls incoming and outgoing traffic based on predefined rules. In this guide, we’ll walk you through configuring firewalls using two widely adopted tools: UFW (Uncomplicated Firewall) for Ubuntu systems and Firewalld for RHEL-based distributions like CentOS, AlmaLinux, and Fedora.
A firewall is a network security system that monitors and controls incoming and outgoing traffic. Linux distributions commonly use iptables, but front-end tools like UFW and Firewalld simplify the management process.
🔐 Goal: Minimize security risks by controlling which services are exposed to the internet. |
UFW (Uncomplicated Firewall) is the default firewall management tool for Ubuntu. It’s a front-end for iptables
, designed to make configuration easier for users who are new to firewall management.
🔑 Key Features: |
|
|
|
|
Let’s walk through setting up a firewall with UFW on an Ubuntu system.
✅ Step 1: Install UFW (if not already installed) |
sudo apt update
sudo apt install ufw
✅ Step 2: Check UFW Status |
sudo ufw status verbose
If it’s inactive, you’ll need to enable it after configuration.
✅ Step 3: Set Default Rules |
Before allowing or denying traffic, set default policies:
sudo ufw default deny incoming
sudo ufw default allow outgoing
✅ Step 4: Allow Essential Services |
Here’s how to allow SSH (port 22) so you don’t get locked out:
sudo ufw allow ssh
Or specify port and protocol:
sudo ufw allow 22/tcp
✅ Step 5: Add More Rules |
Action | Command Example |
---|---|
Allow HTTP | sudo ufw allow 80/tcp |
Allow HTTPS | sudo ufw allow 443/tcp |
Deny a Port | sudo ufw deny 21/tcp |
Allow by Subnet | sudo ufw allow from 192.168.1.0/24 |
✅ Step 6: Enable UFW |
Once your rules are configured:
sudo ufw enable
✅ Step 7: Check Rules |
sudo ufw status numbered
✅ Step 8: Delete Rules (if needed) |
sudo ufw delete
Firewalld is the default firewall service in Red Hat Enterprise Linux, CentOS, AlmaLinux, and Fedora. It uses zones and services to manage rules dynamically without restarting the firewall.
🔑 Key Features: |
|
|
|
|
✅ Step 1: Install and Start Firewalld |
sudo dnf install firewalld # If not already installed
sudo systemctl enable --now firewalld
✅ Step 2: Check Firewalld Status |
sudo firewall-cmd --state
✅ Step 3: Understand Zones |
Each interface is assigned to a zone with specific rules. Common zones include:
Zone | Description |
---|---|
public | Default zone for public interfaces |
internal | For trusted internal networks |
drop | Drops all incoming connections |
trusted | All connections are accepted |
Check the active zone:
sudo firewall-cmd --get-active-zones
✅ Step 4: Assign Interfaces to Zones |
sudo firewall-cmd --zone=public --change-interface=eth0 --permanent
✅ Step 5: Allow Services or Ports |
To allow services:
sudo firewall-cmd --zone=public --add-service=http --permanent
To allow specific ports:
sudo firewall-cmd --zone=public --add-port=8080/tcp --permanent
Apply the changes:
sudo firewall-cmd --reload
✅ Step 6: View Current Configuration |
sudo firewall-cmd --list-all
✅ Step 7: Remove Rules (if needed) |
sudo firewall-cmd --zone=public --remove-service=http --permanent
sudo firewall-cmd --reload
Feature | UFW (Ubuntu) | Firewalld (RHEL) |
---|---|---|
Default Distro | Ubuntu/Debian | RHEL/CentOS/Fedora |
Backend | iptables | nftables or iptables |
Rule Types | Port/Application | Zones/Services/Ports |
Runtime Config | No (requires restart) | Yes (changes can be immediate) |
Ease of Use | Very user-friendly | More advanced and flexible |
Logging | Supported | Supported |
Whether you use UFW or Firewalld, the following best practices apply:
|
|
|
|
|
|
Both UFW and Firewalld are excellent firewall management tools that cater to different Linux ecosystems. If you’re using Ubuntu, UFW provides a beginner-friendly approach. For RHEL-based systems, Firewalld offers flexibility through zones and rich configurations. Whichever you choose, ensuring your firewall is properly configured is crucial to securing your Linux environment.
💡Don’t leave your firewall as an afterthought — it’s your server’s first line of defense. |
Did you find this article helpful? Your feedback is invaluable to us! Feel free to share this post with those who may benefit, and let us know your thoughts in the comments section below.
In this article, we’ll explore the simple steps to enable HTTPS on your website. We’ll guide you through the process of installing SSL on RHEL9,
Learn how to set up a local DNS server on CentOS 9 using BIND, with detailed instructions, CLI examples, and best practices for managing DNS
Learn about securing SSH connections on RHEL 9 and CentOS 9 with Ansible roles. This guide covers key SSH security practices, Ansible playbook setup, and