This tool consolidates multiple network automation scripts into a single, unified Python program (ip_provisioner.py). It facilitates IP prefix conversion, DNS provisioning via ndcli, and various network health checks (BGP/RPKI, Whois, SOA).
- Convert Prefixes (
_01_convert): Normalizes IPv4 prefixes into a list of /24 subnets. - Check BGP Advertising (
_02_check_whois): Verifies if prefixes are announced anywhere via Team Cymru Whois. - Check RPKI & IRR (
_03_check_rpki): Validates BGP announcement, Route objects, and RPKI ROA status via RIPEstat. - Check IP Usage (
_04_check_usage): Checks current IP usage statistics usingndcli. - Deploy DNS Records (
_05_deploy_dns): Batch createsArecords for all IPs in a subnet usingndcli. - Check SOA Records (
_06_check_soa): Verifies Reverse DNS Zone SOA records viadig. - Undo DNS Records (
_07_undo_dns): Bulk removesArecords from DNS.
- Python 3.6+: Uses only the standard library (Zero external dependencies; no
requirements.txtorpip installneeded). - System Tools:
ndcli: Must be installed and configured in your PATH (See ndcli documentation).dig: Required for SOA checks.
- Network Access: Required for RIPEstat and Team Cymru API checks.
-
Clone the Repository:
git clone <repository-url> cd ip-provisioning
-
Make the script executable:
chmod +x ip_provisioner.py
-
(Optional) Create an alias: Add the following to your
~/.bashrcor~/.zshrcto run the tool from anywhere:alias ip-prov='/path/to/ip-provisioning/ip_provisioner.py'
Before running the tool, add your assigned IP prefixes to input_prefix.txt.
- Format: One prefix per line (e.g.,
1.2.3.0/22). - Flexibility: It is fine to use different masks; the tool will automatically convert and expand them all into
/24subnets for the workflow.
Run the script without any arguments to enter the interactive mode.
python3 ip_provisioner.pyDirectly execute sub-commands:
python3 ip_provisioner.py convertpython3 ip_provisioner.py check-bgppython3 ip_provisioner.py check-rpkipython3 ip_provisioner.py check-usagepython3 ip_provisioner.py deploy-dnspython3 ip_provisioner.py check-soapython3 ip_provisioner.py undo-dns
The project is modularized for easier maintenance:
_00_shared/: Shared utilities andndclilogic._01_to_07_: Command modules corresponding to the menu options.
Author: Hai Dinh Tuan (me@haidinhtuan.com)
License: MIT License
Copyright (c) 2025 Hai Dinh Tuan
