Pcornel
Browse topics
Options
Recent
Favorites
Linux · Technical reference

Fail2ban

Direct answer

Fail2ban watches logs for repeated failures (SSH, web logins) and bans the source address in the firewall for a time.

When to use this

Use it to reduce brute-force attempts on exposed services, or when legitimate users get banned.

First 30 seconds

1. fail2ban-client status — jails active?

2. fail2ban-client status sshd — failures and banned IPs.

3. Unban: fail2ban-client set sshd unbanip <ip>.

4. Not banning → backend/logpath matches the service's log?

5. ignoreip includes admin networks.

Operational verification

failure logged → jail filter matches → count exceeds maxretry within findtime → firewall ban for bantime

Evidence · next step

For Security → Fail2ban, continue with the first unproven Topic check: Record exact host, distribution/kernel, boot ID, time window, workload, identity and the authoritative configuration/policy source for Fail2ban. If that boundary is healthy, advance to the adjacent check: Read back the effective runtime state and precedence rather than assuming an edited file, package state or service status is active. Preserve the same host/time/identity scope and rerun the original workload before accepting recovery.

Continue only after interpreting the current observation.
Context & applicabilityCommon mistakes · platform/version boundaries
Platform / version applicability
linux
applies
Structured applicability is explicit Topic metadata; it does not infer compatibility beyond the stored rows.
At a glance

Operational reference

Fast context before you go deeper.

Platformlinux
Scope / prerequisiteUse it to reduce brute-force attempts on exposed services, or when legitimate users get banned.
What next?3 suggested next steps
Evidence1
On this pageJump to a specific section
Operational workflow

Verification & Troubleshooting

Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.

5 steps Observe → verify → isolate → change minimally → repeat the original test.
ObservedRecord what the original test actually shows

Capture the concrete output, symptom, packet, log or counter before changing anything.

Step 1 Operational evidence path Verify boundary

application auth event → journal/log backend → filter match → counter/findtime → ban action → firewall backend → expiry/unban → service result

Healthy evidence: the intended jail is enabled, test failures match the filter, ban/unban state reaches the correct backend and legitimate service access remains healthy

Step 2 Verification and output interpretation Verify boundary

Verification chain. application auth event → journal/log backend → filter match → counter/findtime → ban action → firewall backend → expiry/unban → service result

Step 3 Commands Verify boundary
fail2ban-client status
fail2ban-client status sshd
fail2ban-client set sshd unbanip 10.0.0.5
Step 4 Failure modes and next checks Narrow the fault

Suspicious evidence: wrong backend/log path, regex drift, proxy address is banned, IPv6 is missed, action backend conflicts, whitelist is broad or repeated attacks evade per-source thresholds

Step 5 Common mistakes Narrow the fault
  • Banning your own admin IP (use ignoreip).
Evidence references

Evidence · 1 on this Topic

Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.

observation · 1
Key points

Configure jails in /etc/fail2ban/jail.local (not jail.conf). Whitelist management networks with ignoreip. Make sure the jail reads the right log or journal backend. It complements, not replaces, key-only SSH.

Key checks
  • sestatus / aa-status — SELinux or AppArmor state
  • ss -tulpn — listening services
  • journalctl -u sshd -g 'Failed' — failed logins
  • ausearch -m avc,user_login -ts today — audit events (auditd)
ReferenceImportant terms & boundaries5 sections · depth on demand

What this shows and what it does not

Fail2ban is confirmed only when the intended events are detected and the expected temporary action reaches the real firewall/service path; it does not establish prevention of distributed or credential-based attacks.

In depth

fail2ban: banning repeated offenders

