How Does Subnetting Work? IPv4 Subnets, Classes, and Multicast
Subnetting divides one IPv4 network into smaller logical networks. The working model today is CIDR (Classless Inter-Domain Routing): a prefix such as /24 or /26 states how many of the address’s 32 bits identify the network. The remaining bits identify addresses within that subnet.
To calculate a subnet, identify the prefix length, determine the address block size, and find the network, broadcast, usable-host, and next-subnet values. Historical IPv4 address classes still appear in documentation, but modern subnetting is not restricted to their original boundaries.
How does subnetting work with an IPv4 address and prefix?
An IPv4 address contains 32 binary bits, written as four decimal octets. For example, 192.168.10.37/24 has a 24-bit network portion and an 8-bit host portion.
- Network bits: identify the subnet.
- Host bits: identify an address inside that subnet.
- Prefix length: the number after the slash, such as /24.
- Subnet mask: the dotted-decimal equivalent of the prefix, such as 255.255.255.0 for /24.
Increasing the prefix length uses more bits for the network and leaves fewer host addresses. A /24 has 8 host bits and 256 total addresses. A /26 has 6 host bits and 64 total addresses. In a traditional subnet, two addresses are reserved: the first is the network address and the last is the broadcast address. Therefore, a /24 normally provides 254 usable host addresses, while a /26 provides 62.
Subnetting can be understood as borrowing host bits to create additional networks. Splitting a /24 into /26 subnets changes 2 host bits into network bits, producing four subnets of 64 addresses each. CIDR permits prefixes such as /20, /27, and /30, so the split does not need to follow the old Class A, B, or C boundaries.
Calculate IPv4 subnet ranges: /24 and /26 examples
The basic calculations use these formulas:
- Total addresses: 2host bits
- Traditional usable hosts: 2host bits − 2
- Next subnet: add the block size to the current network address
The block size is the number of addresses in each subnet. In the octet where the mask stops being 255, calculate it as 256 − mask value.
Example 1: 192.168.10.37/24
The /24 mask is 255.255.255.0. The first three octets identify the network, and the final octet contains 8 host bits. The block size in the final octet is 256, so this address belongs to the range beginning at .0 and ending at .255.
- Network address: 192.168.10.0
- First usable host: 192.168.10.1
- Last usable host: 192.168.10.254
- Broadcast address: 192.168.10.255
- Total addresses: 256
- Usable hosts: 254
- Next /24 subnet: 192.168.11.0
The address 192.168.10.37 is therefore a host address inside the 192.168.10.0/24 subnet. The next subnet starts when the third octet increases from 10 to 11.
Example 2: 192.168.10.77/26
A /26 mask is 255.255.255.192. The final octet has 6 host bits, giving 26 = 64 total addresses per subnet. The block size is 256 − 192 = 64, so the possible final-octet network boundaries are 0, 64, 128, and 192.
The value 77 falls between 64 and 127, so it belongs to the second /26 subnet:
- Network address: 192.168.10.64
- First usable host: 192.168.10.65
- Last usable host: 192.168.10.126
- Broadcast address: 192.168.10.127
- Total addresses: 64
- Usable hosts: 62
- Next /26 subnet: 192.168.10.128
The four /26 ranges within 192.168.10.0/24 are:
- 192.168.10.0 through 192.168.10.63
- 192.168.10.64 through 192.168.10.127
- 192.168.10.128 through 192.168.10.191
- 192.168.10.192 through 192.168.10.255
For a quick calculation, identify the relevant octet, divide its value by the block size, and use the resulting block boundary as the network address. For 77 with a block size of 64, the boundary is 64. The broadcast address is one less than the next boundary, 128 − 1 = 127. The usable range lies between those two reserved addresses.
What the IPv4 address classes mean today
IPv4 address classes were part of the original classful addressing system. They assigned a default network size based on the first octet:
- Class A: 1.0.0.0 through 126.255.255.255, with a historical default prefix of /8.
- Class B: 128.0.0.0 through 191.255.255.255, with a historical default prefix of /16.
- Class C: 192.0.0.0 through 223.255.255.255, with a historical default prefix of /24.
- Class D: 224.0.0.0 through 239.255.255.255, used for multicast.
- Class E: 240.0.0.0 through 255.255.255.255, historically reserved or experimental.
The class ranges have important exceptions. The 127.0.0.0/8 range is reserved for loopback, and 0.0.0.0 has special uses. The final Class E values also include reserved broadcast-related addresses, including 255.255.255.255.
Class A, B, and C labels describe historical default boundaries, not the limits of current subnet design. CIDR replaced classful allocation by allowing an organization or route to use a specific prefix length. For example, 172.16.0.0/20, 192.168.1.0/27, and 10.0.0.0/30 are all valid CIDR-style subnet sizes even though their prefixes do not match the old Class A, B, or C defaults.
How multicast IP addresses differ from unicast
A multicast IP address identifies a group of receivers rather than one ordinary network interface. The IPv4 multicast range is 224.0.0.0 through 239.255.255.255, also written as 224.0.0.0/4. This is the historical Class D range.
With unicast, one source sends traffic to one destination address assigned to a particular host interface. With multicast, a source sends traffic to a group address. Hosts that want the traffic join the group, and multicast-capable network devices deliver copies to the relevant network segments. The group address represents the receivers collectively; it is not normally assigned to one host as its ordinary unicast address.
- Unicast: one sender to one destination host.
- Broadcast: one sender to all applicable hosts on a broadcast domain.
- Multicast: one sender to participating members of a destination group.
Class D multicast addresses do not use the usual network-address, host-range, and broadcast-address calculations. A multicast group address is not divided into a conventional subnet with a first usable host and last usable host. It identifies a service or receiver group, while the packet’s source address remains a unicast address belonging to the sender.
Some multicast ranges have defined scopes or purposes. The 224.0.0.0/24 portion is used for local-network control traffic, while 239.0.0.0/8 is commonly used for administratively scoped multicast. These addresses still function as group destinations, not as ordinary host assignments.