Viewing Firewalld Rules
To view the current firewall rules configured by Firewalld, you can use the following commands:
Listing All Firewall Zones
To list all the available firewall zones, use the following command:
sudo firewall-cmd --get-zones
This will display a list of all the predefined and custom firewall zones.
Listing Active Zones
To list the active firewall zones, use the following command:
sudo firewall-cmd --get-active-zones
This will show the network interfaces associated with each active zone.
Viewing Zone-specific Rules
To view the firewall rules for a specific zone, use the following command:
sudo firewall-cmd --zone=<zone_name> --list-all
Replace <zone_name>
with the name of the zone you want to view, such as public
or internal
.
Viewing Default Zone
To view the default firewall zone, use the following command:
sudo firewall-cmd --get-default-zone
This will display the name of the default zone that is used for network interfaces that are not explicitly assigned to a zone.
Viewing Runtime vs. Permanent Rules
Firewalld maintains two sets of firewall rules: runtime rules and permanent rules. Runtime rules are the currently active rules, while permanent rules are the rules that will be applied at the next system restart.
To view the runtime rules, use the following command:
sudo firewall-cmd --list-all
To view the permanent rules, use the following command:
sudo firewall-cmd --permanent --list-all
You can also use the --runtime-to-permanent
option to make the current runtime rules permanent.
sudo firewall-cmd --runtime-to-permanent
By understanding these commands, you can effectively view and manage the firewall rules configured by Firewalld on your Linux system.