This is a very novel version of Fail2ban.
I made this since I wanted a custom solution for monitoring my server. It's tailored to my specific needs, which is:
- Easily provide log files to monitor
- Easily specify patterns to match
- Easily report when a new ban is in effect
- Ban IPs via
iptableswhen server is runningdocker
- Parse log files checking for specific patterns
- Ban IPs via
iptablesmatching the pattern inDOCKER-USERchain - Report a new ban via Slack
- Lookup IP metadata via ipapi
- install
deno
BLOCKLIST_FILE- File to permantently store IP addressesWHITELIST- Comma separated string to specify IP addresses not to banLOG_FILES- Comma separated string to specify full path to log files to check
This uses the chat.postMessage api to send reports. Please setup a slack bot
in order to get the auth bearer token.
SLACK_AUTH- Bearer tokenSLACK_CHANNEL- Channel to post in (make sure your bot is in this channel)SLACK_USERNAME- Username to post as
TAIL_LINES- number of lines to check in log files (default:500)
It's recommended to run this via cron on a schedule that suits your needs.
./run.sh- Add AbuseIPDB check (https://www.abuseipdb.com)
- Add AbuseIPDB report (https://www.abuseipdb.com)
- Provide patterns via file instead of hard code
- make bans temporary instead of permanent
- keep permanent record of banned IPs (in case of new offense) a.k.a
indefinite probation
- blocklist.txt = currently in jail
- offenders.txt = historical list of all IPs