Firewall-Cmd List Zone: Mastering Your Firewall Rules

The `firewall-cmd` command is a powerful tool for managing firewalls in Linux, particularly in systems that use the firewalld service. One of its most useful features is the ability to list the current firewall zones, which can help system administrators understand and manage their network security. The command `firewall-cmd list zone` is specifically designed for this purpose.

Home Network Firewall Rules: Minimal Allow/Block List That Still Works
Home Network Firewall Rules: Minimal Allow/Block List That Still Works

Before diving into the details, it's important to understand that firewalld uses the concept of zones to group similar network interfaces together. Each zone has its own set of rules that determine how traffic is handled. By listing the zones, you can gain a clear overview of your system's network security configuration.

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

Understanding Firewall Zones

Firewalld comes with several predefined zones, each with a specific set of rules. These include:

Firewall Explained 🔥🛡️ | How It Protects Your Computer & Network
Firewall Explained 🔥🛡️ | How It Protects Your Computer & Network
  • drop: Drops all incoming and outgoing traffic.
  • block: Blocks all incoming traffic, but allows outgoing traffic.
  • public: Allows incoming traffic from trusted networks, like your home network.
  • external: Similar to public, but for networks that are not fully trusted, like public Wi-Fi hotspots.
  • internal: Allows incoming traffic from trusted internal networks, like a local area network (LAN).
  • dmz: Allows incoming traffic from any network, useful for servers that need to be accessible from the internet.
  • work: A zone suitable for work networks, allowing incoming traffic from trusted networks, but with more restrictive rules than public.

In addition to these predefined zones, you can also create your own custom zones with specific rules.

Types of Firewalls Explained: Every Computer Science Student Must Know
Types of Firewalls Explained: Every Computer Science Student Must Know

Listing Current Zones

To list the current firewall zones, simply run the command `firewall-cmd list zone` in your terminal. The output will display the name of each zone and its interface(s). For example:

$ firewall-cmd list zone
public
  interfaces: eth0
  sources:
  services: dhcpv6-client
  ports:
  protocols:
  forward ports:
  masquerade: no
  forward ports:
  source ports:
  icmp-blocks:
  rich rules:

This output shows that the `public` zone is currently active and is associated with the `eth0` interface.

the fortgate firewall commands poster
the fortgate firewall commands poster

Filtering Zone Information

You can also filter the output of `firewall-cmd list zone` to display specific information. For instance, to list only the interfaces associated with each zone, you can use the `--zone` option:

`firewall-cmd --zone=public list interfaces`

Firewall Explained: What Every Computer Science Student Must Know
Firewall Explained: What Every Computer Science Student Must Know

This command will display only the interfaces associated with the `public` zone.

Managing Firewall Zones

an info sheet describing the different types of electronic devices and their functions in each region
an info sheet describing the different types of electronic devices and their functions in each region
an image of a black screen with text on it that reads,'how do you use the command? '
an image of a black screen with text on it that reads,'how do you use the command? '
the most used linux command mind map
the most used linux command mind map
a black and white map with the names of different types of commands on it's side
a black and white map with the names of different types of commands on it's side
Linux Commands Cheat Sheet for Hackers & Developers (Must Know)🔥🚀
Linux Commands Cheat Sheet for Hackers & Developers (Must Know)🔥🚀
Nmap Commands Cheat Sheet (Essential Scans for Hackers)
Nmap Commands Cheat Sheet (Essential Scans for Hackers)
NETWORK COMMANDS
NETWORK COMMANDS
an image of a computer screen with the text map heat sheet on it, and other information
an image of a computer screen with the text map heat sheet on it, and other information
a poster with many different types of servers
a poster with many different types of servers
an info sheet with the names and numbers of different types of computer hardware, including
an info sheet with the names and numbers of different types of computer hardware, including
Home Network Segmentation Map: Split IoT, Work & Gaming Devices Safely
Home Network Segmentation Map: Split IoT, Work & Gaming Devices Safely
an image of a computer screen with many numbers on it
an image of a computer screen with many numbers on it
a red and black striped background with an error message on the bottom right corner that reads,
a red and black striped background with an error message on the bottom right corner that reads,
the basic linux commands are displayed in this screenshot
the basic linux commands are displayed in this screenshot
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
Ultimate Nmap Cheat Sheet for Ethical Hacking Beginners
Ultimate Nmap Cheat Sheet for Ethical Hacking Beginners
the back side of a server rack with information about it's components and features
the back side of a server rack with information about it's components and features
the security controls chart is shown in yellow
the security controls chart is shown in yellow
the info is displayed in green and black
the info is displayed in green and black
a blue and green poster with information about the different types of internet services on it
a blue and green poster with information about the different types of internet services on it

In addition to listing zones, `firewall-cmd` also allows you to manage them. You can add, remove, or modify zones, as well as assign interfaces to them.

Adding a New Zone

To create a new zone, use the `firewall-cmd --permanent --new-zone` command, followed by the name of the new zone. For example, to create a new zone called `myzone`, you would run:

`firewall-cmd --permanent --new-zone myzone`

After creating the zone, you can add rules to it using the `firewall-cmd --zone=myzone` command.

Assigning an Interface to a Zone

To assign an interface to a zone, use the `firewall-cmd --zone=myzone --change-interface=eth0` command. This will assign the `eth0` interface to the `myzone` zone.

Remember to reload the firewalld service for the changes to take effect. You can do this with the `firewall-cmd --reload` command.

Understanding and managing firewall zones is a crucial aspect of network security. The `firewall-cmd list zone` command is a powerful tool that can help you maintain a clear overview of your system's network security configuration. Whether you're a seasoned system administrator or just starting out, taking the time to learn and use this command can greatly enhance your ability to protect your Linux system.