Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update fail2ban.md #666

Closed
wants to merge 11 commits into from
28 changes: 27 additions & 1 deletion docs/general/networking/fail2ban.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Jellyfin produces logs that can be monitored by Fail2ban to prevent brute-force
- Jellyfin remotely accessible
- Fail2ban installed and running
- Knowing where the logs for Jellyfin are stored: by default `/var/log/jellyfin/` for desktop and `/config/log/` for docker containers.
- For systemd or nftables users (Debian, Ubuntu) there are some additional steps needed, see *optional steps for systemd and nftables* at the end of this document.

### Step one: create the jail

Expand All @@ -31,7 +32,7 @@ Add this to the new file, replacing `/path_to_logs` with the path to the log fil

backend = auto
enabled = true
port = 80,443
port = 80,443,8096,8920
protocol = tcp
filter = jellyfin
maxretry = 3
Expand Down Expand Up @@ -86,3 +87,28 @@ Assuming you've at least one failed authentication attempt, you can test this ne
```bash
sudo fail2ban-regex /path_to_logs/*.log /etc/fail2ban/filter.d/jellyfin.conf --print-all-matched
```

### Optional steps for systemd and nftables

Systemd users like Debian or Ubuntu currently require some additional configs for fail2ban to work.
Change the file /etc/fail2ban/jail.d/defaults-debian.conf to:

```bash
[sshd]
enabled = true
backend = systemd

[DEFAULT]
banaction = nftables
banaction_allports = nftables[type=allports]
```

Without telling the sshd jail to use systemd as a backend, fail2ban won't even start. The `banaction` is set to send the bans to nftables instead of unused iptables.
In a similar manner, without adding the `banaction` default, fail2ban will try to use iptables that got replaced by nftables.

You also have to enable nftables to start at boot.

```bash
sudo systemctl enable nftables
sudo systemctl start nftables
```