CIDR and masks
An IPv4 address is 32 bits. The prefix after the slash says how many of them identify the network; the rest identify hosts. /24 is the mask 255.255.255.0: 24 network bits and 8 host bits, 256 addresses.
| /24 | 255.255.255.0 | 256 addresses, 254 hosts |
| /25 | 255.255.255.128 | 128 addresses, 126 hosts |
| /26 | 255.255.255.192 | 64 addresses, 62 hosts |
| /27 | 255.255.255.224 | 32 addresses, 30 hosts |
| /28 | 255.255.255.240 | 16 addresses, 14 hosts |
| /30 | 255.255.255.252 | 4 addresses, 2 hosts |
Worked example: 192.168.1.130/26
- /26 leaves 6 host bits, so each subnet has 26 = 64 addresses.
- Subnets start at multiples of 64 in the last number: 0, 64, 128, 192. 130 falls in the one starting at 128.
- Network address: 192.168.1.128. Broadcast address, the last in the block: 192.168.1.191.
- Usable hosts: 192.168.1.129 to 192.168.1.190, 62 addresses.
The first and last addresses are reserved, so a subnet has 2host bits − 2 usable hosts. /31 links between two routers and single /32 addresses are special cases.
Calculator
The Subnet Calculator works this out for any address and prefix or mask, with the wildcard mask and binary form. To convert the numbers between decimal, binary and hex, use the Number Base Converter.