How do I bulk add IP addresses to firewall?

February 11, 2018 107 views
Firewall Configuration Management

I have ~60 IPs to whitelist and would like to paste the entire list into each of the rules but can't. It seems to only allow single IP entry at a time. is there a way to to add the entire list with a copy and paste?

1 Answer

It doesn't look like the cloud control panel UI allows you to paste in multiple IP Addresses at once. That's a good idea for a UI improvement.

In the meantime you can definitely do it via the API...

Here is a curl command you can run to create a new Firewall with multiple IP addresses allowed on an inbound rule TCP port 22 rule on a specific droplet:

curl -X POST -H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_DIGITALOCEAN_API_TOKEN" \
-d '{"name":"My-Firewall", "inbound_rules":[{"droplet_ids":[DROPLETID], "protocol":"tcp", "ports":22, "sources":{"addresses":["JSON.ARRAY.OF", "ALL.THE.IP.ADDRESSES", "YOU.WANT.TO.ADD"] } } ] }' \
Have another answer? Share your knowledge.