- CIDR prefix length (/n)
- 24
254
Open with these values254hosts
Result: 254 hostsHost bits are 32 minus the prefix, and two addresses are always reserved — the network address and the broadcast address. So a /24 has 2⁸ − 2 = 254 usable hosts, and a /16 has 65,534. A /31 and a /32 have no usable host range at all.
254
Open with these values65,534
Open with these values2
Open with these valuesusable hosts = 2^(32 − prefix) − 2
An IPv4 address is 32 bits long, and the prefix written after the slash says how many of those bits name the network. Everything left over numbers the individual machines inside it, so the prefix alone fixes how large a subnet is: the host bits are 32 minus the prefix, and two raised to that count is every address the block contains. Two of those bit patterns are spoken for by convention rather than by arithmetic — all host bits zero identifies the subnet itself, all host bits one is the broadcast — and that is where the subtraction of two comes from. The default setting runs through in one line: a /24 leaves 8 host bits, so 2⁸ = 256 addresses and 256 − 2 = 254 usable ones. Because the prefix moves the exponent, the count changes by doubling rather than by steps: a /25 holds 126, a /16 holds 65,534 and a /0 holds 4,294,967,294. What the result does not give you is a range. It counts addresses without saying where the block starts, which two of them are the reserved pair, or how a larger allocation should be carved up. And the minus two is a rule about ordinary subnets rather than about the arithmetic, which is why the two smallest blocks fall outside it and are clamped to zero.
The first address in an ordinary subnet names the network itself, and the last one is the broadcast address that reaches every host at once. Neither can be assigned, which is where the minus two in 2^n − 2 comes from.
The plain formula would give 0 for a /31 and −1 for a /32, so the result is clamped to 0. A /31 uses both of its addresses for a point-to-point link under RFC 3021, and a /32 is a single-address host route.
A /25 holds 126 usable hosts, a /24 holds 254 and a /16 holds 65,534. Each bit taken from the prefix is a bit added to the host part.
A /24 has 256 usable hosts.
It has 256 addresses but only 254 usable ones, because the network and broadcast address are reserved.
A bigger prefix number means a bigger subnet.
The prefix counts the leading bits that identify the network, so a larger prefix leaves fewer host bits. A /25 is half the size of a /24.
A /30 is useless because it only has 4 addresses.
Two of those four are usable, which is exactly what a point-to-point link between two routers needs.
| Prefix | What it usually is | Usable hosts |
|---|---|---|
| 0 | the whole IPv4 space | 4294967294 |
| 8 | a former class A block | 16777214 |
| 16 | a former class B block | 65534 |
| 24 | a typical office or home LAN | 254 |
| 25 | half a LAN | 126 |
| 30 | a point-to-point link | 2 |
| 31 | point-to-point under RFC 3021 | 0 |
| 32 | a single host route | 0 |
Raise two to the number of host bits and subtract two: 2^(32 − prefix) − 2. The host bits are 32 minus the CIDR prefix length, and the minus two removes the network and broadcast addresses. A /24 therefore holds 254 usable hosts.
Two addresses in every ordinary subnet are reserved: the network address, the first one, which names the subnet itself, and the broadcast address, the last one, which reaches all hosts at once. Neither can be given to a device, so a /24 with 256 addresses has only 254 usable ones.
254. A /24 has 8 host bits, so 2⁸ = 256 addresses, minus the network and broadcast address. A /16 holds 65,534, a /25 holds 126 and a /30 holds just 2 — each smaller prefix roughly doubles the count.
They are special cases. A /31 has two addresses and, under RFC 3021, uses both for a point-to-point link with nothing reserved, while a /32 is a single-address host route. The classic formula would give 0 and −1 there, so the result is clamped to 0.
It is the /n written after an IP address, as in 192.168.1.0/24, and it counts the leading bits that identify the network. The remaining 32 − n bits number the individual hosts. A larger prefix means fewer host bits and fewer usable addresses.
Information, not professional advice.
Diese Seite gibt es auch auf Deutsch.
Zu Deutsch wechseln