Fail2ban
- To make setup easier; set the following variables
Variables
F2BAPI_KEY="your_notifiarr_api_key_here"
F2B_HOST="$(hostname)"
Instructions
-
Open a shell on the server where Fail2ban is installed.
-
Change to the Fail2ban actions directory.
Adjust the path if your installation is different.
cd /etc/fail2ban/action.d/
- Download the Notifiarr Fail2ban action file.
curl -o notifiarr.conf https://notifiarr.com/scripts/fail2ban/notifiarr.conf
- Configure the Notification - Option A: Edit the
notifiarr.conf
file and update the hostname and API key.
nano notifiarr.conf
-
Configure the Notification - Option B: Use sed to Update the hostname and API key:
# Replace `YOUR_SERVERNAME_HERE` with your server's hostname: sed -i "s/YOUR_SERVERNAME_HERE/${F2B_HOST}/g" notifiarr.conf # Replace `YOUR_NOTIFIARR_API_KEY_HERE` with your API key: sed -i "s/YOUR_NOTIFIARR_API_KEY_HERE/${F2BAPI_KEY}/g" notifiarr.conf
-
Configure your
jail.local
file:
Open your jail configuration:
nano /etc/fail2ban/jail.local
Add notifiarr
as an action to the relevant jails or default settings:
action = notifiarr[bantime="%(bantime)s", port="%(port)s", protocol="%(protocol)s"]
- Restart Fail2ban to apply the changes.
fail2ban-client restart