Add Discord webhook notification action

This commit is contained in:
Yankee030 2025-12-03 14:16:27 -05:00
parent ef65652671
commit fda4701633

View file

@ -0,0 +1,51 @@
# Fail2Ban configuration file for Discord Webhook notifications
#
# Author: JY
#
#
# [Usage]
#
# To enable this action, add the following to your jail.local file:
#
# [DEFAULT]
# action = %(action_)s
# discord-webhook[webhook="YOUR_DISCORD_WEBHOOK_URL"]
#
# Or for a specific jail:
#
# [sshd]
# action = discord-webhook[webhook="YOUR_DISCORD_WEBHOOK_URL"]
#
[Definition]
# Option: actionstart
actionstart = curl -X POST -H "Content-Type: application/json" \
-d '{"content": ":white_check_mark: [Fail2Ban] Jail **<name>** has been started on **<fq-hostname>**."}' \
<webhook>
# Option: actionstop
actionstop = curl -X POST -H "Content-Type: application/json" \
-d '{"content": ":octagonal_sign: [Fail2Ban] Jail **<name>** has been stopped on **<fq-hostname>**."}' \
<webhook>
# Option: actioncheck
actioncheck =
# Option: actionban
actionban = curl -X POST -H "Content-Type: application/json" \
-d '{"content": ":lock: [Fail2Ban] **BANNED** \n**Jail:** <name>\n**IP:** <ip>\n**Failures:** <failures>\n**Host:** <fq-hostname>"}' \
<webhook>
# Option: actionunban
actionunban = curl -X POST -H "Content-Type: application/json" \
-d '{"content": ":unlock: [Fail2Ban] **UNBANNED** \n**Jail:** <name>\n**IP:** <ip>\n**Host:** <fq-hostname>"}' \
<webhook>
[Init]
# Default name of the jail
name = default
# Discord Webhook URL (Override this in your jail.local)
webhook = https://discord.com/api/webhooks/your-default-webhook