Networking 11 min read Updated 2026-10-12

IPv4 Subnetting & Variable Length Subnet Masking (VLSM): Architecture, CIDR Math & Real-World Networking

DevDesk Engineering Team (Core Architecture & Infrastructure)

Maintained by systems engineers, security practitioners, and web architects building client-side, zero-trust developer utilities.

IPv4 Subnetting & Variable Length Subnet Masking (VLSM) binary CIDR prefix hierarchy and address allocation diagram
📐 Technical Diagram: IPv4 Subnetting & Variable Length Subnet Masking (VLSM) binary CIDR prefix hierarchy and address allocation diagram

The Problem of Address Exhaustion and Classful Routing

When the Internet Protocol Version 4 (IPv4) specification was authored in 1981 (RFC 791), addresses were divided into rigid classes: Class A (/8, 16.7 million hosts), Class B (/16, 65,536 hosts), and Class C (/24, 256 hosts). Organizations needing 300 IP addresses were allocated an entire Class B block, wasting over 65,000 addresses.

To prevent rapid depletion of the 32-bit IPv4 address pool (approximately 4.29 billion addresses), the Internet Engineering Task Force introduced CIDR (Classless Inter-Domain Routing) and VLSM (Variable Length Subnet Masking) in RFC 1519.

Anatomy of an IPv4 Address

An IPv4 address consists of 32 bits divided into four 8-bit octets separated by dots:

Dotted Decimal: 192.168.1.100
Binary Form:    11000000.10101000.00000001.01100100

Every address is partitioned into two components: the Network ID (identifies the subnet) and the Host ID (identifies the specific interface or device within that subnet). The Subnet Mask indicates where the network portion ends and where the host portion begins.

CIDR Notation and Bit Boundary Math

In CIDR notation, a forward slash followed by a number (prefix length) indicates the count of leading 1-bits in the subnet mask. For example, /24 means 24 contiguous 1s:

CIDR Prefix: /24
Subnet Mask: 255.255.255.0
Binary:      11111111.11111111.11111111.00000000

To determine the number of total host addresses in a subnet with prefix length n, use the formula:

Total Addresses = 2^(32 - n)

Usable Host Addresses = 2^(32 - n) - 2

Two addresses are reserved by networking standards: the Network Address (all host bits set to 0) which identifies the subnet itself, and the Broadcast Address (all host bits set to 1) used to transmit packets to all hosts on the subnet.

Variable Length Subnet Masking (VLSM) in Action

Variable Length Subnet Masking VLSM Hierarchy Tree Diagram
Figure 1: Hierarchical Subnet Partitioning for 10.0.0.0/24 without Address Waste.

Traditional fixed-length subnetting requires every subnet in a network to use the exact same mask. VLSM allows network architects to allocate subnets of differing sizes from a parent IP block to prevent wasted addresses.

Step-by-Step VLSM Allocation Example

Suppose your organization has the root block 10.0.0.0/24 (256 total addresses) and needs to accommodate four distinct departments:

  • Engineering: 100 hosts
  • Sales: 50 hosts
  • Support: 25 hosts
  • Point-to-Point WAN Link: 2 hosts

Step 1: Always sort host requirements in descending order.

Engineering (100) > Sales (50) > Support (25) > WAN Link (2).

Step 2: Calculate the required prefix for Engineering (100 hosts):
Host bits needed: 2^h - 2 >= 100. With h = 7, 2^7 - 2 = 126 usable addresses. Mask prefix = 32 - 7 = /25.
Allocated: 10.0.0.0/25 (Usable: 10.0.0.1 to 10.0.0.126, Broadcast: 10.0.0.127).

Step 3: Calculate the next block for Sales (50 hosts):
Host bits needed: 2^6 - 2 = 62 usable addresses. Mask prefix = 32 - 6 = /26.
Next free address starts at 10.0.0.128.
Allocated: 10.0.0.128/26 (Usable: 10.0.0.129 to 10.0.0.190, Broadcast: 10.0.0.191).

Step 4: Calculate the next block for Support (25 hosts):
Host bits needed: 2^5 - 2 = 30 usable addresses. Mask prefix = 32 - 5 = /27.
Next free address starts at 10.0.0.192.
Allocated: 10.0.0.192/27 (Usable: 10.0.0.193 to 10.0.0.222, Broadcast: 10.0.0.223).

Step 5: Calculate the WAN point-to-point link (2 hosts):
Host bits needed: 2^2 - 2 = 2 usable addresses. Mask prefix = 32 - 2 = /30.
Next free address starts at 10.0.0.224.
Allocated: 10.0.0.224/30 (Usable: 10.0.0.225 and 10.0.0.226, Broadcast: 10.0.0.227).

Notice that we accommodated all 4 departments and still have addresses 10.0.0.228 through 10.0.0.255 free for future growth! Use our VLSM Calculator to compute complex subnet plans instantly.

Interactive Tools Mentioned in this Guide