This Python script allows users to convert CIDR blocks into their addressable IP addresses. It supports processing a single CIDR block or multiple blocks provided in a file.
- Converts a single CIDR block into a list of addressable IPs.
- Processes files containing multiple CIDR blocks (one per line).
- Validates input and handles errors gracefully.
- Python 3.6 or later.
- Clone the repository or download the script file.
- Ensure Python is installed on your system.
Run the script from the command line using the following syntax:
python script.py <CIDR_BLOCK>
Example:
python script.py 192.168.1.0/30
Output:
192.168.1.1
192.168.1.2
python script.py <FILE_PATH> --file
Example:
python script.py cidr_list.txt --file
Output:
192.168.1.0/30:
192.168.1.1
192.168.1.2
10.0.0.0/29:
10.0.0.1
10.0.0.2
10.0.0.3
input
: Required. Accepts a CIDR block (e.g.,192.168.1.0/24
) or a file path.-f
,--file
: Optional. Indicates that the input is a file containing CIDR blocks.
- Invalid CIDR blocks will produce an error message without crashing the script.
- Missing files will prompt a "File not found" message.
For processing multiple CIDR blocks, create a text file (cidr_list.txt
) with each CIDR block on a separate line:
192.168.1.0/30
10.0.0.0/29
172.16.0.0/28