介绍
# fail2ban Reporter
监控 fail2ban 封禁并自动向 AbuseIPDB 上报攻击者。
## 设置
1. 在 https://www.abuseipdb.com/account/api 获取免费的 AbuseIPDB API 密钥 2. 存储密钥:`pass insert abuseipdb/api-key` 3. 安装监控程序:`bash {baseDir}/scripts/install.sh`
## 手动使用
### 上报所有当前被封禁的 IP
```bash bash {baseDir}/scripts/report-banned.sh ```
### 检查指定 IP
```bash bash {baseDir}/scripts/check-ip.sh <ip> ```
### 显示封禁统计
```bash bash {baseDir}/scripts/stats.sh ```
## 自动上报
安装脚本会设置一个 fail2ban 动作,用于自动上报新的封禁。
```bash bash {baseDir}/scripts/install.sh # install auto-reporting bash {baseDir}/scripts/uninstall.sh # remove auto-reporting ```
## 心跳集成
将以下内容添加到 HEARTBEAT.md 以定期检查新封禁:
```markdown - [ ] Check fail2ban stats and report any unreported IPs to AbuseIPDB ```
## 工作流
1. fail2ban 封禁 IP → 动作触发 `report-single.sh` 2. 脚本使用 SSH 暴力破解类别向 AbuseIPDB 上报 3. 发送 Telegram 通知(如果已配置) 4. 将上报记录到 `/var/log/abuseipdb-reports.log`
## API 参考
完整 API 文档请参阅 [references/abuseipdb-api.md](references/abuseipdb-api.md)。