Subnet Divider is a bash script that helps you divide IP ranges into smaller-sized subnets. This script accepts either an IP range or a file containing multiple IP ranges as input and creates a list of mutually exclusive subnets based on the user-specified subnet size. It supports IPv4 with CIDR range notation.
- Divides IP ranges into subnets
- Supports both single IP ranges and an input file containing IP ranges split by new lines
- User-specified subnet size
- Outputs subnets into a file
- Combines previous outputs by removing duplicate ranges and sorting them all together
- [Optional] Split the output file into multiple files based on a user-specified maximum number of lines per file
- Clone the repository:
git clone https://github.com/rahgozar94725/Subnet-Divider.git
- Navigate to the repository directory:
cd Subnet-Divider
- Make the script executable:
chmod +x subnet-divider.sh
./subnet-divider.sh -i <IP_RANGE_OR_FILE> [--output <OUTPUT_FILE>] [--subnet <SUBNET_BITS>] [--lines <MAX_LINES>]
-i <IP_RANGE_OR_FILE>
,--input <IP_RANGE_OR_FILE>
: IP range or a file containing IP ranges.-o <OUTPUT_FILE>
,--output <OUTPUT_FILE>
(optional): The output file name [Default: Based on input file name]-s <SUBNET_BITS>
,--subnet <SUBNET_BITS>
(optional): Target subnet size in bits. [Default: 24]-l <MAX_LINES>
,--lines <MAX_LINES>
(optional): Maximum lines per file for splitting the output. [Default: No splitting]
Divide a single IP range:
./subnet-divider.sh -i 192.168.0.0/16
Extract IP ranges from a file, designate an output file, specify the desired subnet size, and divide the resulting output into multiple files, each containing 100 lines:
./subnet-divider.sh --input ip_ranges.txt --output output.txt --subnet 16 --lines 100
If you find this script useful, please consider giving it a star on GitHub. It boosts the project's visibility and encourages further development.
If you find this script helpful and would like to support its development and maintenance, you can donate using the cryptocurrencies:
Your donations will be greatly appreciated (But not required) and will contribute to this project's ongoing improvement and support.