AccueilGlossaire › fail2ban (Intrusion Prevention)

fail2ban (Intrusion Prevention)

Linux

Outil scannant logs et bannissant IPs avec tentatives malveillantes répétées.

fail2ban est un outil Python d'intrusion prevention scannant les logs (auth.log, secure, apache access.log, etc.) et bannissant automatiquement les IPs montrant des patterns malveillants (multiple failed SSH logins, repeated 401/403 errors, etc.) via règles iptables/nftables temporaires.

Fonctionnement : (1) **Jails** définissent ce qu'à protéger ; chaque jail spécifie : log à monitorer, filter (regex match), action (ban via firewall), max retries, find time, ban time ; (2) **Filters** dans /etc/fail2ban/filter.d/ — regex patterns reconnaissant tentative malveillante ; (3) **Actions** dans /etc/fail2ban/action.d/ — comment bannir (iptables-multiport default, nftables, route blackhole, mail notify) ; (4) bans expirent automatiquement après bantime (default 10 min, recommandé augmenter).

Configuration : (1) `/etc/fail2ban/jail.local` — override defaults (jamais éditer jail.conf) ; (2) `bantime = 1h` (ou plus long, `-1` permanent) ; (3) `findtime = 10m` (window temporelle), `maxretry = 5` ; (4) `ignoreip = 127.0.0.1/8 192.168.1.0/24` (whitelist) ; (5) enable jails : `[sshd] enabled = true`, `[apache-auth] enabled = true`, `[nginx-limit-req]`, `[postfix]`, `[dovecot]`, etc.

Commandes : (1) `fail2ban-client status` — overview ; (2) `fail2ban-client status sshd` — détails jail ; (3) `fail2ban-client set sshd banip 1.2.3.4` — manual ban ; (4) `fail2ban-client unban 1.2.3.4` ; (5) `fail2ban-regex /var/log/auth.log /etc/fail2ban/filter.d/sshd.conf` — test filter.

Alternatives modernes : CrowdSec (community-driven, blocklist sharing, plus moderne), sshguard (lighter, single-purpose). Compétences Security+, RHCSA, LFCS.

Certifications qui couvrent ce concept
Security+ RHCSA LFCS
Termes liés
OpenSSH Hardening iptables (Linux Firewall — legacy) SIEM (Security Information and Event Management)

Préparez vos certifications IT gratuitement

200+ certifications, 400 000+ questions, examens blancs chronométrés.

Voir le catalogue →
← Retour au glossaire