Option 1: 축구중계 Send Alerts to Slack
✅ Step 1: Create a Slack Incoming Webhook
-
Go to: https://api.slack.com/apps
-
Create a new app → Select "Incoming Webhooks"
-
Enable Webhooks and create a Webhook URL
-
Choose a channel (e.g.,
#fail2ban-alerts
) -
Copy the Webhook URL (you'll use it in your script)
✅ Step 2: Create the Notification Script
Create a new script file:
bash
복사편집
sudo nano /etc/fail2ban/action.d/slack.conf
Paste this template:
ini
복사편집
[Definition] actionstart = actionstop = actioncheck = actionban = curl -X POST -H 'Content-type: application/json' --data '{"text":"[Fail2Ban] IP <ip> has been banned from <name> jail."}' https://hooks.slack.com/services/XXXXXXXXX/YYYYYYYYY/ZZZZZZZZZZZZZZ actionunban = curl -X POST -H 'Content-type: application/json' --data '{"text":"[Fail2Ban] IP <ip> has been unbanned from <name> jail."}' https://hooks.slack.com/services/XXXXXXXXX/YYYYYYYYY/ZZZZZZZZZZZZZZ
Replace the webhook URL with your own.
✅ Step 3: Add to Fail2Ban Jail
In /etc/fail2ban/jail.local
:
ini
복사편집
[nginx-auth] enabled = true port = http,https filter = nginx-auth logpath = /var/log/nginx/error.log maxretry = 5 bantime = 3600 findtime = 600 action = slack
Restart Fail2Ban:
bash
복사편집
sudo systemctl restart fail2ban
Now every ban/unban will notify your Slack channel with the IP and jail name.
???? Option 2: Send 축구중계 Alerts to Telegram
✅ Step 1: Set Up a Telegram Bot
-
Open Telegram, search for @BotFather
-
Create a new bot → Get the bot token
-
Send a message to the bot or your group
-
Visit:
https://api.telegram.org/bot<your_token>/getUpdates
→ This gives you your chat ID
✅ Step 2: Create Telegram Action Script
File: /etc/fail2ban/action.d/telegram.conf
ini
복사편집
[Definition] actionstart = actionstop = actioncheck = actionban = curl -s -X POST https://api.telegram.org/bot<YOUR_BOT_TOKEN>/sendMessage -d chat_id=<YOUR_CHAT_ID> -d text="[Fail2Ban] Banned IP <ip> from <name> jail." actionunban = curl -s -X POST https://api.telegram.org/bot<YOUR_BOT_TOKEN>/sendMessage -d chat_id=<YOUR_CHAT_ID> -d text="[Fail2Ban] Unbanned IP <ip> from <name> jail."
Replace <YOUR_BOT_TOKEN>
and <YOUR_CHAT_ID>
.
✅ Step 3: Activate the Telegram Alert
In /etc/fail2ban/jail.local
:
ini
복사편집
action = telegram
Restart:
bash
복사편집
sudo systemctl restart fail2ban
Boom — you’ll now get real-time ban/unban alerts in Telegram!
???? Bonus Ideas:
-
Add GeoIP lookup to show country flag and location:
bash
복사편집
geoiplookup <ip>
-
Pipe alerts into Grafana Loki or InfluxDB for dashboards
-
Use Uptime Kuma alongside for service status alerts
???? Result: Real-Time Monitoring That Works
축구중계 | Alert Speed | Setup Difficulty | Secure? |
---|---|---|---|
Slack | Instant | Easy | ✅ |
Telegram | Instant | Moderate | ✅ |
With these alerts, you’ll always know who’s knocking—and who got kicked out—in real-time, no matter where you are.
Comments on “Send Alerts to Slack”