Subnets and CIDR
Read /24, count hosts and split networks.
A subnet is a slice of a network. CIDR notation writes it as an address plus the number of bits that identify the network: 192.168.1.0/24 means the first 24 bits are the network and the last 8 are for hosts.
| CIDR | Subnet mask | Addresses | Usable 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 |
/30 | 255.255.255.252 | 4 | 2 |
The formula: addresses = 2 to the power of (32 minus the prefix). Two are reserved in a normal subnet: the first is the network address and the last is the broadcast address, so usable hosts = addresses minus 2.
Worked example
Take 192.168.1.0/26. There are 2^6 = 64 addresses, from 192.168.1.0 to 192.168.1.63. The network address is .0, the broadcast is .63 and the usable hosts are .1 to .62 (62 hosts). The next /26 starts at 192.168.1.64.
NoteCloud providers often reserve a few more addresses per subnet. Check your provider before sizing a subnet tightly.
Test yourself
Answer all the questions, then check them. Finish with every answer right to mark the lesson as done.