mirror of
https://gitlab.archlinux.org/archlinux/infrastructure.git
synced 2026-11-29 15:25:58 +01:00
Replace the "future plan" / "manually disable fail2ban" wording with the implemented nginx_stream_deny + nginx-stream-deny flow in the HAProxy and fail2ban runbooks. Related-to: https://gitlab.archlinux.org/archlinux/infrastructure/-/work_items/766 Assisted-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: Christian Heusel <christian@heusel.eu>
53 lines
2.1 KiB
Markdown
53 lines
2.1 KiB
Markdown
# fail2ban
|
|
|
|
Fail2Ban is an intrusion prevention software framework that protects computer servers from brute-force attacks.
|
|
|
|
By default all our servers playbook should include the `fail2ban` role which enables the `sshd` jail by default through `groups_vars`. The default `/etc/fail2ban/jail.local` configuration whitelists all the servers in `hosts`, take note that when adding a new postfix relayhost the `fail2ban` role has to be run on the postfix server to update the whitelist.
|
|
|
|
## Jails
|
|
|
|
Fail2ban can provide multiple jails for different services, to check the status of for example the `sshd` jail:
|
|
|
|
```
|
|
fail2ban-client status sshd
|
|
```
|
|
|
|
To unblock an IP Address:
|
|
|
|
```
|
|
fail2ban-client set sshd unbanip 8.8.8.8
|
|
```
|
|
|
|
### sshd
|
|
|
|
The sshd jail should be enabled for every host we have, to block brute force ssh attacks.
|
|
|
|
### postfix
|
|
|
|
The postfix jail not enabled on any server. Adding it to a host:
|
|
|
|
Add `fail2ban_jails` dict with `postfix: true` to the host's `host_vars`.
|
|
|
|
### dovecot
|
|
|
|
The dovecot jail is enabled for our mail server, blocking failed logins. Adding it to a host:
|
|
|
|
Add `fail2ban_jails` dict with `dovecot: true` to the host's `host_vars`.
|
|
|
|
### nginx_limit_req
|
|
|
|
The nginx_limit_req jail is not enabled on any server. This jail bans IPs based repeated errors on nginx error log. Default blocking is 1 hour(s). Adding to a host:
|
|
|
|
Add `fail2ban_jails` dict with `nginx_limit_req: true` to the host's `host_vars`.
|
|
|
|
The `rsslimit` zone is whitelisted from being banned with `ignoreregex`, as we
|
|
choose to not ban RSS abusers.
|
|
|
|
#### Behind the HAProxy ADN
|
|
|
|
On hosts fronted by the HAProxy ADN the default firewalld banaction does not work:
|
|
|
|
- Every packet arrives from an allowlisted ADN IP (so an ipset ban of the real client IP never matches)
|
|
- Setting `nginx_stream_deny: true` in the host's `host_vars` (see `docs/haproxy.md`) switches the `nginx_limit_req` jail to the `nginx-stream-deny` banaction, which writes `deny <ip>;` lines into `/etc/nginx/snippets/stream-fail2ban-deny.conf`.
|
|
- A systemd path unit (`nginx-stream-deny-reload`) reloads nginx with a cooldown so the deny takes effect before TLS termination.
|