📐 Subnetting

Learn how to divide networks into smaller subnets using subnet masks and CIDR notation.

📐 Subnet Basics
Q1What is a subnet mask?Beginner

A subnet mask determines which part of an IP address identifies the network and which part identifies the host (device). It's always used alongside an IP address.

Example: IP 192.168.1.10 with mask 255.255.255.0:

  • Network part: 192.168.1 (first 3 octets = 24 bits)
  • Host part: .10 (last octet = 8 bits, so 254 usable hosts)
💡 255.255.255.0 in CIDR notation is /24 — meaning 24 bits are the network portion. This is the most common subnet for home/small office networks.
Q2What is CIDR notation?Intermediate

CIDR (Classless Inter-Domain Routing) notation is a compact way to represent an IP address and its subnet mask together, using a slash and prefix length.

Common CIDR examples:

  • 192.168.1.0/24 — 256 addresses (254 usable), mask 255.255.255.0
  • 10.0.0.0/8 — 16 million addresses, mask 255.0.0.0
  • 192.168.1.0/28 — 16 addresses (14 usable), mask 255.255.255.240

Usable hosts = 2^(32 - prefix) - 2 (subtract network and broadcast addresses).

⚠️ For /24: 2^8 - 2 = 254 usable hosts. For /28: 2^4 - 2 = 14 usable hosts.
Q3Why do we use subnetting?Intermediate

Subnetting divides a large network into smaller, more manageable sub-networks. Benefits:

  • Improved security — Isolate different departments (e.g. HR can't access Engineering subnet)
  • Reduced congestion — Broadcast traffic is contained within each subnet
  • Efficient IP use — Assign only as many IPs as needed per segment
  • Easier management — Troubleshoot and monitor smaller network segments
💡 Cloud providers like AWS use subnetting extensively — when you create a VPC (Virtual Private Cloud), you carve it into public and private subnets for security.