32 bits, written for humans
An IPv4 address is a 32 bit number. That is the entire truth of it. The dotted form you are used to exists only because 32 raw bits are unreadable, so we split them into four groups of 8 bits, called octets, and write each octet in decimal from 0 to 255. That form is called a dotted quad.
192.168.1.42 11000000 . 10101000 . 00000001 . 00101010
Every subnetting question in this course is answered in the second line, so you need to move between the two forms fluently. Each octet has 8 bit positions with these values:
| Bit position | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
|---|---|---|---|---|---|---|---|---|
| Value | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
To convert a decimal octet to binary, walk left to right and subtract greedily. Take 42:
128? 42 < 128 -> 0, remainder 42 64? 42 < 64 -> 0, remainder 42 32? 42 >= 32 -> 1, remainder 10 16? 10 < 16 -> 0, remainder 10 8? 10 >= 8 -> 1, remainder 2 4? 2 < 4 -> 0, remainder 2 2? 2 >= 2 -> 1, remainder 0 1? 0 < 1 -> 0, remainder 0 42 = 00101010
Going the other way, just add the values under the 1s: 00101010 is 32 + 8 + 2 = 42. Memorize the eight values 128, 64, 32, 16, 8, 4, 2, 1 and you will never need a calculator for any of this.
Because there are 32 bits, the whole IPv4 space holds 2³² = 4,294,967,296 addresses, which sounded infinite in 1981 and ran out in 2011. That single fact drives Unit 6 (NAT) and half of Unit 8 (IPv6).
The split that makes routing possible
MAC addresses are flat, so they cannot be summarized. IP addresses are hierarchical, and that is their whole point. Every address is split into two parts:
- The network portion, the leading bits, which identify a network. - The host portion, the trailing bits, which identify one interface inside that network.
Where does the split fall? Wherever the prefix length says, written as a
slash and a number after the address. 192.168.1.42/24 means the first 24 bits
are network and the last 8 are host. This is CIDR notation (classless inter
domain routing).
The same split can be written as a subnet mask, a 32 bit number with 1s over the network bits and 0s over the host bits.
address 192.168.1.42 11000000 10101000 00000001 00101010 mask 255.255.255.0 11111111 11111111 11111111 00000000 \____ network, 24 bits ___/\_ host _/
A mask always has its 1s contiguous and on the left, so only 33 masks exist, one per prefix length from /0 to /32. The ones you meet constantly:
| Prefix | Mask | Host bits |
|---|---|---|
| /8 | 255.0.0.0 | 24 |
| /16 | 255.255.0.0 | 16 |
| /22 | 255.255.252.0 | 10 |
| /24 | 255.255.255.0 | 8 |
| /25 | 255.255.255.128 | 7 |
| /26 | 255.255.255.192 | 6 |
| /27 | 255.255.255.224 | 5 |
| /28 | 255.255.255.240 | 4 |
| /30 | 255.255.255.252 | 2 |
| /32 | 255.255.255.255 | 0 |
Notice the pattern in the last octet: 128, 192, 224, 240, 248, 252, 254, 255. Each step adds the next bit value. That column is worth knowing by heart.
How many hosts does a prefix hold
With h host bits there are 2ʰ addresses in the block. Two of them are reserved in every ordinary subnet, the network address and the broadcast address, which Lesson 4-2 derives. So:
addresses = 2^(32 - prefix) usable = 2^(32 - prefix) - 2
| Prefix | Host bits | Addresses | Usable hosts |
|---|---|---|---|
| /30 | 2 | 4 | 2 |
| /29 | 3 | 8 | 6 |
| /28 | 4 | 16 | 14 |
| /27 | 5 | 32 | 30 |
| /26 | 6 | 64 | 62 |
| /25 | 7 | 128 | 126 |
| /24 | 8 | 256 | 254 |
| /23 | 9 | 512 | 510 |
| /22 | 10 | 1,024 | 1,022 |
| /20 | 12 | 4,096 | 4,094 |
| /16 | 16 | 65,536 | 65,534 |
| /8 | 24 | 16,777,216 | 16,777,214 |
Two directions to read this table. Smaller prefix means bigger block, which feels backwards until you remember the prefix counts fixed bits, so fewer fixed bits leaves more room. A /8 is enormous, a /30 holds two hosts.
And every step of one bit doubles or halves. A /25 is exactly half of a /24. Two /26s make a /25. This is the arithmetic of Lesson 4-3.
What classes were, and why CIDR replaced them
Before 1993 the split was not free. The first bits of the address chose one of three fixed classes:
| Class | First bits | First octet | Default prefix | Networks | Hosts each |
|---|---|---|---|---|---|
| A | 0 | 1 to 126 | /8 | 126 | 16,777,214 |
| B | 10 | 128 to 191 | /16 | 16,384 | 65,534 |
| C | 110 | 192 to 223 | /24 | 2,097,152 | 254 |
| D | 1110 | 224 to 239 | multicast | n/a | n/a |
The waste is obvious in the last column. An organization with 300 hosts was too big for a class C's 254 and got a class B, wasting 65,234 addresses. Meanwhile the routing tables of the internet grew one entry per assigned network with no way to combine them.
CIDR fixed both problems by making the prefix length explicit and arbitrary. That organization now gets a /23 with 510 usable hosts, a close fit. And a provider holding 192.0.2.0/24 through 192.0.15.0/24 can advertise the single summary route 192.0.0.0/20, which is called route aggregation and is the only reason the internet's routing table is millions of entries rather than hundreds of millions.
Class terminology survives in casual speech, so when someone says "a class C" in 2026 they usually just mean a /24. The classes themselves are gone.