Understanding IPv4 Subnetting
An IPv4 address is a 32-bit number divided into four 8-bit octets, written in dotted decimal notation (e.g., 192.168.1.0). A subnet mask defines which portion of the address identifies the network and which portion identifies individual hosts within that network.
CIDR (Classless Inter-Domain Routing) notation expresses the subnet mask as a prefix length — the number of leading 1-bits in the mask. A /24 mask (255.255.255.0) has 24 leading 1s, meaning the first 24 bits are the network portion and the last 8 bits are for hosts, giving 256 addresses (254 usable, after subtracting the network and broadcast addresses).
Key Subnet Terms
- Network Address: The first address in a subnet, with all host bits set to 0. Used to identify the subnet itself.
- Broadcast Address: The last address in a subnet, with all host bits set to 1. Packets sent to this address reach all hosts on the subnet.
- First Usable Host: Network address + 1. The lowest IP address that can be assigned to a device.
- Last Usable Host: Broadcast address − 1. The highest IP address that can be assigned to a device.
- Usable Hosts: 2^(32 − prefix) − 2. Subtract 2 for the network and broadcast addresses.
Common CIDR Prefixes
- /8 — Class A: 16,777,214 usable hosts. Used for large networks.
- /16 — Class B: 65,534 usable hosts. Common in mid-size enterprise networks.
- /24 — Class C: 254 usable hosts. The most commonly used subnet for home and small office networks.
- /25 — 126 usable hosts. Splits a /24 into two equal halves.
- /28 — 14 usable hosts. Useful for small server segments.
- /30 — 2 usable hosts. Used for point-to-point links between two routers.
Frequently Asked Questions
What is the difference between a subnet mask and a CIDR prefix?
They represent the same information in different formats. A subnet mask is written in dotted decimal (e.g., 255.255.255.0) while a CIDR prefix is written as a slash and a number (e.g., /24). Both indicate that the first 24 bits of the IP address are the network portion. You can enter either format into this calculator.
Why are two addresses always subtracted from the total?
Every subnet has two reserved addresses that cannot be assigned to hosts: the network address (all host bits = 0) and the broadcast address (all host bits = 1). A /24 subnet has 256 total addresses (2^8 = 256) but only 254 are usable. The only exceptions are /31 (used for point-to-point links, RFC 3021) and /32 (a host route for a single IP address).
What is a private IP address range?
RFC 1918 defines three private IP address ranges that are not routed on the public internet: 10.0.0.0/8, 172.16.0.0/12, and 192.168.0.0/16. These are commonly used in home, office, and data centre networks. Devices on private networks use NAT (Network Address Translation) to communicate with the internet.