2^X-2 because 255 is a broadcast address, but I dunno what that means.
The other missing value is just the 0, because when you have an 8-bit octet for each part of an IPv4 address, the possible values in binary range from 00000000 to 11111111. 11111111 gets you the 255 in decimal, and 00000000 is 0. In between those two are 254 other possibilities.
The 32-bit IP address consists of a network portion which may be 8, 16, or 24 bits (that is, 1, 2, or 3 bytes, which are always called octets in this business). The remaining octets specify a host address which is an individual machine in that network.
The host address portion cannot be all-1-bits because that is the broadcast address. That means, any packet so addressed is meant to be received by all of the hosts in that particular network.
The host address portion also cannot be all-0-bits. That address generally refers to the particular network as a whole. (But that’s not used for broadcasts, though.)
Worth noting that this also applies if you subnet a network (i.e use a subnet other than 8, 16, or 24) - you still have a subnet zero and a subnet all-ones, they just don’t always have a 0 or 255 final octet.
So if you have a /26 subnetting scheme, you get 4 subnets with
subnet 1 (00) xx.xx.xx.0 (subnet 1 zero)
subnet 1 (00) xx.xx.xx.63 (subnet 1 all-ones, broadcast)
subnet 2 (01) xx.xx.xx.64 (subnet 2 zero)
subnet 2 (01) xx.xx.xx.127 (subnet 2 all-ones, broadcast)
subnet 3 (10) xx.xx.xx.128 (subnet 3 zero)
subnet 3 (10) xx.xx.xx.191 (subnet 3 all-ones, broadcast)
subnet 4 (11) xx.xx.xx.192 (subnet 4 zero)
subnet 4 (11) xx.xx.xx.255 (subnet 4 all-ones, broadcast)
Yes, the way I see it, the old system of classes A, B, and C, in which the length of the network portion of the address could be deduced purely from the first few bits of the 32-bit IP address, is obsolete. These days, the network portion can be any length, which is specified by a separate parameter, usually notated with the slash suffix as si_blakely did. When I’m dealing with network people I don’t here them talk about Class C and so on. It’s always “slash 24”, “slash 28” etc.
The new system (which is not that new) is called CIDR (pronounced “cedar,” for classless interdomain routing.) The old classful system is still taught for historical perspective, but is largely obsolete.
All zeroes in the host address is shorthand for “the network”, i.e. often used “network only.”
192.168.0.0 / 24 (meaning netmask 255.255.255.0); I’m not sure what stops 0 from being a host address, but by convention it is not allowed. The hosts are 00000001 to 11111110.
Cisco routers can be configured to allow all 0’s or all 1’s in the subnet portion of an address. This is especially useful when you’ve got large subnets or very few bits to spare for the subnet portion of an address.
Tangentially related question: many years ago I saw what I believe was an early XKCD which was a map of the allocated IP space, in graph form, which demonstrated that Stanford University had more allocated addresses than all of Africa (or something like that).
Does that ring a bell with anyone? What’s the scoop?
Stanford probably had a Class A (/8) IP address back then (16,777,216 ip addresses), whereas Africa had smaller blocks.
A related myth (that Stanford has more IP addresses than China) was (but is no longer) true. Stanford turned in the /8 and has a smaller block, and China has more blocks.
In 2000ish I did some work at a regional hospital in NZ - they had a Class B (/16) address and internet accessible computers (no NAT) and were already getting big money offers from ISPs wanting the address range.
Some ISPs are talking about carrier grade NAT, where multiple residential connections share a single IP address - needless to say, IP purists are aghast at the idea. Just roll out IPv6, already.