Linux Firewalld: Mastering Essential Rules

In the realm of Linux network security, firewalld has emerged as a robust and user-friendly solution for managing firewall rules. This service, available in modern Linux distributions like CentOS, RHEL, and Fedora, provides a dynamic and efficient way to control incoming and outgoing network traffic. Let's delve into the world of firewalld and explore how to list firewall rules in this powerful tool.

18 Linux Firewall Software: Protect Your Linux System
18 Linux Firewall Software: Protect Your Linux System

Before we dive into listing rules, it's crucial to understand that firewalld operates using zones and services. Zones define the trust level of network interfaces, while services represent specific network services like SSH, HTTP, or DNS. By combining these concepts, we can create intricate firewall rules to safeguard our Linux systems.

Firewall Explained 🔥🛡️ | How It Protects Your Computer & Network
Firewall Explained 🔥🛡️ | How It Protects Your Computer & Network

Understanding Firewalld Zones and Services

To effectively manage firewall rules, we must first grasp the fundamentals of zones and services in firewalld. Zones are network profiles that determine the level of trust for network interfaces. Common zones include public, internal, dmz, and work. Services, on the other hand, represent specific network services that can be allowed or blocked by the firewall.

the linux firewall frontends wheel is shown with icons and symbols in it
the linux firewall frontends wheel is shown with icons and symbols in it

By default, firewalld comes with a predefined set of zones and services. However, you can create custom zones and services to cater to your specific network requirements. Understanding these concepts is vital for listing and managing firewall rules effectively.

Listing Available Zones

the fortgate firewall commands poster
the fortgate firewall commands poster

To list the available zones in firewalld, we can use the following command in the terminal:

firewall-cmd --get-zones

This command will display a list of all the zones currently defined in the system. You can also use the --list-all-zones option to show detailed information about each zone, including their default and current settings:

firewall-cmd --list-all-zones

Listing Available Services

the diagram shows how firewall works and what it is doing to work for them
the diagram shows how firewall works and what it is doing to work for them

Similarly, to list the available services in firewalld, we can use the following command:

firewall-cmd --get-services

This command will display a list of all the services currently defined in the system. To view detailed information about each service, including their default and current ports, use the --list-all-services option:

firewall-cmd --list-all-services

Listing Firewall Rules

Linux Server Hardening Checklist (2026) 🔐
Linux Server Hardening Checklist (2026) 🔐

Now that we have a solid understanding of zones and services, let's explore how to list firewall rules in firewalld. Listing rules is an essential task for auditing and managing your firewall configuration effectively.

To list all the active firewall rules, we can use the following command:

the linux system tools list is shown in blue and red colors, with several icons on it
the linux system tools list is shown in blue and red colors, with several icons on it
the linux commands for devops poster
the linux commands for devops poster
a white piece of paper with writing on it and an image of a firewall diagram
a white piece of paper with writing on it and an image of a firewall diagram
a poster with many different types of servers
a poster with many different types of servers
the linux patch checklist is shown in black
the linux patch checklist is shown in black
Types of Firewalls Explained: Every Computer Science Student Must Know
Types of Firewalls Explained: Every Computer Science Student Must Know
the internet and firewalls diagram shows how to use it in different areas of the world
the internet and firewalls diagram shows how to use it in different areas of the world
the basic linux command commands are displayed in this screenshote screen shot, which shows how to use them
the basic linux command commands are displayed in this screenshote screen shot, which shows how to use them
the info sheet shows different types of linuxs and other web services, including security tools
the info sheet shows different types of linuxs and other web services, including security tools
Linux Commands Cheat Sheet for Beginners 2026
Linux Commands Cheat Sheet for Beginners 2026
the router and firewall diagram is shown in red, white, and blue
the router and firewall diagram is shown in red, white, and blue
the linux command commands list is shown in this screenshote, which shows how to use
the linux command commands list is shown in this screenshote, which shows how to use
a black and yellow flyer with linux commands
a black and yellow flyer with linux commands
the linux command commands are displayed in this poster
the linux command commands are displayed in this poster
several different types of firewalls are shown in this graphic above the words, utm / firewalls
several different types of firewalls are shown in this graphic above the words, utm / firewalls
Linux Commands Cheat Sheet for Hackers & Developers (Must Know)🔥🚀
Linux Commands Cheat Sheet for Hackers & Developers (Must Know)🔥🚀
#cybersecurity #hacking #security
#cybersecurity #hacking #security
the linux basics bash commands list
the linux basics bash commands list
the linux file types info sheet is shown in this graphic above it's image
the linux file types info sheet is shown in this graphic above it's image
the ultimate linux command commands for long - term and processing documents, including text or images
the ultimate linux command commands for long - term and processing documents, including text or images

firewall-cmd --list-all

This command will display a comprehensive list of all the active rules, including their zones, services, and the corresponding actions (allow or deny). To list only the rules for a specific zone, you can use the following syntax:

firewall-cmd --list-all --zone=ZONE_NAME

Listing Permanent and Runtime Rules

It's essential to understand that firewalld maintains two sets of rules: permanent and runtime. Permanent rules are stored in the configuration file (/etc/firewalld/zones/zone.file) and are applied during system startup. Runtime rules, on the other hand, are stored in the runtime directory (/run/firewalld/) and are applied immediately without requiring a system reboot.

To list permanent rules, use the following command:

firewall-cmd --permanent --list-all

To list runtime rules, use the following command:

firewall-cmd --runtime --list-all

Listing Rules for a Specific Service

To list rules for a specific service, you can use the following command:

firewall-cmd --list-all --service=SERVICE_NAME

Replace SERVICE_NAME with the name of the service you want to inspect. This command will display all the active rules related to the specified service.

Managing Firewall Rules

Listing firewall rules is just the beginning. firewalld offers a plethora of commands to manage your firewall rules effectively. You can add, remove, or modify rules, as well as enable or disable services and zones. To learn more about managing firewall rules, refer to the official firewalld documentation or consult our comprehensive guide on managing firewall rules with firewalld.

In the ever-evolving landscape of network security, staying informed and proactive is crucial. Listing and managing firewall rules with firewalld is an essential step in maintaining a robust and secure Linux environment. By mastering these techniques, you'll be well-equipped to protect your systems from potential threats and ensure seamless network connectivity.

As you continue your journey into Linux network security, consider exploring other aspects of firewalld and related tools. Stay curious, and always strive to expand your knowledge to better safeguard your systems and data. Happy learning!