← Back to All Guides
Networking & Security • 9 min read • September 27, 2026

IPv4 Subnetting & CIDR Notation: Binary Arithmetic, Network Masks & Subnet Allocation

A systems engineering masterclass on network prefixes, host bit allocations, broadcast addresses, and cloud VPC architectures.

By ToolHero Cloud Infrastructure & Network Security Team

The Evolution from Classful Routing to CIDR

In the early days of the ARPANET and IPv4 internet (1981, RFC 791), network addresses were divided into rigid classes:

  • Class A: 8-bit prefix (16.7\text{ million} hosts)

  • Class B: 16-bit prefix (65,536 hosts)

  • Class C: 24-bit prefix (254 hosts)
  • This rigid allocation led to massive waste: an organization requiring 300 IP addresses had to be allocated an entire Class B block (65,536 addresses), wasting over 99\% of assigned IPs.

    In 1993, the IETF introduced Classless Inter-Domain Routing (CIDR) under RFC 1519, allowing subnet masks of arbitrary bit lengths designated by a slash prefix (e.g., /24, /27, /16).


    The Binary Mathematics of IPv4 Addresses

    An IPv4 address is not four separate numbers; it is a single 32-bit binary integer divided into four 8-bit octets for human readability:

    \text{192.168.1.10} = \underbrace{\text{11000000}}_{192}.\underbrace{\text{10101000}}_{168}.\underbrace{\text{00000001}}_{1}.\underbrace{\text{00001010}}_{10}

    The Subnet Mask

    A subnet mask separates the 32 bits into two distinct functional segments:
  • Network Bits (Prefix): Identifies the specific network or subnetwork.
  • Host Bits: Identifies individual client devices (servers, laptops, routers) on that subnet.
  • Subnet Bit Partitioning (/27 Example):
    Network Bits (Prefix = 27):                     Host Bits (32 - 27 = 5):
    11111111 . 11111111 . 11111111 . 11100000       ─────> 5 bits for hosts
    (255   .   255   .   255   .   224)

    Core Subnet Calculations

    For any given CIDR block (e.g., 10.0.4.0/24 or 192.168.50.64/27):

    1. Number of Total Addresses

    N_{\text{total}} = 2^{(32 - \text{CIDR})}
    For a /27 network:
    N_{\text{total}} = 2^{(32 - 27)} = 2^5 = 32\text{ addresses}

    2. Number of Usable Host Addresses

    In standard IPv4 subnets, two addresses are reserved:
  • Network ID: All host bits are set to 0 (identifies the subnet itself).
  • Broadcast Address: All host bits are set to 1 (targets all hosts on the subnet).
  • N_{\text{usable}} = 2^{(32 - \text{CIDR})} - 2 = 32 - 2 = 30\text{ usable hosts}

    (Note: In AWS/GCP cloud VPCs, 5 addresses per subnet are reserved by cloud hypervisors for router, DNS, and management purposes).

    3. Calculating the Network ID via Bitwise AND

    \text{Network Address} = \text{IP Address} \ & \ \text{Subnet Mask}

    Quick Reference: Common Subnet Prefixes

    | CIDR Prefix | Subnet Mask | Total IPs | Usable Hosts | Common Use Case |
    |---|---|---|---|---|
    | /30 | 255.255.255.252 | 4 | 2 | Point-to-point router links |
    | /28 | 255.255.255.240 | 16 | 14 | Small microservice clusters |
    | /24 | 255.255.255.0 | 256 | 254 | Standard corporate office LAN |
    | /20 | 255.255.240.0 | 4,096 | 4,094 | Medium cloud VPC subnets |
    | /16 | 255.255.0.0 | 65,536 | 65,534 | Enterprise core network / VPC |


    Instant Subnet Calculations with ToolHero

    ToolHero's Subnet Calculator computes network IDs, usable IP host ranges, broadcast addresses, wildcard masks, and binary bit breakdowns instantly in your browser without network latency.

    Frequently Asked Questions

    Why are two IP addresses subtracted from every subnet?

    The lowest address (all host bits 0) represents the Network ID, and the highest address (all host bits 1) represents the Broadcast Address for sending packets to all subnet devices.

    What is a /32 subnet?

    A /32 represents a single specific host IP address with 0 host bits, commonly used for single host firewall rules and loopback interfaces.

    Does ToolHero Subnet Calculator track my internal IP ranges?

    No! All binary subnet calculations happen locally inside your web browser. No IP addresses or network topology data are ever sent over the network.

    Put This Theory Into Practice

    Experience zero-upload, client-side processing with ToolHero suite of free online utilities.

    Explore All Free Tools →