fail2ban watches logs for repeated failures, such as failed SSH logins, and bans the offending addresses through the firewall for a while. The jail.conf(5) manual page describes the configuration:

  • Files are read in the order jail.conf, jail.d/*.conf, jail.local, jail.d/*.local, and later files override earlier ones. The .conf files should stay untouched so upgrades are easy, with local changes in .local files.
  • A jail is enabled with enabled = true in its section.
  • Each jail combines a filter (filter.d/, regular expressions that find failures and extract the host), log sources and an action (action.d/, the commands that ban and unban).

Key options (manual)

OptionMeaning
maxretryFailures needed within findtime to trigger a ban
findtimeThe window in which failures are counted
bantimeHow long a ban lasts
ignoreipAddresses and networks never banned (management networks)
backendauto by default; systemd reads the journal (and then takes journalmatch, not logpath)
logpathLog files to watch (non-systemd backends)
banactionThe firewall action (default iptables-multiport; nftables actions exist)

A typical jail.local

host$ sudo tee /etc/fail2ban/jail.local >/dev/null <<'EOF'
[DEFAULT]
ignoreip = 127.0.0.1/8 ::1 10.99.0.0/24
bantime = 1h
findtime = 10m
maxretry = 5
banaction = nftables-multiport
backend = systemd

[sshd]
enabled = true
EOF
host$ sudo systemctl restart fail2ban
host$ sudo fail2ban-client status sshd
Status for the jail: sshd
|- Filter
|  |- Currently failed: 3
|  `- Total failed:     412
`- Actions
   |- Currently banned: 7
   `- Banned IP list:   198.51.100.23 203.0.113.77 ...
host$ sudo fail2ban-client set sshd unbanip 203.0.113.77
host$ sudo nft list ruleset | grep -A3 f2b
host$ fail2ban-client --str2sec 1d12h

What fail2ban does and doesn't do

It helps againstIt doesn't help against
Noisy brute-force attempts from single addressesDistributed attacks from many addresses
Log noiseValid stolen credentials
Simple scannersAttacks on services without a filter

Key-only SSH authentication already makes password guessing useless. fail2ban then mainly reduces noise and load. Always put your own management networks in ignoreip, so a mistyped password doesn't lock out the administrators.

Documented example, not captured output.

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.

How it works at runtime

Fail2ban is part of Security → Fail2ban. Fail2ban observes authentication/application logs and applies temporary actions such as source-address firewall bans after configured thresholds, reducing repeated automated abuse without replacing authentication hardening.

Topic-specific state model. Fail2ban observes authentication/application logs and applies temporary actions such as source-address firewall bans after configured thresholds, reducing repeated automated abuse without replacing authentication hardening.

Interpretation rule. - A banned address ≠ an attacker identity or evidence that an account is safe.

  • Fail2ban service active ≠ the intended jail sees the correct current log source and action backend.

Quick reference

Fail2ban watches logs for repeated failures and bans source IPs via the firewall.

# /etc/fail2ban/jail.local
[DEFAULT]
bantime = 1h
findtime = 10m
maxretry = 5
backend = systemd
banaction = nftables-multiport

[sshd]
enabled = true
fail2ban-client status sshd
fail2ban-client set sshd unbanip 203.0.113.7
fail2ban-regex /var/log/auth.log /etc/fail2ban/filter.d/sshd.conf

Use jail.local (not jail.conf) for changes. Fail2ban reduces noise and brute-force attempts but does not replace key-only SSH and network restrictions; whitelist admin networks with ignoreip.

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.

Limits and how it fails

Primary failure point. Fail2ban is confirmed only when the intended events are detected and the expected temporary action reaches the real firewall/service path; it does not establish prevention of distributed or credential-based attacks.

Fail2ban acts on observed authentication patterns and network banning; it does not fix authentication policy.

ReferenceConfiguration & state1 section · depth on demand

Configuration, persistence and lifecycle

Distribution/platform context. Fail2ban owns log-driven response automation; authentication service, Logging and Firewall branches own their underlying state.

Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Technical verification history

Verification history & basis

When and against what this Topic was checked. Later text edits do not count as a new check.

2026-09-14 · vendor doclinux current

Authoritative/upstream documentation reviewed for bounded claims in Security → Fail2ban. Documentation verification only; this is not observed lab or production Evidence.

Basis: https://docs.kernel.org/security/index.html · confidence 94%
Technical changelog & impact

What changed and what may be affected

Recent technical edits are separated from ordinary page timestamps. Relationship impact is advisory: it identifies nearby canonical references to review, not automatic breakage.

Related reference impactReview these references after material technical changes when their shared boundary is affected.
Terminology layer

Terms & aliases

Hover a linked term for a quick definition; click it to open its glossary entry. Aliases are other names that find this Topic in search.

Aliases that resolve here
fail2banlinux brute force protectionfail2ban jail
Embedded reference data

Quick lookup tables

Fail2ban operational reference

Topic-specific lookup boundaries, proof limits and next-step Evidence for Fail2ban.

Lookup boundaryTopic-specific referenceOperational use
Scope / effective stateFail2ban observes authentication/application logs and applies temporary actions such as source-address firewall bans after configured thresholds, reducing repeated automated abuse without replacing authentication hardening.Establish exactly what this Topic owns before crossing into another subsystem.
Fast verificationPin host + boot/time + real identity/workload → identify authoritative policy/key/trust source → read back loaded/effective runtime state → reproduce one safe allow/deny/handshake test → correlate audit/service/kernel evidence → locate first failed boundary → make the smallest persistent change → repeat original workload + regression/recovery check.Use the shortest evidence path first; a fast check is a boundary test, not blanket proof.
Verification chainapplication auth event → journal/log backend → filter match → counter/findtime → ban action → firewall backend → expiry/unban → service resultTrace requested/configured state through effective state to the observed workload result.
Failure boundaryFail2ban is proven only when the intended events are detected and the expected temporary action reaches the real firewall/service path; it does not establish prevention of distributed or credential-based attacks.Stop broad troubleshooting at the first boundary that is not supported by evidence.
Positive evidenceCorrelated Linux security/trust evidence can establish this proof path: application auth event → journal/log backend → filter match → counter/findtime → ban action → firewall backend → expiry/unban → service resultUse this observation only for the specific claim it actually supports.
Evidence limitIt does not independently prove unobserved identities, objects, policies, namespaces, endpoints or time periods. Fail2ban is proven only when the intended events are detected and the expected temporary action reaches the real firewall/service path; it does not establish prevention of distributed or credential-based attacks.Do not promote a local success signal into end-to-end or adjacent-dependency proof.
Next troubleshooting checkContinue from the first unproven security/trust boundary, capture the adjacent effective state and audit/handshake evidence, make only the demonstrated persistent change, then repeat the original workload plus recovery/regression checks.Continue to the next unresolved boundary while preserving the original test condition.

Fail2ban · operational reference

Compact Linux state, persistence, verification and boundary reference for fast lookup.

Reference boundaryFail2ban
Topic pathSecurity → Fail2ban
Runtime stateFail2ban observes authentication/application logs and applies temporary actions such as source-address firewall bans after configured thresholds, reducing repeated automated abuse without replacing authentication hardening.
Fast checks- Record exact host, distribution/kernel, boot ID, time window, workload, identity and the authoritative configuration/policy source for Fail2ban. - Read back the effective runtime state and precedence rather than assuming an edited file, package state or service status is active. - Reproduce one safe allowed/denied or handshake/access test and correlate kernel/service/audit evidence at the first relevant boundary. - Apply the smallest persistent cause-specific change, then repeat the original test plus an adjacent regression/recovery check.
Verification chainapplication auth event → journal/log backend → filter match → counter/findtime → ban action → firewall backend → expiry/unban → service result Boundary chain: local authoritative state → adjacent dependency → effective/programmed state → original workload/request → return/regression → explicit Evidence boundary. Boundary chain: local authoritative state → adjacent dependency → effective/programmed state → original workload/request → return path or regression → explicit Evidence boundary.
Failure boundaryFail2ban is proven only when the intended events are detected and the expected temporary action reaches the real firewall/service path; it does not establish prevention of distributed or credential-based attacks. Boundary chain: process/context → userspace configuration → kernel subsystem/resource → device/network/filesystem dependency → effective state → original workload.
Persistence ruleProve which configuration source owns the state, then prove that the running consumer loaded or generated the intended state.
Confirmation

Confirm action

Continue?