🇩🇪 Germany VPS with 10Gbps Port & Unlimited Traffic – SMTP Ports Open (25, 465, 587)

Configure FirewallD Zones: A Step-by-Step Guide

July 31, 2025

 

 

Configuring FirewallD zones is a vital aspect of managing network security in Linux systems. FirewallD, a dynamic firewall management tool, offers a more flexible approach compared to traditional iptables. By leveraging zones, you can control access to network interfaces based on specific criteria or trusted connections. This guide will walk you through understanding, configuring, and managing FirewallD zones effectively.

Understanding FirewallD Zones

At its core, a FirewallD zone defines a set of rules that applies to one or more network interfaces or sources. Depending on the security requirements, you can configure zones to manage traffic differently. The default zones provided by FirewallD include:

  • drop: All incoming connections are rejected without a notification.
  • block: All incoming connections are rejected and a notification is sent.
  • public: For use in public areas where you don’t trust other hosts.
  • internal: Intended for trusted internal networks.
  • trusted: All connections are accepted.
  • home: Suitable for home networks.
  • work: For work environments.

Each zone has its own preset rules that can be modified to suit your requirements.

Installing and Starting FirewallD

To configure FirewallD zones, you first need to ensure that FirewallD is installed and running on your system. You can install it using your package manager:

sudo dnf install firewalld      # For Fedora and RHEL
sudo apt-get install firewalld  # For Ubuntu

Once installed, you can start and enable the service with the following commands:

sudo systemctl start firewalld
sudo systemctl enable firewalld

Checking the Current Zone Configuration

Before making any changes, it’s advantageous to check your current configuration. You can view the active zones and their settings with the command:

sudo firewall-cmd --get-active-zones

This will show you which zones are currently active and to which interfaces they are assigned.

Configuring a Zone

To modify or configure a zone, you can utilize the firewall-cmd command-line interface. Suppose you want to set the public zone to allow HTTP and HTTPS traffic. You can do so by executing the following commands:

sudo firewall-cmd --zone=public --add-service=http
sudo firewall-cmd --zone=public --add-service=https

Making Changes Permanent

Changes made using the command line are temporary by default; they will be lost upon a system restart. To ensure your configuration persists, you can use the --permanent flag:

sudo firewall-cmd --zone=public --add-service=http --permanent
sudo firewall-cmd --zone=public --add-service=https --permanent

After making permanent changes, reload the firewall for them to take effect:

sudo firewall-cmd --reload

Adding and Removing Sources in Zones

In addition to modifying services, you can specify which IP addresses or networks are allowed to connect. For instance, to add a specific IP to the trusted zone, use the following command:

sudo firewall-cmd --zone=trusted --add-source=192.168.1.100 --permanent

Conversely, if you need to remove a source, you can execute:

sudo firewall-cmd --zone=trusted --remove-source=192.168.1.100 --permanent

Remember to reload the firewall after making such changes.

Listing Specific Zone Details

To view the details of a specific zone, including allowed services and sources, you can use:

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

This command provides a comprehensive overview of the zone’s rules, making it easier to visualize your current configuration.

Conclusion

Configuring FirewallD zones is integral to securing your Linux system’s network interfaces. By understanding how to set up and manage zones, you can tailor your firewall rules to meet specific needs, enhancing your overall security posture. Whether opening up access for trusted networks or limiting exposure in public environments, effective use of FirewallD zones will help you maintain a robust defense against potential threats.

VirtVPS