KitWharfFREEFast & Private Web Apps

IPv4 Subnetting & CIDR Demystified: Binary Math, Netmasks, and VLSM Slicing

October 22, 202610 min readKitWharf Team
Interactive Online Tool Available

Subnet & CIDR IP Calculator

Calculate IPv4/IPv6 subnets, network/broadcast addresses, usable host ranges, and binary netmasks. Slice subnets with VLSM.

Launch Free Tool

Subnetting is the foundational pillar of computer networking. Whether you are provisioning a Virtual Private Cloud (VPC) on AWS or GCP, segmenting IoT devices on a corporate VLAN, or troubleshooting firewall routing tables, you cannot escape CIDR blocks and netmasks.

Yet many software engineers and junior sysadmins treat subnetting as an intimidating mystery.

In this guide, we'll strip away the jargon and show you the simple binary mathematics that make subnetting completely intuitive.


1. What is an IPv4 Address? (The 32-Bit Truth)

Although we write IPv4 addresses in human-friendly dotted-decimal notation (like 192.168.1.1), computers view them as a single 32-bit unsigned integer:

192       . 168       . 1         . 1
11000000  . 10101000  . 00000001  . 00000001

Every IP address consists of two distinct segments:

  1. The Network Portion: Identifies which network or subnet the device belongs to (like a street name).
  2. The Host Portion: Identifies the specific device on that network (like a house number).

2. What Does the Subnet Mask and CIDR Prefix Do?

How does a router know where the network portion ends and the host portion begins? The Subnet Mask.

A subnet mask is simply a continuous sequence of binary 1s followed by continuous binary 0s.

  • The binary 1s mark the Network bits.
  • The binary 0s mark the Host bits.

In modern networking, we write this using CIDR (Classless Inter-Domain Routing) notation: a slash followed by the count of leading 1 bits:

CIDR Prefix Subnet Mask Binary Netmask Total IP Addresses Usable Hosts ($2^H - 2$)
/24 255.255.255.0 11111111.11111111.11111111.00000000 256 254
/25 255.255.255.128 11111111.11111111.11111111.10000000 128 126
/26 255.255.255.192 11111111.11111111.11111111.11000000 64 62
/27 255.255.255.224 11111111.11111111.11111111.11100000 32 30
/28 255.255.255.240 11111111.11111111.11111111.11110000 16 14
/16 255.255.0.0 11111111.11111111.00000000.00000000 65,536 65,534

3. The Formula: Network Address, Broadcast, and Usable Hosts

Given an IP and CIDR prefix (e.g. 192.168.1.100/24):

1. Network Address: Bitwise AND

The network address is obtained by performing a bitwise AND between the IP and the Subnet Mask: $$\text{Network Address} = \text{IP} ;&; \text{Mask}$$ For 192.168.1.100 and 255.255.255.0, the network address is 192.168.1.0.

2. Broadcast Address: Bitwise OR with Inverted Mask

The broadcast address is the highest address in the range, where all host bits are set to 1: $$\text{Broadcast Address} = \text{Network Address} ;|; (\sim\text{Mask})$$ For our example, the broadcast address is 192.168.1.255.

3. Usable Host Range

  • First Usable Host: $\text{Network Address} + 1$ (192.168.1.1)
  • Last Usable Host: $\text{Broadcast Address} - 1$ (192.168.1.254)

Why Subtract 2? The network address is reserved to identify the network itself, and the broadcast address is reserved to send traffic to all hosts on the subnet simultaneously.

(Exception: RFC 3021 defines /31 subnets for point-to-point router links, where both addresses are usable hosts without broadcast).


4. VLSM (Variable Length Subnet Masking) Explained

In traditional legacy networking (Classful routing), organizations were handed rigid Class A (/8), Class B (/16), or Class C (/24) blocks, resulting in millions of wasted public IP addresses.

VLSM allows network architects to slice a larger parent subnet into custom-sized smaller subnets tailored to exact departmental needs:

Suppose your company is allocated 192.168.1.0/24 (256 addresses) and needs to support:

  • Engineering: 100 devices
  • Marketing: 50 devices
  • Management: 25 devices

With VLSM, you carve up the /24:

  1. Slicing into a /25 gives 126 usable hosts (192.168.1.0/25 for Engineering).
  2. Taking the remaining half (192.168.1.128) and slicing it into a /26 gives 62 usable hosts (192.168.1.128/26 for Marketing).
  3. Taking the remaining quarter (192.168.1.192) and slicing into a /27 gives 30 usable hosts (192.168.1.192/27 for Management).

Zero address space is wasted!


5. Calculate Subnets & Partition Networks Instantly

Need to plan a cloud VPC, calculate host boundaries, or slice subnets without doing manual binary arithmetic on scratch paper?

Use the KitWharf Subnet & CIDR IP Calculator:

  • Full IPv4 Breakdown: Computes Network Address, Broadcast, Usable Range, and Netmask in real time.
  • VLSM Subnet Divider: Slice any network block into smaller subnets with an interactive visual preview.
  • Binary Bit Visualizer: Inspect the 32-bit binary representation of your IP and mask.
  • IPv6 Inspector: Expand compressed IPv6 addresses into full 8-hextet notation and verify network scopes.
  • 100% Private & In-Browser: Zero telemetry or server calls.

Ready to put this into practice?

Launch our free Subnet & CIDR IP Calculator — instant client-side execution in your browser with zero registration required.

Open Tool