Section 1: Subnetting without fear
The binary you actually need
Subnetting is easiest when you understand the binary behind it. The good news is that you need only a small part of binary maths, and it becomes automatic with a little practice.
Bits in an octet
An IPv4 address has four octets of 8 bits. Each bit position has a value:
128 64 32 16 8 4 2 1
To convert a number to binary, go left to right and switch on bits that fit:
192 = 128 + 64 = 11000000
168 = 128 + 32 + 8 = 10101000
10 = 8 + 2 = 00001010
255 = all bits on = 11111111
Subnet masks in binary
A subnet mask is a run of ones followed by zeros. The number of ones is the prefix length:
/24 = 11111111.11111111.11111111.00000000 = 255.255.255.0
/26 = 11111111.11111111.11111111.11000000 = 255.255.255.192
/28 = 11111111.11111111.11111111.11110000 = 255.255.255.240
Only a few values can appear in a mask octet, so memorise them:
Bits on: 0 1 2 3 4 5 6 7 8
Value: 0 128 192 224 240 248 252 254 255
Network and host bits
The ones in the mask mark network bits. The zeros mark host bits. With h host bits:
- Total addresses in the subnet = 2 to the power of h.
- Usable hosts = 2 to the power of h, minus 2 (network and broadcast addresses).
Powers of two to know by heart:
2^1=2 2^2=4 2^3=8 2^4=16 2^5=32
2^6=64 2^7=128 2^8=256 2^9=512 2^10=1024
So a /26 has 32 minus 26 = 6 host bits, giving 64 addresses and 62 usable hosts. A /30 has 2 host bits, 4 addresses and 2 usable hosts, which is why /30 was traditionally used for point to point links between routers. A /31 is also allowed on point to point links on modern equipment, giving two usable addresses without network or broadcast.
The block size
The most useful shortcut is the block size: 256 minus the interesting mask octet. For a /26, the mask octet is 192, so the block size is 64. Subnets then start at multiples of 64 in that octet: 0, 64, 128 and 192. We use this shortcut constantly in the next lesson.
Practise converting five numbers to binary and calculating hosts for /25 through /30.