You cannot understand subnet masks without seeing addresses in binary. The good news is that you need very little binary, and it is all in this lesson.
Eight bits, eight values
Each octet is 8 bits. Each bit position has a value, doubling from right to left:
128 64 32 16 8 4 2 1
An octet's value is the sum of the positions set to 1.
192 = 1 1 0 0 0 0 0 0 = 128 + 64
255 = 1 1 1 1 1 1 1 1 = 128+64+32+16+8+4+2+1
0 = 0 0 0 0 0 0 0 0
20 = 0 0 0 1 0 1 0 0 = 16 + 4
Those eight numbers — 128, 64, 32, 16, 8, 4, 2, 1 — are worth memorising. They are the only arithmetic in this course.
Converting decimal to binary
Work left to right. For each position, ask "does this fit in what remains?" If yes, write 1 and subtract; if no, write 0.
Take 200:
128 fits in 200? yes → 1, remainder 72
64 fits in 72? yes → 1, remainder 8
32 fits in 8? no → 0
16 fits in 8? no → 0
8 fits in 8? yes → 1, remainder 0
4, 2, 1 0 0 0
200 = 1 1 0 0 1 0 0 0
Check: 128 + 64 + 8 = 200. Correct.
The values you will actually meet
Subnet masks only ever use eight values in their interesting octet, because the ones are always contiguous from the left:
| Decimal | Binary | Ones |
|---|---|---|
| 0 | 00000000 | 0 |
| 128 | 10000000 | 1 |
| 192 | 11000000 | 2 |
| 224 | 11100000 | 3 |
| 240 | 11110000 | 4 |
| 248 | 11111000 | 5 |
| 252 | 11111100 | 6 |
| 254 | 11111110 | 7 |
| 255 | 11111111 | 8 |
That is the whole table. If a mask octet is not in this list, it is not a valid mask — 255.255.255.100 is meaningless, because 100 is 01100100 and the ones are not contiguous.
You will find yourself recognising these on sight within a day of using them. Print the table; it is the most useful page of the handout.