SkillAgentSearch skills...

SubnetCalculator

Powerful CLI toolkit for IP networking calculations, subnet/supernet planning, and CIDR address management. Master IPv4 subnetting, VLSM/FLSM calculations, and route aggregation with ease. Simplifying complex network tasks for engineers, administrators, and students.

Install / Use

/learn @nazdridoy/SubnetCalculator

README

Subnet Calculator (subcalc)

Powerful CLI toolkit for IP networking calculations, subnet/supernet planning, and CIDR address management. Master IPv4 subnetting, VLSM/FLSM calculations, and route aggregation with ease. Simplifying complex network tasks for engineers, administrators, and students.

License: MIT Python 3.6+ Platform

Features

  • Network Information: Display detailed information about any IP network
  • VLSM Calculation: Create optimally-sized subnets based on specific host requirements
  • FLSM Calculation: Create equal-sized subnets based on either:
    • Number of required subnets
    • Specific prefix length
  • Notation Conversion: Easily convert between:
    • CIDR notation (e.g., /24)
    • Subnet masks (e.g., 255.255.255.0)
    • Wildcard masks (e.g., 0.0.0.255)
  • IP Address Utilities: Tools for IP address analysis:
    • IP validation and classification
    • Check if an IP is within a subnet
    • Analyze IP address ranges
  • Supernetting/CIDR Aggregation: Efficient route summarization:
    • Aggregate multiple networks into optimal CIDR blocks
    • Find the smallest common supernet
    • Analyze common network prefixes
  • Interactive Mode: User-friendly interactive input with command history and editing
  • Command-line Mode: Scriptable operation for automation

SubnetCalculator screenshot showing example output of subnet calculation results

Installation

Clone the repository

git clone https://github.com/nazdridoy/SubnetCalculator.git
cd SubnetCalculator

Make the script executable

chmod +x subcalc

Usage

Network Summary

Display detailed information about a network:

./subcalc --network 192.168.0.0/24

FLSM Subnet Calculation

Create equal-sized subnets in two ways:

  1. By number of subnets:
./subcalc --network 192.168.0.0/24 --flsm 8
  1. By specific prefix length:
./subcalc --network 192.168.0.0/24 --flsm /28

VLSM Subnet Calculation

Create optimally-sized subnets based on host requirements:

./subcalc --network 192.168.0.0/24 --vlsm 50 30 10 5

Interactive Mode

Run the tool interactively:

./subcalc --flsm     # For FLSM calculation
./subcalc --vlsm     # For VLSM calculation

Notation Conversion

Convert between CIDR, subnet mask, and wildcard mask notations:

./subcalc --convert /24               # Convert from CIDR notation

./subcalc --convert 255.255.255.0 # Convert from subnet mask notation ./subcalc --convert 0.0.0.255 # Convert from wildcard mask notation ./subcalc --convert # Run in interactive mode


### IP Address Utilities

#### Validate an IP Address
Validate an IP address and display information about it:

