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.

Category:

5 responses to “Bulk updating Cloudflare’s firewall rules”

  1. Rachele Zumpfe avatar
    Rachele Zumpfe

    *This really answered my problem, thank you!

  2. accurIT Presence avatar

    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

    1. accurIT Presence avatar

      Tag them…that is. : )

      1. Phil Banks avatar

        Hi Ryan,

        Next time I get a moment to look at this I’ll see if the API lets you add Tags – it should be simnple to add if it does.

        All the best,
        Phil

Leave a Reply

Your email address will not be published. Required fields are marked *