This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| computing:fail2ban [2026/03/22 15:24] – oemb1905 | computing:fail2ban [2026/03/22 21:31] (current) – oemb1905 | ||
|---|---|---|---|
| Line 11: | Line 11: | ||
| ------------------------------------------- | ------------------------------------------- | ||
| - | This tutorial is designed to help you install fail2ban and get a basic set of configurations in place. | + | This tutorial is designed to help you install fail2ban and get a basic set of configurations in place. |
| + | |||
| + | //My defaults give a very small 1 hour punishment for first time offense of 3 violations of any jail. Repeat offenders, however, get immediate life-bans. So, the default is very tolerant and the extreme is essentially for life punishment. Using this framework, you override individual services with '' | ||
| + | |||
| + | You will need to change this recipe to fit your needs. At the same time, there are certain aspects in this tutorial, that are just " | ||
| sudo cp / | sudo cp / | ||
| Line 40: | Line 44: | ||
| logpath = %(sshd_log)s | logpath = %(sshd_log)s | ||
| backend = %(sshd_backend)s | backend = %(sshd_backend)s | ||
| - | maxretry = 1 | + | maxretry = 3 |
| The repeat offender, or recidivist jail, is listed under '' | The repeat offender, or recidivist jail, is listed under '' | ||
| Line 190: | Line 194: | ||
| EOF | EOF | ||
| + | mkdir -p /home/logs | ||
| sudo chmod 750 / | sudo chmod 750 / | ||
| </ | </ | ||
| Line 197: | Line 202: | ||
| 0 * * * * / | 0 * * * * / | ||
| - | --- // | + | Create a custom jail for postfix floods, for example: |
| + | |||
| + | < | ||
| + | cat << ' | ||
| + | |||
| + | [postfix-flood-attack] | ||
| + | enabled | ||
| + | maxretry = 1 | ||
| + | filter | ||
| + | action | ||
| + | logpath | ||
| + | |||
| + | EOF | ||
| + | |||
| + | # 2. Create the filter definition | ||
| + | cat << ' | ||
| + | [Definition] | ||
| + | failregex = lost connection after AUTH from (.*)\[< | ||
| + | ignoreregex = | ||
| + | EOF | ||
| + | |||
| + | # Set permissions and reload the jail | ||
| + | chmod 750 / | ||
| + | systemctl restart fail2ban.service | ||
| + | </ | ||
| + | |||
| + | --- // | ||