Skip to content

Instantly share code, notes, and snippets.

@quanhua92
Created August 10, 2022 06:55
Show Gist options
  • Save quanhua92/59842f55829ff0b125ef9e005cf9ce3e to your computer and use it in GitHub Desktop.
Save quanhua92/59842f55829ff0b125ef9e005cf9ce3e to your computer and use it in GitHub Desktop.
Add Bunny.net Edge Server IP Address to UFW firewall
#!/bin/sh
curl -s https://bunnycdn.com/api/system/edgeserverlist -H "Accept: application/json" | jq -r .[] > /tmp/bunny_ips
echo "" >> /tmp/bunny_ips
curl -s https://bunnycdn.com/api/system/edgeserverlist/ipv6 -H "Accept: application/json" | jq -r .[] >> /tmp/bunny_ips
for ip in `cat /tmp/bunny_ips`; do ufw allow proto tcp from $ip comment 'Bunny IP'; done;
@quanhua92
Copy link
Author

This script adds the Bunny Edge Server IPs to the UFW firewall.
You will need to schedule this to run every day to add any new IP address. Need to install jq with sudo apt install jq to parse the JSON

@quanhua92
Copy link
Author

Here is a repo with Github Action to run the script everyday https://github.com/quanhua92/bunnycdn_edge_servers_list

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment