Fail2ban Integration
Escalate Fail2ban bans against IPs that ipinsights.io already knows are bad.
Overview
There are two useful patterns here. (A) Maintain a local Fail2ban jail that bans every IP on the ipinsights.io blocklist outright. (B) Use a custom action on your existing jails that queries the ipinsights.io API at ban-time and applies a longer ban for repeat offenders. We'll set up both.
Prerequisites
- Fail2ban 0.11+ with iptables, nftables or firewalld backend
curlandjqon the host- Optional: an ipinsights.io API key (only needed for the live-lookup action below) — see your profile page
Pattern A — Blocklist Tail Jail
Mirror the blocklist locally and have Fail2ban tail the file. A new IP appearing in the file triggers an immediate ban.
/usr/local/bin/ipinsights-mirror.sh:
Schedule it hourly (cron or systemd timer). Then create the filter at
/etc/fail2ban/filter.d/ipinsights-blocklist.conf:
And the jail in /etc/fail2ban/jail.d/ipinsights.local:
Pattern B — Reputation-Aware Action
Drop in an action that queries ipinsights.io for every IP a jail bans, and
escalates the ban if the IP is known-bad. Create
/etc/fail2ban/action.d/ipinsights-escalate.conf:
/usr/local/bin/ipinsights-escalate.sh:
Attach to an existing jail by adding the action, for example to sshd:
Verify
API Key: Pattern A needs no key. Pattern B requires one, stored at
/etc/fail2ban/ipinsights.key (root-readable only).
Request Higher API Limit
Running a high-volume Fail2ban deployment? If the default rate limit isn't enough for your environment, submit a request below and we'll review it.