# fail2ban - regułki dla dovecot'a

DevFeed: [fail2ban - regułki dla dovecot'a](<https://devfeed.tech/articles/fail2ban-regu-ki-dla-dovecot-a-27503.md>)

Original publisher: [Read original article](<https://gagor.pro/2011/11/fail2ban-regulki-dla-dovecota/>)

Author: Tom

Published: 2011-11-28T00:00:00Z

Content type: tutorial

Language: pl

Sources: [Tomasz Gągor](<https://devfeed.tech/sources/tomasz-gagor.md>)

Topics: [Authentication](<https://devfeed.tech/topics/authentication.md>)

Tags: [auth](<https://devfeed.tech/tags/auth.md>), [authentication](<https://devfeed.tech/tags/authentication.md>), [debian](<https://devfeed.tech/tags/debian.md>), [fail2ban](<https://devfeed.tech/tags/fail2ban.md>), [filter](<https://devfeed.tech/tags/filter.md>), [linux](<https://devfeed.tech/tags/linux.md>), [login](<https://devfeed.tech/tags/login.md>), [mail](<https://devfeed.tech/tags/mail.md>), [port](<https://devfeed.tech/tags/port.md>), [security](<https://devfeed.tech/tags/security.md>)

## AI overview

This tutorial explains how to configure fail2ban on Debian to block repeated authentication failures against Dovecot POP3 and IMAP mailboxes. It provides a custom Dovecot filter with a failregex, a jail configuration for POP3/IMAP ports, log path, retry limit, and optional timing values, followed by restarting fail2ban.

## Source excerpt

Domyślna konfiguracja fail2ban'a (na Debianie) nie zawiera reguł pozwalających na blokowanie prób włamań na skrzynki POP/IMAP dla dovecota (no chyba że korzystamy z saslauthd). Można szybko utworzyć własny zestaw filtrów co przedstawię poniżej. Tworzymy plik: /etc/fail2ban/filter.d/dovecot.conf [Definition] failregex = (?: pop3-login|imap-login): .*(?:Authentication failure|Aborted login \(auth failed|Aborted login \(tried to use disabled|Disconnected \(auth failed|Aborted login \(\d+ authentication attempts).*rip=(?P<host>\S*),.* ignoreregex = Później dopisujemy na końcu pliku: /etc/fail2ban/jail.conf [dovecot] enabled = true filter = dovecot port = pop3,pop3s,imap,imaps logpath = /var/log/mail.log maxretry = 20 # te dwa poniżej wedle uznania - ja mam dobrze ustawione default'y #findtime = 1200 #bantime = 1200 Zostało zrestartować fail2ban'a: