I have CentOS 7 with firewalld. I installed fail2ban and using the firewallcmd-new action. I am seeing bans in the fail2ban logs, and I want to check in firewallcmd if they are blocked. How can I do it?
I have CentOS 7 with firewalld. I installed fail2ban and using the firewallcmd-new action. I am seeing bans in the fail2ban logs, and I want to check in firewallcmd if they are blocked. How can I do it?
First, I strongly recommend that you use
banaction = firewallcmd-ipset
as this will provide much better performance when the ban list starts getting large.Now, with any of fail2ban's firewalld actions, it will add a direct rule, which you can inspect with
firewall-cmd --direct --get-all-rules
:As you can see, I am using
firewallcmd-ipset
, so the actual banned IP addresses are not listed here. Instead, I find them withipset list
:Details here: https://fedoraproject.org/wiki/FirewallD#Which_zones_are_available.3F
List all zones with the enabled features.
firewall-cmd --list-all-zones
Print zone with the enabled features. If zone is omitted, the default zone will be used.
firewall-cmd [--zone=<zone>] --list-all
If the above command is not displaying enough info, you can try
For the most advanced usage, or for iptables experts, FirewallD provides a direct interface that allows you to pass raw iptables commands to it. Direct Interface rules are not persistent unless the --permanent is used.
To see all custom chains or rules added to FirewallD:
firewall-cmd --direct --get-all-chains
firewall-cmd --direct --get-all-rules