2025-05-09 13:18:20 +00:00

69 lines
2.0 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 📡 Fail2Ban Discord Alert
Ein Python-basiertes Monitoring-Tool, das automatisch IP-Sperren aus der `fail2ban.log` erkennt und sie mit Länderflagge und Geodaten in Echtzeit an einen Discord-Webhook sendet.
---
## 🔧 Features
- ✅ Überwachung von `/var/log/fail2ban.log` in Echtzeit
- 🛡️ Versand von Discord-Embed-Nachrichten bei neuen IP-Bans
- 🌍 Geo-IP-Lookup mit Ländererkennung via [ipapi.co](https://ipapi.co)
- 🇩🇪🇺🇸 Automatische Anzeige von Länderflaggen im Embed
- 🧠 SQLite-Datenbank zur Vermeidung doppelter Benachrichtigungen
- 📁 `.env`-Konfigurationsdatei für sicheren Webhook-Zugriff
- 🧰 Automatischer Systemd-Service für dauerhaftes Monitoring
---
## 📦 Voraussetzungen
- Linux mit systemd
- Python 3.6+
- Zugriff auf `/var/log/fail2ban.log`
- Funktionierender Fail2Ban-Dienst
- Ein Discord-Webhook-Link
---
---
## ⚙️ Dateien im Projekt
| Datei | Funktion |
|--------------------------------|-----------------------------------------------|
| `fail2ban_discord.py` | Hauptmonitor-Skript |
| `.env` | Webhook-Konfiguration (wird befüllt) |
| `requirements.txt` | Python-Abhängigkeiten |
| `install_fail2ban_discord.sh` | Installationsskript inkl. systemd-Anbindung |
| `bans.db` | SQLite-Datenbank für verarbeitete IPs |
---
## 🔁 Service-Verwaltung
```bash
# Status prüfen
systemctl status fail2ban_discord_alert.service
# Dienst starten/stoppen
sudo systemctl start fail2ban_discord_alert.service
sudo systemctl stop fail2ban_discord_alert.service
```
---
## 🧪 Test-Webhook erneut senden
```bash
curl -H "Content-Type: application/json" \
-X POST \
-d '{"content": "✅ Testnachricht vom Fail2Ban Discord Alert!"}' \
"$(grep DISCORD_WEBHOOK_URL .env | cut -d '=' -f2)"
```
## 📄 Lizenz
MIT License frei verwendbar, auch in kommerziellen Umgebungen.