Skip to main content

A CLI tool for fetching and managing CIDR IP ranges from RIRs with firewall integration.

Project description

📡 CIDRe - CIDR Enhanced

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: 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 ufw on 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cidre_cli-1.0.1.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cidre_cli-1.0.1-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file cidre_cli-1.0.1.tar.gz.

File metadata

  • Download URL: cidre_cli-1.0.1.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.0

File hashes

Hashes for cidre_cli-1.0.1.tar.gz
Algorithm Hash digest
SHA256 509a706ca6fb106190ffe04da70d4ea100cb290424360d4b29fcbabbfd2688f6
MD5 f5b631183fc5797f4c87639c0d474c63
BLAKE2b-256 a48facee576ecac26de729fee5e4bcd72063a151b6141612bcfa932d826a6888

See more details on using hashes here.

File details

Details for the file cidre_cli-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: cidre_cli-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 7.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.0

File hashes

Hashes for cidre_cli-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5c110d0efa253ee76673aa135fb2edf57e04b2f26904b1cbb3e1a95e15d168ed
MD5 0a28887c6106e1c919516f87c7e7e4cc
BLAKE2b-256 f0551cf5815371fa10f9f2317be75d7093bad2dbceb8aada0a7678e908191747

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page