VLSM stands for Variable Length Subnet Mask. In order to divide network to subnets you must know its IP and subnet mask.
I know it sounds terrible but we need to use some… maths. But, don’t worry. This one is extremely easy ;).
If you know the number of desirable IP addresses in a single subnet then you should use this formula: 2x >= NIP + 2
Where NIP stands for number of desirable addresses and x stands for number bits in mask host part. Using this formula we can obtain the number of 0 bits in mask address. The rest are 1.
If you know the number of desirable subnets you must use following formula: 2x >= Nsubnet
Where Nsubnet is number of desirable subnets and x is the number of host bits in mask. Using this formula we can obtain the number of 1 bits in subnet mask. The rest are 0.
Dividing B class IP to subnets
Let’s say that each subnet needs to has 500 addresses.
- The network part of mask for B class is 16 bit length.
- The host part of mask for B class is 16 bit length.
In order to divide network to subnets with, at least, 500 addresses we need to find x in following formula:
2x >= 500 + 2
29 is 512. So, x = 9 because when x equals 9 then we have 512 addresses.
- Network to divide: 220.127.116.11
- Starting mask: 255.255.0.0
- Binary starting mask: 11111111 11111111 00000000 00000000
- Divided mask in binary: 11111111 11111111 11111110 00000000 because x = 9 so, we put 9 zeros at the end.
- Divided mask in decimal: 255.255.254.0
Dividing C class IP to subnets
As an example, let’s say that we want to divide C class IP address to 8 subnets.
- The network part of mask for C class is 24 bit length.
- The host part of mask for C class is 8 bit length.
Let’s say our network IP address is 192.168.1.0 . The mask for C class is 255.255.255.0 .
In order to divide this network to 8 subnets we need to find a number that will fit in following formula:
2x >= 8
23 is 8. So, x equals 3.
- Network to divide: 192.168.1.0
- Starting mask: 255.255.255.0
- Binary starting mask: 11111111 11111111 11111111 00000000
- Divided mask in binary: 11111111 11111111 11111111 11100000 because x = 3 . So, we put 111 at the begin of host part of the mask.
- Divided mask in decimal: 255.255.255.224
The network has been divided to 8 subnets.