Now let’s try creating a custom subnet mask for a Class B address. Remember that the default mask will be 255.255.0.0. So if subnetting a Class B address, we’re going to begin defining our custom mask in the third octet. Say that we require at least 72 subnets to meet our current requirements. Let’s walk through the steps below:
- Since we know that we need at least 72 subnets, our first step is figuring out how many bits we’ll need to steal from the host portion. We’ve already looked at an example with 5 bits, so we know that won’t be enough – 25-2 provides only 30 subnets. How about 6 bits? That only provides 26-2, or 62 – again not enough. 7 bits will provide 27-2, or 126 subnets – this meets our requirement of 72, and also accounts for future growth.
- Given that we need 7 bits, the next step is to define the custom subnet mask in binary. In this case, the first 16 bits will define our Class B network, the next 7 bits will define our subnets, and the remaining bits will define hosts.
- Still looking at the figure from the previous step, calculate how many host bits remain. In this case, there are 9 host bits available. This gives us a maximum of 29-2, or 510 hosts per subnet.
- Convert the subnet mask to decimal and we’re done – our custom mask is 255.255.254.0
But what if you need more subnets than 8 bits can provide? No problem – just steal more bits! For example, imagine that in the example above we actually required 300 subnets. Obviously 8 bits won’t meet our needs, since 28-2 is only 254. But what about 9 bits? This will actually meet our needs – 9 bits provides 29-2 or 510 subnets. Don’t get worried about spanning octets when you’re subnetting. You just keep on stealing bits in high order. This is illustrated in the figure below.
Figure: Custom subnet mask using 9 bits to define subnets for a Class B address.
Notice that when converted back to decimal, our custom subnet mask becomes 255.255.255.128. This mask is absolutely valid, and leaves us a total of 7 host bits. This provides for a maximum of 27-2 hosts per subnet – 126. In other words, our mask provides 510 subnets total, with each supporting up to 126 hosts.