Subnetting and CIDR calculation: Dividing IP networks
In short: With subnetting you divide an IP network into smaller networks; the CIDR notation /24 states how many bits belong to the network, from which addresses, broadcast and hosts can be calculated.
In more detail: An IPv4 address has 32 bits, written as four bytes (192.168.10.37). The subnet mask (or prefix length) defines which part is the network and which the hosts. CIDR (classless inter-domain routing) writes this briefly: 192.168.10.0/24 means that the first 24 bits are the network.
In Depth
The most important formulas
- Host bits h = 32 − prefix.
- Addresses in the network: 2^h; usable hosts: 2^h − 2 (subtract network address and broadcast).
- Network address: host bits all 0. Broadcast: host bits all 1.
- First host address: network address + 1, last: broadcast − 1.
Example
/24: h = 8 → 256 addresses, 254 hosts, mask255.255.255.0.
Table of common prefixes
| Prefix | Mask | Addresses | Hosts |
|---|---|---|---|
| /24 | 255.255.255.0 | 256 | 254 |
| /25 | 255.255.255.128 | 128 | 126 |
| /26 | 255.255.255.192 | 64 | 62 |
| /27 | 255.255.255.224 | 32 | 30 |
| /28 | 255.255.255.240 | 16 | 14 |
| /29 | 255.255.255.248 | 8 | 6 |
| /30 | 255.255.255.252 | 4 | 2 |
| Prefix /16 = 255.255.0.0 (65,534 hosts), /8 = 255.0.0.0. |
Example: subnet of 192.168.10.37/26
- /26 → host bits 6 → block size 64.
- Networks in the last byte: 0, 64, 128, 192. The 37 lies in the block 0 to 63.
- Network address: 192.168.10.0, broadcast: 192.168.10.63.
- Hosts: .1 to .62 (62 of them). Dividing: one /24 into four /26 networks: .0/26, .64/26, .128/26, .192/26 (62 hosts each).
Exam and practice tips
- Think in binary: the mask /26 in the last byte:
11000000= 192. - For the task “How many subnets/hosts?”: determine the need (hosts + 2 → next power of two) and choose the smallest suitable network (VLSM: networks of different sizes).
- Private ranges: 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16.
- IPv6 uses /64 for subnets.
- Tools:
ipcalc, online calculators, the CIDR tool in the wiki. Calculate by hand first, then check.
See also: Subnet mask, Subnet, IPv6, NAT, VLAN