IP Addressing, Subnetting and CIDR With easy examples.
An IP address is a 32-bit number that uniquely identifies a device on a network, usually written as four decimal numbers separated by dots, like 192.168.1.10. Subnetting is the practice of splitting one large network into smaller pieces called subnets, and CIDR (Classless Inter-Domain Routing) is the modern notation for describing them, written as an address plus a prefix length, like 192.168.1.0/24.
This matters because the internet routes billions of packets using these addresses, and every office network, home Wi-Fi, and cloud setup depends on correct subnetting. Bad subnet math causes address clashes, unreachable devices, and security holes. Every network engineer and cloud practitioner does this arithmetic daily.
Key Concepts
- IPv4 address: 32 bits; dotted decimal splits them into four 8-bit octets (0–255 each).
- Network vs host bits: the first n bits identify the network, the rest identify the device; the prefix length /n says where the split is.
- Subnet mask: 32 bits with n ones then zeros — for example, /24 = 255.255.255.0.
- Network address: host bits all zero (identifies the subnet itself). Broadcast address: host bits all one (a message to every device in the subnet). Neither can be assigned to a device.
- Private ranges: 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16 — free for internal networks, never routed on the public internet.
- CIDR: replaced the old classes (A/B/C) with flexible prefix lengths like /26 or /21.
Formulas
- Number of subnets when borrowing b bits = 2^b.
- Usable host addresses per subnet = 2^(32−n) − 2 (subtract the network and broadcast addresses).
- Block size (addresses per subnet) = 2^(32−n) = 256 − (interesting octet of the mask).
- /24 → mask 255.255.255.0, 254 hosts; /26 → 255.255.255.192, 62 hosts; /30 → 255.255.255.252, 2 hosts (used for point-to-point links).
Worked Example
Split 192.168.10.0/24 into 4 equal subnets.
- 4 subnets need 2 borrowed bits (2^2 = 4); new prefix = 24 + 2 = /26.
- Host bits = 32 − 26 = 6; block size = 2^6 = 64; usable hosts = 64 − 2 = 62 per subnet. Mask = 255.255.255.192.
- The subnets step through the last octet in blocks of 64:
- Subnet 1: 192.168.10.0/26 — usable 192.168.10.1 to 192.168.10.62, broadcast 192.168.10.63.
- Subnet 2: 192.168.10.64/26 — usable .65 to .126, broadcast .127.
- Subnet 3: 192.168.10.128/26 — usable .129 to .190, broadcast .191.
- Subnet 4: 192.168.10.192/26 — usable .193 to .254, broadcast .255.
Check: 4 × 64 = 256 addresses, covering the whole /24 exactly, with 4 × 62 = 248 usable — the arithmetic closes perfectly.
Common Misconceptions
- "The .0 and .255 addresses are always unusable." Only the subnet's own network and broadcast addresses are reserved; 192.168.10.0 is usable as a host address inside a larger subnet like 192.168.0.0/16.
- "Subnetting wastes addresses." It organizes them — broadcast traffic stays local, security zones become possible, and routing tables shrink.
- "Classes A, B, C are still how it works." Classful networking was replaced by CIDR in 1993; the classes survive only as vocabulary.
Real-World Applications
- Office VLAN design and cloud VPC subnets on AWS.
- Home routers (usually 192.168.1.0/24).
- ISP address allocation and firewall rules written per subnet.
An IPv4 address plus a prefix length defines a subnet; borrowing bits creates subnets and 2^(host bits) − 2 gives usable addresses. The /24-into-four worked example shows the pattern every network uses. Learn this arithmetic once, and every network diagram becomes readable.
Related blogs
- OSI and TCP/IP reference models Explained with Examples
- Routing Algorithms: Distance Vector and Link State
- TCP and UDP: Reliability and Congestion Control Guide.
- DNS, DHCP, HTTP/HTTPS Explained with Examples
- Firewalls and VPN Basics: Complete Beginner's Guide
- Wireless Networks: Wi-Fi Basics: Complete Beginner's Guide