Configuring Fail2ban to work with firewalld

This document (000021067) is provided subject to the disclaimer at the end of this document.


SUSE Linux Enterprise Server 15 SP4
SUSE Linux Enterprise Server for SAP Applications 15 SP4


This document details how to configure Fail2ban service to work with firewalld on SLES15. Fail2ban can dynamically add rich rules to firewalld to block banned IPs.  It will remove them if the Fail2ban service is stopped.


1) Open /etc/fail2ban/jail.local file and add the banaction and banaction_allports parameters:
# Do all your modifications to the jail's configuration in jail.local!
banaction = firewallcmd-rich-rules[actiontype=<multiport>]
banaction_allports = firewallcmd-rich-rules[actiontype=<allports>]

enabled = true

2) Restart Fail2ban service:
systemctl restart fail2ban.service

When Fail2ban blocks an IP it will also add a related rich rule to firewalld.
To verify all the firewalld rich rules: 
firewall-cmd --list-all
firewall-cmd --list-rich-rules

Fail2ban deletes the rich rules from firewalld when Fail2ban service is stopped or the jail (in this case the [sshd] jail) is stopped (fail2ban-client stop sshd).

Additional Information

The banaction and banaction_allports parameters can be redefined centrally in the [DEFAULT] section inside jail.local (to apply it to all jails at once) or separately in each jail, where this substitution will be used.

jail.conf man page:

Firewalld :
Firewalld runtime vs permanent:

Please note: Fail2ban package is supported only on SLES 15 SP4 and later versions. In previous releases of SLES Fail2ban is provided only through SUSE Package Hub. While the packages from the SUSE Package Hub are not officially supported by SUSE, SUSE Linux Enterprise Server remains supported and supportable when using these packages.


This Support Knowledgebase provides a valuable tool for SUSE customers and parties interested in our products and solutions to acquire information, ideas and learn from one another. Materials are provided for informational, personal or non-commercial use within your organization and are presented "AS IS" WITHOUT WARRANTY OF ANY KIND.

  • Document ID:000021067
  • Creation Date: 12-May-2023
  • Modified Date:16-May-2023
    • SUSE Linux Enterprise Server

< Back to Support Search

For questions or concerns with the SUSE Knowledgebase please contact: tidfeedback[at]

SUSE Support Forums

Get your questions answered by experienced Sys Ops or interact with other SUSE community experts.

Join Our Community

Support Resources

Learn how to get the most from the technical support you receive with your SUSE Subscription, Premium Support, Academic Program, or Partner Program.

SUSE Customer Support Quick Reference Guide SUSE Technical Support Handbook Update Advisories
Support FAQ

Open an Incident

Open an incident with SUSE Technical Support, manage your subscriptions, download patches, or manage user access.

Go to Customer Center