Subnet Masks/VLSM Notation

IP addresses and subnet masks are 32-bit numbers. The notation w.x.y.z refers to an address where the high-order byte has value "w", the next byte has value "x", etc. If we take 255.255.255.0 and express it in hexadecimal, we get:

FF.FF.FF.00

or looking at it as a 32-bit integer

FFFFFF00

Each "F" represents the bit pattern "1111" so if we look at the number in binary, we have:

11111111111111111111111100000000

Counting the leading "1" bits, we see that there are 24 -- /24 in VLSM notation.

It is handy to remember that the size of the subnet can be obtained by subtracting the number of consecutive leading "1" bits from 32 and raising 2 to that power. In the above case, 32 - 24 = 8 and 2 ** 8 = 256 addresses. Remember that the number of usable addresses is two less than that (254) because the first and last address in the subnet are reserved as the sub-network and broadcast addresses respectively.

The size of a subnet can be any power of two so long as the address of the subnet is a multiple of it's size. For example, if you want a subnet of size 8, you could choose 192.168.12.8/29 (8 = 2 ** 3 and 32 - 3 = 29). The subnet mask would be:

11111111111111111111111111111000 = FFFFFFF8 = 255.255.255.248.

This subnet would have 6 usable addresses: 192.168.12.9 - 192.168.12.14.

You will still hear the terms "Class A network", "Class B network" and "Class C network". In the early days of IP, sub-networks only came in three sizes:

Class A - Subnet mask 255.0.0.0, size = 2 ** 24

Class B - Subnet mask 255.255.0.0, size = 2 ** 16

Class C - Subnet mask 255.255.255.0, size = 256

The class of a network was determined by the value of the high order byte of its address so you could look at an IP address and immediately determine the associated subnet mask.

As the internet grew, it became clear that such a gross partitioning of the 32-bit address space was going to be very limiting (early on, large corporations and universities were assigned their own class A network!). It was then that VLSM was devised -- today, any system that you are likely to work with understands VLSM and Class-based subnetworking is largely a thing of the past.

Last updated 7/15/2002 - Tom Eastep

Copyright 2002 Thomas M. Eastep