Blog/network

How to Calculate CIDR Subnets: A Complete Guide for Network & Cloud Engineers

By Yurlie Network TeamAugust 3, 20267 min read 107 views

What is CIDR and Why Classful Addressing Failed

Classless Inter-Domain Routing (CIDR) was introduced in 1993 by the Internet Engineering Task Force (IETF) to replace the original Classful Network Architecture (Class A, Class B, and Class C).

Under the legacy classful system:

  • Class A (/8) gave an organisation 16.7 million IP addresses.
  • Class B (/16) assigned 65,536 IP addresses.
  • Class C (/24) assigned 256 IP addresses.

This coarse allocation resulted in massive IPv4 address exhaustion. CIDR solved this by allowing subnets to be partitioned at any arbitrary bit boundary from /0 to /32.

---

Anatomy of an IPv4 Address

An IPv4 address consists of 32 bits, divided into 4 octets (8 bits per octet) separated by dots:

192.168.1.1 = 11000000 . 10101000 . 00000001 . 00000001

The CIDR suffix (e.g. /24) specifies how many leading bits represent the Network ID, leaving the remaining bits for Host IDs.

---

CIDR Subnet Reference Table

CIDR PrefixSubnet MaskTotal IP CountUsable HostsTypical Network Use Case
/32255.255.255.25511Single host IP / Security Group Rule
/30255.255.255.25242Point-to-point router links
/28255.255.255.2401614Microservice pod cluster
/27255.255.255.2243230Database subnet group
/24255.255.255.0256254Standard office LAN / K8s Node
/20255.255.240.04,0964,094Corporate office site
/16255.255.0.065,53665,534Cloud VPC Network (AWS / GCP / Azure)

---

Step-by-Step Subnet Calculation Example

Let's calculate the subnet details for 10.0.4.0/22:

  1. Calculate Host Bits: 32 - 22 = 10 host bits
  2. Calculate Total IPs: 2^10 = 1,024 IP addresses
  3. Calculate Usable Hosts: 1,024 - 2 = 1,022 usable hosts
  4. Subnet Mask: 255.255.252.0 (11111111.11111111.11111100.00000000)
  5. First Usable IP: 10.0.4.1
  6. Last Usable IP: 10.0.7.254
  7. Broadcast Address: 10.0.7.255
Pro Tip for Cloud Architecture: AWS reserves the first 4 IP addresses and the last 1 IP address in every subnet (e.g., in a /24 subnet, only 251 IPs are available for your EC2 instances).

---

Calculate Subnets Instantly with Yurlie

Calculate IP ranges, broadcast addresses, wildcard masks, and binary layouts in real-time with our free CIDR Subnet Calculator.

Total Views: 107Category: network

Try Yurlie Online Developer Tools

Run CIDR calculations, JSON formatting, Base64 encoding, and UUID generation instantly in your browser.

Explore Tools →