Fail2Ban configuration and CLI tool to update Cloudflare Custom IP Lists
-
A Cloudflare API Token with the following permissions (Docs):
Account:Account Filter Lists:Edit
Account:Account Filter Lists:Read
Account:Account Settings: Read
-
A Cloudflare Custom IP List (Docs)
A Fail2Ban Action configuration file. On most systems this belongs in /etc/fail2ban/actions.d
A CLI shell utility for adding and removing IP address from a Cloudflare Custom IP List
Requires CF_API_TOKEN environment variable containing a Cloudflare API Token
Usage:
cloudflare-iplist -l <list> -a <action> -i <ip>
Options:
-l <list> name of the IP list.
-a <action> action of operation. Can be 'add' or 'remove'.
-i <ip> IP address to add or remove.
Example:
cloudflare-iplist -l my_blocklist -a add -i 192.0.2.0
A simple Docker container defintion based on binbashing/fail2ban with cloudflare-iplist installed