A CLI tool for fetching and managing CIDR IP ranges from RIRs with firewall integration.
Project description
CIDRe is a CLI tool that fetches daily updated IP allocations from Regional Internet Registries (RIRs), compiles them into country-based CIDR files, and allows easy firewall management (e.g., blocking entire countries in UFW).
🔹 Supports AFRINIC, APNIC, ARIN, LACNIC, RIPE NCC
🔹 Merges and optimizes CIDR blocks for efficiency
🔹 Firewall integration (UFW support)
🔹 IPv4 & IPv6 compatible
⚡ Quick Start
1️⃣ Install CIDRE
pip install cidre-cli
2️⃣ Pull & Merge CIDR Ranges
cidre pull --merge
- Downloads the latest CIDR allocations from RIRs.
- Merges overlapping IP ranges for efficiency.
3️⃣ Block Specific Countries in UFW
cidre deny ru ir kp
- Blocks Russia (RU), Iran (IR), and North Korea (KP) in UFW.
- Requires UFW installed (
sudo apt install ufw).
4️⃣ Allow Specific Countries in UFW
cidre allow us gb de
- Allows United States (US), United Kingdom (GB), and Germany (DE) IPs in UFW.
5️⃣ Reject (Drop) Traffic from Specific Countries
cidre reject cn ru
- Rejects (drops) traffic from China (CN) and Russia (RU).
🚀 Features
- Daily automatic CIDR updates.
- Compiles CIDR blocks per country from RIR allocation data.
- Merges overlapping IP ranges for efficiency.
- Allows easy firewall rules for blocking or allowing entire countries.
- Supports both IPv4 & IPv6.
🛠️ Installation
1️⃣ Install via PyPI
pip install cidre-cli
2️⃣ Alternative: Clone the Repository
git clone https://github.com/vulnebify/cidre-cli.git
cd cidre-cli
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
chmod +x cidre-cli.py
⚡ Usage
1️⃣ Pull and Compile CIDR Ranges
Fetches the latest IP allocation data from all RIRs and compiles per-country CIDR blocks:
cidre pull --merge
--merge: Merges overlapping IP ranges for efficiency.--proxy <proxy>: Proxies connection to RIRs.--store <path>: Specifies a custom storage directory.- Output Example:
output/cidr/ipv4/us.cidr(United States IPv4 ranges)output/cidr/ipv6/de.cidr(Germany IPv6 ranges)
2️⃣ Block Entire Countries with UFW
Block specific countries' CIDR blocks in UFW firewall:
cidre deny ru ir kp
- Blocks Russia (RU), Iran (IR), and North Korea (KP) in the Uncomplicated Firewall (UFW).
- Requires UFW installed (
sudo apt install ufwon Debian/Ubuntu).
3️⃣ Allow Specific Countries
cidre allow us gb de
- Allows United States (US), United Kingdom (GB), and Germany (DE) IPs in UFW.
4️⃣ Reject (Drop) Traffic from Specific Countries
cidre reject cn ru
- Rejects (drops) traffic from China (CN) and Russia (RU).
📄 License
This project is licensed under the MIT License.
🙌 Inspired By
CIDRE was inspired by herrbischoff/country-ip-blocks and aims to provide an automated alternative with firewall integration.
🤝 Contributions
PRs are welcome! Feel free to fork the repo and submit pull requests.
📧 Contact
For any questions, open an issue or reach out via GitHub Discussions.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cidre-cli-1.0.3.tar.gz.
File metadata
- Download URL: cidre-cli-1.0.3.tar.gz
- Upload date:
- Size: 3.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
290af9b33fb0871d626855b008e204be496d754e08a101811ef6ad4f229b59e4
|
|
| MD5 |
7173b12a797bc681b8821ef227734409
|
|
| BLAKE2b-256 |
cc904239e7c29b2a0f884d1f77bed9bd2aeb826fe75f10932f5fcb93d0f43cec
|
File details
Details for the file cidre_cli-1.0.3-py3-none-any.whl.
File metadata
- Download URL: cidre_cli-1.0.3-py3-none-any.whl
- Upload date:
- Size: 3.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
441b8dba7403da4381aa7026655cef62156db6a1c0520073d1a7392c23b3512f
|
|
| MD5 |
b6b3c5bf4dc0df332b859ad29ab4d2c5
|
|
| BLAKE2b-256 |
52523d5d4785d004094cffdd14db76c0d7147863e20ca9774cf17895dea8aa99
|