Filters & actions

fail2ban filter library

Every filter that ships with fail2ban 1.1.1, with its regexes, modes, the jails that use it and sample log lines it matches. Search below, or start with the most used ones.

Updated 9 min readChecked against fail2ban 1.1.1

A fail2ban filter is a file in /etc/fail2ban/filter.d/ with regular expressions (failregex) that recognize failed logins and other abuse in a log and extract the attacker's IP. fail2ban 1.1.1 ships 96 filters: sshd, nginx-http-auth, apache-auth, postfix, dovecot, recidive and many more. A jail uses the filter with the same name unless you set filter =. The full searchable list is below.

bash
ls /etc/fail2ban/filter.d/

Browse filters by service#

Filters for the services people protect most are documented inside their setup guides, next to the jail configuration. Everything else is grouped by type:

How filters, jails and actions fit together#

Part Lives in Answers
Filter filter.d/<name>.conf Which log lines are failures, and which IP caused them?
Jail jail.conf / jail.local Which log to read, how many failures, how long to ban?
Action action.d/<name>.conf How to ban: firewall, email, report?

A jail section like [nginx-http-auth] automatically uses filter.d/nginx-http-auth.conf, because the default is filter = %(__name__)s[mode=%(mode)s]. Several jails can share one filter with different options: postfix-sasl is filter = postfix[mode=auth]. Enabling a jail is covered in the jail.local example; actions are in the action library.

Most used filters#

How to choose a filter#

  1. Find out where the service logs failures. A file (/var/log/nginx/error.log) or the journal (journalctl -u ssh). Note one real failure line.
  2. Look for a matching filter in the list below. Search by service name. Many filters have modes; the filter page lists them.
  3. Test it against your real log before enabling the jail, e.g. sudo fail2ban-regex /var/log/nginx/error.log nginx-http-auth or sudo fail2ban-regex systemd-journal sshd. The summary line shows how many lines matched. Zero matches on a log that contains failures means the filter doesn't fit your log format. See fail2ban-regex for the options.
  4. No filter fits? Write your own in a few lines: custom filter guide. The regex tester lets you try regexes against pasted log lines in the browser.

Popular applications without a stock filter (Nextcloud, WordPress, Jellyfin, Home Assistant, Gitea…) are covered in the guides, with tested filters.

Customize a stock filter#

Don't edit files in filter.d/ that came with the package; upgrades overwrite them. Instead:

  • Change a mode or parameter from the jail: filter = sshd[mode=aggressive] or mode = aggressive in the jail.
  • Add regexes or ignores: create filter.d/<name>.local with failregex = %(known/failregex)s plus your lines. The .local is read after the .conf.
  • Something very different: copy the filter to a new name (filter.d/sshd-custom.conf) and point the jail at it.

Where the filters come from#

The stock filters live in the upstream repository under config/filter.d, each with test log samples in fail2ban/tests/files/logs/. Distribution packages install them unchanged to /etc/fail2ban/filter.d/. A newer fail2ban release often brings filter fixes (the 1.1.1 sshd filter, for example, matches the sshd-session process name used since OpenSSH 9.8), so check the version you run with fail2ban-client --version.

Files in filter.d/ that aren't filters on their own, like common.conf, apache-common.conf and botsearch-common.conf, hold shared regex fragments that other filters include.

All built-in filters#

Search by name or description. Each name opens the filter's page with its full definition, modes, the jails that use it and example log lines.

FilterServiceWhat it catches
3proxy3proxy proxy serverbans clients that fail proxy authentication on a 3proxy server
apache-authApache HTTP Servercatches failed HTTP Basic/Digest authentication and denied access in the Apache error log
apache-badbotsApache HTTP Serverbans known spam bots and e-mail harvesters by their User-Agent in the access log
apache-botsearchApache HTTP Serverbans scanners probing for admin pages and scripts that don't exist (phpMyAdmin, wp-login and similar)
apache-fakegooglebotApache HTTP Serverbans clients that claim to be Googlebot but fail a reverse-DNS check
apache-modsecurityApache + ModSecuritybans clients whose requests were blocked by ModSecurity rules
apache-nohomeApache HTTP Serverbans requests for user home directories (~user) that don't exist
apache-noscriptApache HTTP Serverbans clients requesting scripts (php, asp, cgi, perl) that don't exist on the server
apache-overflowsApache HTTP Serverbans clients sending overlong or malformed request URIs
apache-passApache HTTP Serverport-knocking helper: records clients that request a secret URL so another jail can allow them
apache-shellshockApache HTTP Serverbans requests that try to exploit the Bash Shellshock bug through CGI headers
asspASSP anti-spam SMTP proxybans hosts that ASSP rejects for SMTP abuse
asteriskAsterisk PBXbans SIP and IAX clients with failed registrations, wrong passwords or unknown extensions
bitwardenBitwarden (self-hosted)bans repeated failed logins to a self-hosted Bitwarden identity server
centreonCentreon Webbans failed logins to the Centreon monitoring web portal
counter-strikeCounter-Strike 1.6 serverbans players hammering the server with bad RCON passwords
courier-authCourier IMAP/POP3bans failed IMAP and POP3 logins on Courier
courier-smtpCourier MTAbans relay attempts and failed SMTP authentication on Courier
cyrus-imapCyrus IMAPbans failed IMAP/POP3 authentication on a Cyrus server
danteDante SOCKS serverbans clients that fail SOCKS authentication
directadminDirectAdmin control panelbans failed logins to the DirectAdmin panel
domino-smtpHCL/IBM Domino SMTPbans failed SMTP authentication on a Domino server
dovecotDovecot IMAP/POP3bans failed IMAP, POP3 and SASL logins logged by Dovecot
dropbearDropbear SSHbans failed password logins and bad users on the Dropbear SSH server
drupal-authDrupalbans failed Drupal logins (Drupal must log to syslog)
ejabberd-authejabberd XMPP serverbans failed XMPP authentication on ejabberd
exim-spamExim MTAbans hosts whose mail Exim rejected as spam (SpamAssassin, honeypot addresses)
eximExim MTAbans hosts with failed SMTP auth, relay attempts and rejected recipients in Exim's main log
freeswitchFreeSWITCHbans SIP clients with failed registrations or calls on FreeSWITCH
froxlor-authFroxlor control panelbans failed logins to the Froxlor server panel
gitlabGitLabbans failed sign-ins to a self-hosted GitLab (application or JSON log)
grafanaGrafanabans failed logins to Grafana
groupofficeGroup-Officebans failed logins to the Group-Office groupware
gssftpdgssftpd (Kerberos FTP)bans failed logins on the Kerberos FTP daemon
guacamoleApache Guacamolebans failed logins to the Guacamole remote-desktop gateway
haproxy-http-authHAProxybans clients that fail HTTP Basic authentication in front of HAProxy
hordeHorde webmailbans failed logins to Horde webmail
kerioKerio Connectbans hosts that Kerio Connect flags for SMTP spam, relay or auth failures
lighttpd-authlighttpdbans failed HTTP authentication on lighttpd
mongodb-authMongoDBbans failed MongoDB authentication attempts
monitMonitbans failed logins to Monit's built-in web interface
monitorixMonitorixbans failed authentication on Monitorix's built-in web server
mssql-authMicrosoft SQL Server on Linuxbans failed SQL Server logins
murmurMumble server (murmur)bans clients with wrong server passwords on a Mumble server
mysqld-authMySQL / MariaDBbans hosts with repeated 'Access denied' errors in the MySQL/MariaDB error log
nagiosNagios NRPEbans hosts not allowed to talk to the NRPE agent
named-refusedBIND (named)bans clients whose DNS queries or zone transfers BIND refused
nginx-bad-requestnginxbans clients sending malformed requests that nginx answers with 400 Bad Request
nginx-botsearchnginxbans scanners requesting admin pages and scripts that don't exist (404s for wp-login, phpMyAdmin and similar)
nginx-forbiddennginxbans clients that keep hitting locations you deny in nginx (403 forbidden by rule)
nginx-http-authnginxbans failed HTTP Basic authentication (auth_basic) in the nginx error log
nginx-limit-reqnginxbans clients that keep tripping nginx limit_req rate limits
nsdNSD DNS serverbans clients refused zone transfers or notifies by NSD
openhabopenHABbans failed authentication to openHAB's web and REST API
openvpnOpenVPNbans clients that fail the TLS handshake or authentication on an OpenVPN server
openwebmailOpenWebMailbans failed logins to OpenWebMail
oracleimsOracle Communications Messaging Serverbans failed authentication in Oracle IMS XML logs
pam-genericAny PAM servicebans authentication failures reported by PAM for any service
perditionPerdition IMAP/POP3 proxybans failed logins through the Perdition mail proxy
php-url-fopenPHP web appsbans requests that pass a remote URL as a script parameter (remote file inclusion attempts)
phpmyadmin-syslogphpMyAdminbans failed phpMyAdmin logins (phpMyAdmin logging to syslog)
portsentryPortSentrybans hosts that PortSentry detected port-scanning
postfixPostfix MTAbans hosts with rejected SMTP commands, failed SASL logins, RBL hits and unknown recipients in Postfix
proftpdProFTPDbans failed logins and unknown users on ProFTPD
proxmoxProxmox VE web UIbans failed logins to the Proxmox VE web interface (pveproxy, port 8006)
pure-ftpdPure-FTPdbans failed logins on Pure-FTPd
qmailqmailbans hosts rejected by qmail's RBL check
recidivefail2ban itselfreads fail2ban's own log and bans IPs that keep getting banned, for much longer
roundcube-authRoundcube webmailbans failed logins to Roundcube webmail
routeros-authMikroTik RouterOSbans failed logins to a MikroTik router (via remote syslog)
scanlogdscanlogdbans hosts that scanlogd caught port-scanning
screensharingdmacOS Screen Sharingbans failed VNC/Screen Sharing logins on macOS
selinux-sshOpenSSH via SELinux auditbans failed SSH logins recorded in the SELinux audit log
sendmail-authSendmailbans failed SMTP AUTH attempts on Sendmail
sendmail-rejectSendmailbans hosts Sendmail rejected for relaying, unknown users or bad HELO
sieveDovecot ManageSievebans failed ManageSieve logins
slapdOpenLDAP (slapd)bans clients with repeated invalid LDAP credentials (error 49)
softethervpnSoftEther VPNbans failed logins to a SoftEther VPN server
sogo-authSOGo groupwarebans failed logins to SOGo
solid-pop3dsolid-pop3dbans failed POP3 logins on solid-pop3d
squidSquid proxybans clients trying to abuse a Squid proxy (denied requests, proxy bypass attempts)
squirrelmailSquirrelMailbans failed logins to SquirrelMail webmail
sshdOpenSSH serverbans failed SSH logins: wrong passwords, invalid users, and in ddos/aggressive mode pre-auth disconnects and scans
stunnelstunnelbans clients failing TLS client-certificate checks in stunnel
suhosinSuhosin PHP hardeningbans clients that trigger Suhosin PHP security alerts
tine20Tine 2.0 groupwarebans failed logins to Tine 2.0
traefik-authTraefik reverse proxybans clients failing Basic/Digest auth in Traefik's access log (401 responses)
uwimap-authUW IMAPbans failed logins on UW IMAP
vaultwardenVaultwardenbans failed logins and wrong 2FA codes on Vaultwarden (self-hosted Bitwarden)
vsftpdvsftpdbans failed logins on vsftpd
webmin-authWebminbans failed Webmin logins
wuftpdWU-FTPDbans failed logins on WU-FTPD
xinetd-failxinetdbans hosts refused by xinetd access control
xrdpxrdp (RDP for Linux)bans failed RDP logins on xrdp 0.9.19 or newer
znc-adminlogZNC IRC bouncerbans failed ZNC logins (needs the adminlog module)
zoneminderZoneMinderbans failed logins to the ZoneMinder CCTV web console

FAQ#

Where are fail2ban filters located?#

In /etc/fail2ban/filter.d/. Each .conf file is one filter, named after the file without the extension (sshd.conf is the sshd filter). Your own changes go in a .local file with the same name, or in a new .conf file for a completely custom filter.

How many filters does fail2ban have?#

fail2ban 1.1.1 ships 96 filters, covering SSH, web servers (nginx, Apache, lighttpd), mail servers (Postfix, Dovecot, Exim, Sendmail), FTP, databases, VoIP and many web applications. Run ls /etc/fail2ban/filter.d/ to see the ones installed on your system.

Can I use one filter for several jails?#

Yes. Set filter = <name> in each jail. You can pass different parameters per jail, for example filter = postfix[mode=auth] in one jail and filter = postfix[mode=rbl] in another, which is exactly how the stock postfix-sasl and postfix-rbl jails work.

Spotted something wrong or out of date? Tell us — every page is checked against the current fail2ban release.