Console9

Fail2Ban jail.local directives reference

Complete reference for Fail2Ban configuration directives in jail.local including ban thresholds and actions.

Fail2Ban jail.local directives reference

Complete reference for Fail2Ban configuration directives in jail.local including ban thresholds and actions.

Fail2Ban [DEFAULT] Section Directives

DirectiveDescriptionDefaultExample
bantimeDuration an IP is banned. Accepts seconds or time suffixes (m, h, d).10mbantime = 1h
findtimeTime window during which maxretry failures must occur to trigger a ban.10mfindtime = 10m
maxretryNumber of failures within findtime before Fail2Ban bans the IP.5maxretry = 3
ignoreipSpace-separated list of IPs, CIDR ranges, or hostnames to never ban.127.0.0.1/8 ::1ignoreip = 127.0.0.1/8 203.0.113.10
backendHow Fail2Ban reads log files. Values: auto, systemd, pyinotify, polling.autobackend = systemd
banactionAction to execute when banning an IP. Refers to a file in /etc/fail2ban/action.d/.iptables-multiportbanaction = nftables-multiport
banaction_allportsAction to execute for all-port bans.iptables-allportsbanaction_allports = ufw
actionCombined action template. action_ (ban only), action_mw (ban + whois email), action_mwl (ban + whois + log lines).%(action_)saction = %(action_mwl)s

Fail2Ban Jail Directives

DirectiveDescriptionDefaultExample
enabledWhether the jail is active. Must be true to function.falseenabled = true
portPort(s) to block in the ban action. Accepts names or numbers.service-specificport = http,https
filterFilter file name (without .conf) from /etc/fail2ban/filter.d/.jail namefilter = sshd
logpathPath to the log file Fail2Ban monitors. Supports glob patterns.service-specificlogpath = /var/log/nginx/error.log
journalmatchsystemd journal match expression (used with backend = systemd).nonejournalmatch = _SYSTEMD_UNIT=sshd.service

Fail2Ban Filter Directives

DirectiveDescriptionExample
failregexPython regex pattern(s) matching failed authentication log lines. <HOST> captures the offending IP.failregex = ^Failed password for .* from <HOST>
ignoreregexRegex pattern(s) to exclude from matching even if failregex matches.ignoreregex = ^.* from 127\.0\.0\.1$
datepatternCustom date/time format if Fail2Ban cannot auto-detect the timestamp.datepattern = %%Y-%%m-%%d %%H:%%M:%%S