Bulk updating Cloudflare’s firewall rules

I’ve been using Cloudflare recently and overall it’s extremely straightforward, but there was one small fly in the ointment – the firewall settings.

Currently you can only enter single IPv4 addresses at once (ranges like x.x.x.x-x aren’t valid either). Luckily they have a very easy to use API so I put together a quick form that does a bulk update of your rules.

You can only do one “action” at once (whitelisting / blacklisting / removing), but if you need anything more complicated I’m surprised you’re here… The API is also smart enough that it doesn’t moan if you ask it to, e.g., whitelist an IP that is already whitelisted.

You can download it on GitHub, and as always pull requests are welcome.

Comments

  1. Super sweet! Maybe I’m missing something, but it would be cool if we could add notes to the entries. For example, I’m bulk uploading a long list of IPs for ManageWP and I’d like to take them all as “ManageWP”.

    Either way…very nice work.
    Ryan

Leave a Reply

Your email address will not be published.