IP List Manager is a tool that automates tasks the synchronization of IP lists across multiple Cloudflare accounts. It is designed to help Cloudflare users efficiently manage allowlists, blocklists, and trusted IP ranges.
cf-box % python3 cloudflare_ip_list_manager.py
📌 Managing IP lists for F************i@g****.com's Account (ID: 1e7ed1...0fbe52)
📌 Managing IP lists for L********o@g****.com's Account (ID: b2f381...099a43)
📄 Report saved: reports/cf_sync_2025-01-31_11-29-56.md
Warning
Set your GitHub repository visibility to private before to populate config.yaml and execute the runner.
- ✅ Automatic IP list synchronization with Cloudflare's API.
- ✅ Supports multiple accounts and IP lists via a YAML configuration.
- ✅ Fetches IPs from external sources (JSON and plaintext).
- ✅ Caches IP lists locally to avoid unnecessary API requests.
- ✅ Optimized bulk update to avoid multiple requests for rulesets endpoints.
- Python 3.7+
requestspyyaml
pip install -r requirements.txtThe script uses a config.yaml file to define accounts, IP lists, and sources.
accounts:
- id: "1e7ed1e7e9b2dfdfb15ed609d30fbe52"
name: "Example Cloudflare Account"
lists:
- name: "trusted_aws_ips"
sync_from: "https://raw.githubusercontent.com/lord-alfred/ipranges/main/aws.json"
type: "json"
- name: "bad_ips"
sync_from: "https://github.com/stamparm/ipsum/raw/refs/heads/master/levels/3.txt"
type: "text"
notifications:
webhook: "https://your-webhook-url.com"Ensure your Cloudflare API token is set as an environment variable or as GitHub Actions Repository Secret:
export CLOUDFLARE_API_TOKEN="your_cloudflare_api_token"python cloudflare_ip_list_manager.py- Reads the
config.yamlfor accounts and IP list definitions. - Fetches the current Cloudflare IP lists to compare with external sources.
- Downloads IPs from the specified sources (JSON or plaintext files).
- Checks for changes to avoid unnecessary API updates.
- Bulk updates Cloudflare IP lists to comply with rate limits.
- Caches results to minimize external requests.
- Cloudflare limits API requests to ~1,200 per 5 minutes per account.
- The script uses a single bulk update instead of multiple small updates.
- Implements 300-600s backoff when rate-limited.
Feel free to submit pull requests and improve the project.
This project is licensed under the MIT License.
This tool is not affiliated with or officially supported by Cloudflare.