IP Addressing & CIDR

CIDR notation, subnetting, private RFC 1918 ranges, IPv6 basics, and calculating usable hosts per subnet.

Overview

Overview IP addressing and subnetting are foundational networking knowledge that every cloud engineer, SRE, and backend developer working with infrastructure must understand. Whether you are designing VPC address spaces, configuring Kubernetes pod CIDR ranges, debugging why two services cannot communicate, or understanding why a security group rule is not matching, IP addressing knowledge is directly applied.

An IP address is a 32-bit (IPv4) or 128-bit (IPv6) number that identifies a network interface. IPv4 addresses are written in dotted-decimal notation as four octets (e.g., 192.168.1.100). The address is divided into a network portion and a host portion, determined by the subnet mask.

CIDR (Classless Inter-Domain Routing, RFC 4632) replaced the rigid class-based addressing (Class A/B/C) with prefix notation. A CIDR block like 10.0.0.0/16 means the first 16 bits are the network prefix, leaving 16 bits for host addresses. This allows arbitrary prefix lengths, enabling efficient allocation of IP address space without wasting entire Class C blocks on networks with a handful of hosts.

RFC 1918 defines three private address ranges that are not routed on the public internet: 10.0.0.0/8 (16 million addresses), 172.16.0.0/12 (1 million addresses), and 192.168.0.0/16 (65,536 addresses). These ranges are used for private networks, VPCs, Kubernetes pod networks, and corporate LANs. They reach the internet via NAT (Network Address Translation).

IPv6 uses 128-bit addresses written as eight groups of four hex digits separated by colons (e.g., 2001:0db8:85a3:0000:0000:8a2e:0370:7334). Consecutive groups of zeros can be replaced with :: once per address. IPv6 has a vast address space (340 undecillion addresses), making NAT unnecessary — every device can have a globally unique address. IPv6 also introduces link-local addresses (fe80::/10) for communication within a network segment without configuration.

For cloud environments, VPC design decisions — CIDR block size, subnet allocation, reserved addresses, peering constraints — have long-term operational consequences that are expensive to change. Getting subnetting right the first time matters.

Key concepts

CIDR Notation
CIDR (Classless Inter-Domain Routing) represents an IP address block as a base address and prefix length: network/prefix (e.g., 192.168.1.0/24). The prefix length (0-32 for IPv4) indicates how many leading bits are fixed (the network prefix). The remaining bits identify individual hosts within the network. A /24 has 24 fixed bits and 8 host bits (256 addresses); a /16 has 16 fixed bits and 16 host bits (65,536 addresses).
Subnet Mask
A 32-bit mask where 1s denote the network portion and 0s denote the host portion. /24 corresponds to 255.255.255.0 (24 ones followed by 8 zeros). The network address is the IP bitwise-AND'd with the mask. The broadcast address is the network address OR'd with the inverted mask. Usable host addresses are all addresses between network address+1 and broadcast-1.
RFC 1918 Private Ranges
Three IPv4 address blocks reserved for private networks, not routed on the public internet: 10.0.0.0/8 (10.0.0.0 to 10.255.255.255, ~16.7M addresses), 172.16.0.0/12 (172.16.0.0 to 172.31.255.255, ~1M addresses), and 192.168.0.0/16 (192.168.0.0 to 192.168.255.255, 65,536 addresses). Internet access from these ranges requires NAT. All three ranges may appear in VPCs, home networks, container networks, and corporate LANs.
IPv6 Address Structure
IPv6 uses 128-bit addresses in 8 groups of 4 hex digits. The /64 prefix is standard for subnets, leaving 64 bits for interface identifiers. Key address types: global unicast (2000::/3, globally routable), link-local (fe80::/10, auto-configured, not routable), loopback (::1/128), and unique local (fc00::/7, analogous to RFC 1918).
AWS Reserved Addresses per Subnet
AWS reserves 5 IP addresses in every subnet: .0 (network address), .1 (VPC router), .2 (AWS DNS), .3 (reserved for future use), and the broadcast address. A /24 subnet has 256 total addresses minus 5 reserved = 251 usable. This matters when sizing subnets for large EC2 fleets or Kubernetes node groups where each node consumes multiple IPs for pod addresses.
Supernetting and Route Summarization
Supernetting (the inverse of subnetting) combines multiple contiguous networks into a single larger CIDR block for routing efficiency. For example, 10.0.0.0/24 and 10.0.1.0/24 can be summarized as 10.0.0.0/23. Route summarization reduces the number of entries in routing tables. BGP heavily relies on prefix aggregation to keep the global routing table manageable.

When to use it

  • Designing a VPC address space for a cloud environment (AWS, GCP, Azure) with room for future growth
  • Calculating available IP addresses in a subnet to ensure enough addresses for EC2 instances or Kubernetes pods
  • Debugging why two VPCs cannot be peered (overlapping CIDR ranges)
  • Configuring Kubernetes pod CIDR, service CIDR, and node CIDR without conflicts
  • Understanding security group and firewall rules that filter by IP range
  • Explaining IP address exhaustion and why IPv6 adoption matters

Interview questions

  • How do you calculate the number of usable hosts in a /26 subnet, and what is its network and broadcast address if the base is 192.168.10.64?
  • How do you design a VPC address scheme for a multi-account AWS environment with dev, staging, and production?

Sign up free to read the full topic

More Networking topics

Start free on Cariara · Coding problems · System design studio