subnet calculator
subnet_calculatorCalculate IPv4 subnet details from CIDR notation. Parses a CIDR block (e.g. 192.168.1.0/24) and returns the network address, broadcast address, subnet mask, wildcard mask, first and last usable host addresses, total and usable host counts, prefix length, and classful IP class (A/B/C/D/E). Essential for homelab network planning, VLAN segmentation, firewall rule design, and understanding address space allocation. Handles special cases for /31 point-to-point links (RFC 3021) and /32 host routes.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cidr | Yes | IPv4 address in CIDR notation, e.g. 192.168.1.0/24 |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ip_class | Yes | Classful IP address class: A, B, C, D (multicast), or E (reserved) | |
| last_usable | Yes | Last usable host address in the subnet | |
| subnet_mask | Yes | Subnet mask in dotted decimal notation, e.g. 255.255.255.0 | |
| total_hosts | Yes | Total number of addresses in the subnet including network and broadcast | |
| first_usable | Yes | First usable host address in the subnet | |
| usable_hosts | Yes | Number of usable host addresses (excluding network and broadcast) | |
| prefix_length | Yes | CIDR prefix length, e.g. 24 | |
| wildcard_mask | Yes | Wildcard (inverse) mask, e.g. 0.0.0.255 | |
| network_address | Yes | Network address of the subnet | |
| broadcast_address | Yes | Broadcast address of the subnet |