The IP Calculator is a command-line tool written in Rust designed to calculate and manipulate IP addresses, subnets, and ranges. This utility provides various operations such as validating IP addresses, masks, and CIDR notations, calculating subnets, and finding ranges of addresses.
Validate if an IP address, mask, or CIDR is correctly formatted.
Perform subnet calculations based on a given CIDR and prefix.
Retrieve a specific subnet by index.
Check if two IP addresses belong to the same subnet.
Find ranges of IP addresses within a given CIDR.
Display help and command usage information.
- Rust (latest statble version)
- Rust standard library
- Clone the repository
git clone https://github.com/nightwolf-1/ip_calculator.git
cd ip_calculator
- Build the program
cargo build --release
- The binary will be avialable in the target/release directory
./target/release/ip_calculator <command> <arguments>
The program accepts a variety of commands, each designed for a specific task. Below is a list of supported commands and their usage:
./ip_calculator <command> <arguments>
- -h or --help: Displays the list of available commands or detailed help for a specific command.
./ip_calculator --help
./ip_calculator --help <command>
- -s or --subnets: Calculate subnets for a given CIDR and prefix. Supports optional filters and pagination.
./ip_calculator -s <CIDR> <prefix> [-f <number_of_subnets>] [-p <page_number>]
- --get-subnet: Retrieve a specific subnet by index.
./ip_calculator --get-subnet <CIDR> <prefix> <index>
- -same or --same-subnet: Check if two IP addresses belong to the same subnet. Optionally supports different masks for the two addresses.
./ip_calculator -same <IP1> <IP2> <mask1> [mask2]
- -cip or --check-ip: Validate if an IP address is correctly formatted.
./ip_calculator -cip <IP>
- -cmask or --check-mask: Validate if a mask is correctly formatted.
./ip_calculator -cmask <mask>
- -fr or --find-range: Find ranges of addresses within a given CIDR.
./ip_calculator -fr <CIDR> <number_of_hosts> [excluded_IPs...]
- CIDR: Display details about a given CIDR without additional commands.
./ip_calculator <CIDR>
./ip_calculator <IP> <mask>