What Is an IP Subnet? CIDR and Class B Address Ranges Explained
An IP subnet is a logical division of an IPv4 address range. Each subnet has a network address that identifies the subnet, a broadcast address used to reach all hosts on it, and a defined set of host addresses between those two endpoints. A CIDR prefix, such as /24 or /20, determines how many bits identify the network and how many remain for hosts.
Modern subnet calculations use CIDR rather than the old classful system. The historical Class B address range is 128.0.0.0 through 191.255.255.255, with a default /16 mask, but an address in that first-octet range can now use almost any valid CIDR prefix.
What Is an IP Subnet?
An IP subnet is a smaller, independently addressable portion of an IP network. Subnetting divides one larger address space into multiple smaller ranges so that devices, routes, and access rules can be organized more precisely.
An IPv4 address contains 32 bits, normally written as four decimal octets. For example, 172.20.37.25 represents four 8-bit values. A subnet mask or CIDR prefix separates those bits into:
- Network bits: The fixed portion that identifies the subnet.
- Host bits: The remaining portion used to identify addresses within that subnet.
For example, 192.168.10.0/24 uses the first 24 bits for the network and leaves 8 host bits. That creates 256 total addresses, from 192.168.10.0 through 192.168.10.255. In a traditional IPv4 subnet, the first address is the network address and the last is the broadcast address, leaving 254 commonly usable host addresses.
The network address identifies the block itself. The broadcast address is used to send traffic to all hosts in that block. Hosts normally receive addresses between those two values, although /31 and /32 prefixes have special uses:
- /31: Commonly used for point-to-point links, where both addresses can represent endpoints and there is no traditional network-and-broadcast pair.
- /32: Represents one specific IPv4 address, often for a host route or loopback.
How Do Subnets Work? Prefixes, Network Bits, and Host Bits
A CIDR prefix is the number after the slash. It states how many of the 32 IPv4 bits belong to the network portion. A larger prefix leaves fewer host bits and therefore creates a smaller subnet.
- /16: 16 network bits and 16 host bits.
- /20: 20 network bits and 12 host bits.
- /24: 24 network bits and 8 host bits.
- /26: 26 network bits and 6 host bits.
The total number of addresses in a subnet is calculated as 2 to the power of the host-bit count. For ordinary IPv4 subnets, the commonly usable host count is the total minus two, because the network and broadcast addresses are reserved.
- /20: 12 host bits, 4,096 total addresses, 4,094 commonly usable hosts.
- /24: 8 host bits, 256 total addresses, 254 commonly usable hosts.
- /26: 6 host bits, 64 total addresses, 62 commonly usable hosts.
Subnetting works by borrowing host bits from a larger network. For example, dividing a /16 network into /20 subnets borrows four bits. That produces 2 to the power of 4, or 16, separate subnets. Each /20 subnet has 12 host bits and contains 4,096 total addresses.
The subnet mask expresses the same boundary in dotted-decimal form. Common examples include:
- /16: 255.255.0.0
- /20: 255.255.240.0
- /24: 255.255.255.0
- /26: 255.255.255.192
Network devices use the mask to determine whether a destination is local to the same subnet or requires routing through a gateway. Addresses with matching network bits belong to the same subnet; differences in those bits indicate different subnets.
Class B Address Range: 128–191 and the Historical /16 Mask
Under the historical classful IPv4 system, a Class B address had a first octet from 128 through 191. The complete first-octet range was therefore:
128.0.0.0 through 191.255.255.255
Class B networks used a default mask of 255.255.0.0, or /16. The first two octets identified the network, while the last two octets provided 16 host bits. A single classful /16 network contained 65,536 total addresses and 65,534 commonly usable host addresses.
For example, 172.20.0.0/16 would cover 172.20.0.0 through 172.20.255.255 under the historical default. The network address would be 172.20.0.0, the broadcast address would be 172.20.255.255, and the usual host range would be 172.20.0.1 through 172.20.255.254.
Classful addressing is no longer the basis for Internet allocation or routing. CIDR replaced the fixed Class A, Class B, and Class C boundaries by allowing prefixes of different lengths. This supports more efficient allocation and more specific routes. A network beginning with an address from 128 through 191 is not automatically a /16 today.
For example, 172.20.37.25/20 falls within the historical Class B first-octet range, but its actual subnet is /20, not /16. Its network and host boundaries are determined by /20. Other modern allocations in the same first-octet range could use /12, /21, /24, or another valid prefix.
“Class B address range” remains useful when reading older documentation, configuration notes, or training material. It should be treated as a historical description of the first octet and default mask, not as a rule that determines the current subnet size.
Worked CIDR Calculations: Network, Broadcast, Hosts, and Increments
A reliable IPv4 subnet calculation follows four steps:
- Convert the prefix to a subnet mask.
- Find the host-bit count and calculate the address total.
- Use the subnet increment to locate the network block containing the given address.
- Identify the broadcast and usable host range.
The subnet increment is calculated in the mask octet where the mask is neither 255 nor 0. The formula is 256 minus the mask value. It shows where each subnet block starts.
Example 1: 172.20.37.25/20
- Mask: /20 is 255.255.240.0.
- Increment: The relevant octet is the third; 256 minus 240 equals 16.
- Network blocks: The third octet starts at 0, 16, 32, 48, and so on.
- Network: The value 37 falls in the 32–47 block, so the network is 172.20.32.0.
- Broadcast: The address immediately before the next block is 172.20.47.255.
- Usable hosts: 172.20.32.1 through 172.20.47.254.
- Host capacity: 12 host bits provide 4,096 total addresses and 4,094 commonly usable addresses.
This example shows why a first octet of 172 does not force a /16 mask. The address is within the historical Class B range, but /20 defines the actual subnet.
Example 2: 192.168.10.77/26
- Mask: /26 is 255.255.255.192.
- Increment: In the fourth octet, 256 minus 192 equals 64.
- Network blocks: The ranges begin at 0, 64, 128, and 192.
- Network: 77 falls in the 64–127 block, so the network is 192.168.10.64.
- Broadcast: The broadcast address is 192.168.10.127.
- Usable hosts: 192.168.10.65 through 192.168.10.126.
- Host capacity: 6 host bits provide 64 total addresses and 62 commonly usable addresses.
When the prefix ends on an octet boundary, the calculation is simpler. For 10.4.8.19/24, the mask is 255.255.255.0, the network is 10.4.8.0, the broadcast is 10.4.8.255, and the usable range is 10.4.8.1 through 10.4.8.254.
For any ordinary IPv4 prefix, the key formulas are:
- Host bits: 32 minus the prefix length.
- Total addresses: 2 to the power of the host-bit count.
- Commonly usable hosts: Total addresses minus 2.
- Subnet increment: 256 minus the mask value in the relevant octet.