```bash
./subcalc --validate 192.168.1.1      # Validate a specific IP
./subcalc --validate                  # Run in interactive mode

Check if an IP is within a Network

Check if an IP address belongs to a specified network:

./subcalc --check-ip 192.168.1.5 192.168.1.0/24  # Check IP in network
./subcalc --check-ip 10.0.0.1                    # Prompt for network
./subcalc --check-ip                             # Fully interactive mode

Analyze IP Address Range

Calculate information about an IP address range:

./subcalc --range 192.168.1.10 192.168.1.20  # Analyze specific range
./subcalc --range 10.0.0.1                   # Prompt for end IP
./subcalc --range                            # Fully interactive mode

Supernetting/CIDR Aggregation

Aggregate multiple subnets into optimal summary routes:

# Find efficient summary routes for multiple networks
./subcalc --supernet 192.168.1.0/24 192.168.2.0/24 192.168.3.0/24

# Run in interactive mode
./subcalc --supernet

Command-line Arguments

usage: subcalc [-h] [--network NETWORK] [--version] [--vlsm [VLSM ...]] [--flsm [FLSM]] [--convert [CONVERT]]
               [--validate [VALIDATE]] [--check-ip [CHECK_IP ...]] [--range [RANGE ...]]
               [--supernet [SUPERNET ...]]

Subnet Calculator Tool - Calculate and display subnet information

options:
  -h, --help            show this help message and exit
  --network NETWORK     Base network address in CIDR notation (e.g., 192.168.0.0/24)
  --version, -v         Show program version and exit
  --vlsm [VLSM ...]     Run Variable Length Subnet Mask calculator with specified host requirements (e.g., --vlsm 20 40 80)
  --flsm [FLSM]         Run Fixed Length Subnet Mask calculator with number of subnets (e.g., --flsm 4) or target prefix length (e.g., --flsm /28)
  --convert [CONVERT]   Convert between CIDR, subnet, and wildcard masks (e.g., --convert /24 or --convert 255.255.255.0)
  --validate [VALIDATE]
                        Validate an IP address and show its properties (e.g., --validate 192.168.1.1)
  --check-ip [CHECK_IP ...]
                        Check if an IP address is in a network (e.g., --check-ip 192.168.1.5 192.168.1.0/24)
  --range [RANGE ...]   Analyze an IP address range (e.g., --range 192.168.1.10 192.168.1.20)
  --supernet [SUPERNET ...]
                        Find optimal summary routes for multiple subnets (e.g., --supernet 192.168.1.0/24 192.168.2.0/24)

Examples:
  ./subcalc --network 192.168.0.0/24                    # Display network summary
  ./subcalc --network 192.168.0.0/24 --flsm 16          # Create 16 equal-sized subnets

  ./subcalc --network 192.168.0.0/24 --flsm /28         # Create subnets with prefix /28
  ./subcalc --network 192.168.0.0/24 --vlsm 20 40 50    # Create subnets with specified host capacities
  ./subcalc --flsm                                      # Run FLSM in interactive mode
  ./subcalc --vlsm                                      # Run VLSM in interactive mode
  ./subcalc --convert /24                               # Convert between CIDR, subnet mask, and wildcard mask
  ./subcalc --convert 255.255.255.0                     # Convert between notations using subnet mask
  ./subcalc --convert                                   # Run conversion tool in interactive mode
  ./subcalc --validate 192.168.1.5                      # Validate an IP address and display information
  ./subcalc --check-ip 192.168.1.5 192.168.1.0/24       # Check if an IP address is in a network
  ./subcalc --range 192.168.1.10 192.168.1.20           # Analyze an IP address range
  ./subcalc --supernet 192.168.1.0/24 192.168.2.0/24    # Find optimal summary routes for multiple subnets
  ./subcalc --supernet                                  # Run supernetting tool in interactive mode

Example Outputs

Network Summary


Network Summary for 192.168.0.0/24:
Network Address:     192.168.0.0
Broadcast Address:   192.168.0.255
Netmask:             255.255.255.0
Prefix Length:       /24
Number of Addresses: 256
Usable Hosts:        254
First Usable Host:   192.168.0.1
Last Usable Host:    192.168.0.254

FLSM Output


FLSM Summary:
Base Network:         192.168.0.0/24
Subnet Bits:          2
New Prefix Length:    /26
Subnet Mask:          255.255.255.192
Hosts per Subnet:     62
Requested Subnets:    4
Actual Subnets:       4
Unused Subnets:       0

+----------+------------------+-----------------+---------------+---------------+---------------+---------------+-------+
| Subnet   | CIDR Notation    | Subnet Mask     | Network ID    | Broadcast ID  | First Host IP | Last Host IP  | Hosts |
+----------+------------------+-----------------+---------------+---------------+---------------+---------------+-------+
| Subnet 1 | 192.168.0.0/26   | 255.255.255.192 | 192.168.0.0   | 192.168.0.63  | 192.168.0.1   | 192.168.0.62  | 62    |
+----------+------------------+-----------------+---------------+---------------+---------------+---------------+-------+
| Subnet 2 | 192.168.0.64/26  | 255.255.255.192 | 192.168.0.64  | 192.168.0.127 | 192.168.0.65  | 192.168.0.126 | 62    |
+----------+------------------+-----------------+---------------+---------------+---------------+---------------+-------+
| Subnet 3 | 192.168.0.128/26 | 255.255.255.192 | 192.168.0.128 | 192.168.0.191 | 192.168.0.129 | 192.168.0.190 | 62    |
+----------+------------------+-----------------+---------------+---------------+---------------+---------------+-------+
| Subnet 4 | 192.168.0.192/26 | 255.255.255.192 | 192.168.0.192 | 192.168.0.255 | 192.168.0.193 | 192.168.0.254 | 62    |
+----------+------------------+-----------------+---------------+---------------+---------------+---------------+-------+

...

VLSM Output

+------------------+-----------------+---------------+---------------+---------------+---------------+--------------+-------------+
| Subnet           | Subnet Mask     | Network ID    | Broadcast ID  | First Host IP | Last Host IP  | Needed Hosts | Total Hosts |
+------------------+-----------------+---------------+---------------+---------------+---------------+--------------+-------------+
| 192.168.0.0/25   | 255.255.255.128 | 192.168.0.0   | 192.168.0.127 | 192.168.0.1   | 192.168.0.126 | 100          | 126         |
+------------------+-----------------+---------------+---------------+---------------+---------------+--------------+-------------+
| 192.168.0.128/26 | 255.255.255.192 | 192.168.0.128 | 192.168.0.191 | 192.168.0.129 | 192.168.0.190 | 50           | 62          |
+------------------+-----------------+---------------+---------------+---------------+---------------+--------------+-------------+
| 192.168.0.192/27 | 255.255.255.224 | 192.168.0.192 | 192.168.0.223 | 192.168.0.193 | 192.168.0.222 | 25           | 30          |
+---------
View on GitHub
GitHub Stars8
CategoryDevelopment
Updated2d ago
Forks0

Languages

Python

Security Score

90/100

Audited on Mar 29, 2026

No findings