Fixed Length and Variable Length Subnet Mask Numericals
Last Updated :
29 May, 2020
Before starting off with this article make sure you know the basics of
Subnetting and
Classless Addressing.
1. Fixed-Length Subnet Mask :
When a block of addresses is divided into subnets all having an equal number of addresses, the type of subnetting is said to be Fixed Length Subnetting. The subnet masks used here will be the same for all the subnets as the number of addresses is equal for each subnet.
Example -
Consider an address block 121.37.10.64 /26.
Find the first and last addresses for each subnet, if the number of equal sized subnets required is as given in the input.
Input :
Number of subnets required = 4
Output :
Subnet-1:
First Address: 121.37.10.64 /28
Last Address: 121.37.10.79 /28
Subnet-2:
First Address: 121.37.10.80 /28
Last Address: 121.37.10.95 /28
Subnet-3:
First Address: 121.37.10.96 /28
Last Address: 121.37.10.111 /28
Subnet-4:
First Address: 121.37.10.112 /28
Last Address: 121.37.10.127 /28
Since 4 subnets are required, we need 2 bits to identify each subnet. Thus the subnet mask now becomes (/28)..
Number of variable bits left = 32 -28 = 4 bits. Thus the total number of addresses in each subnet= 2
4= 16.
Figure - Address space divided into 4 equal sized subnets
There are two ways of approaching the solution:
Method-1:
- To find the First Address, understand that the first 26 bits will be the same as the address given because they were fixed. As discussed above the next 2 bits will also be fixed.
- Out of the 16 addresses of that a subnet holds, to point its first address it is required that all the 4 (non-fixed) bits are 0.
- So the first address of the 1st subnet =
121.37.10. 01 00 0 0 0 0 /28 = 121.37.10.64/28.
For the 2nd subnet = 121.37.10. 01 01 0 0 0 0 /28 = 121.37.10.80/28
and so on.
- To find the last address, add (the number of addresses in the subnet -1) to the first address of that subnet. In this case, add (16-1) to the first address of each subnet. So the last address of the 1st subnet is
121.37.10.79/28.
Method -2 (shortcut):
- To find the first address of the 1st subnet, carryout AND operation between the address given and the subnet mask of the 1st subnet.
Performing AND operation :
01111001 00100101 00001010 01000000/26
AND 11111111 11111111 11111111 11110000/28
-------------------------------------------------------------------------
01111001 00100101 00001010 01000000 /28
Thus, first Address of the 1st subnet
= 01111001 00100101 00001010 01000000 /28 = 121.37.10.64 /28
- To find the last address of a subnet, perform OR operation between the first address of the subnet and the complement of the subnet mask.
First address of 1st subnet,
= 01111001 00100101 00001010 01000000 /28
Complement of the subnet mask,
= 00000000 00000000 0000000 00001111 / 28
Performing OR operation we get the last address of the 1st subnet
= 01111001 00100101 00001010 00001111 / 28 = 121.37.10.79 /28
- Add 1 to the last address of the previous subnet to find the first address of the next subnet.
Note -
When the number of subnets required cannot be computed in the powers of 2, then divide address space in a way that the number of subnets is closest to a number that can solely be represented as a power of 2.
For example, if we need 14 subnets, then since 14 cannot be represented solely in the powers of 2, so we divide address space into 16 equal subnets. Now the respective addresses can be found using the above-mentioned method.
2. Variable Length Subnet Masks :
When a block of addresses is divided into subnets containing different numbers of addresses, type of subnetting is said to be Variable-Length Subnetting.
The subnet masks used here might not be the same for different subnets.
Example:
Consider a block of address with starting address 112.78.0.0/16. Find the first and last addresses for each group, if the number and size of the subnets required by them are as given in the input.
Input:
Group-1:
256 subnets, each needs 128 addresses
Group-2:
1024 subnets, each requiring 4 addresses
Group-1:
128 subnets, each consisting of 16 addresses
Output:
Group-1:
First Address : 112.78.0.0 /17
Last Address : 112.78.127.255 /17
Group-2:
First Address : 112.78.128.0 /20
Last Address : 112.78.143.255 / 20
Group-3:
First Address : 112.78.144.0 /21
Last Address : 112.78.151.255 /21
To understand such problems, it is important to understand the procedure to fix the bits in the subnet ID and find the subnet mask for each group of subnets.
Given the Total addresses in the address block,
= 232-16 = 65,536
Understanding the division of address space,
Group-1:
Number of addresses = 256 x 128 = 32, 768
Thus, group 1 occupies 1/2 of the addresses in the block. So, 1 bit is fixed to identify this half and the Subnet Mask becomes /17.
Similarly for
Group-2, a total of 4 bits are fixed and the Subnet Mask becomes /20.
And, for
Group-3, a total of 5 bits are fixed and subnet mask becomes /21.
Then using Method 2 mentioned above, the respective starting and ending addresses can be found.

For the sake of understanding the problem, let the block of addresses be represented by a big square which can be further divided into the required subnets. Since the total number of addresses in the block = 65, 536, it can be deduced that the square is made up of 256 x 256 addresses. Observe the division of the address space and fixing of the initial bits in the subnet ID of the address space carefully. The blanks along with 8 more blanks together will be the host ID.
Once the address space is appropriately divided and respective subnet masks found, use the methods above to find the required addresses.
Similar Reads
Introduction of Variable Length Subnet Mask (VLSM)
Variable Length Subnet Mask (VLSM) is a technique used in IP network design to create subnets with different subnet masks. VLSM allows network administrators to allocate IP addresses more efficiently and effectively, by using smaller subnet masks for subnets with fewer hosts and larger subnet masks
6 min read
Virtual Length Subnet Mask (VLSM ) in IP Networking
VLSM is an IP routing technique that is applied for optimal use of the available Internet Protocol address space. Specifically, with the virtue of CIDR (Classless Inter-domain Routing), the IP address space is segmented into variable-size subnets against the obscured of the actual number of hosts wi
9 min read
Finding Network ID of a Subnet (using Subnet Mask)
In order to find network id (NID) of a Subnet, one must be fully acquainted with the Subnet mask. Subnet Mask: It is used to find which IP address belongs to which Subnet. It is a 32 bit number, containing 0's and 1's. Here network id part and Subnet ID part is represented by all 1's and host ID par
2 min read
Difference Between VLAN and Subnet
In network management, VLAN (Virtual Local Area Network) and Subnet are important instruments that is used to manage networks and its traffic. Their main purpose is to divide large existing networks into smaller ones, which would be easier to work with. However, they get to this goal in a different
6 min read
C Program to find IP Address, Subnet Mask & Default Gateway
Terminology IP Address : An IP address, short for Internet Protocol address, is an identifying number for a piece of network hardware. Having an IP address allows a device to communicate with other devices over an IP-based network like the internet. Subnet mask: A subnet mask is a 32-bit number used
2 min read
Logical Unit Number (LUN) Masking
Logical Unit Number (LUN) Masking is process that grants control of data access by specifying LUNs which can be accessed by computer system. It is usually performed at Host Bus Adapter (HBA) level. Storage subsets are created by LUN masking within Virtual SAN where only identified servers are author
2 min read
How to Calculate Number of Host in a Subnet?
Subnetting is a critical task in a network setup involving dividing a larger network into smaller, manageable subnet segments. Calculating the number of hosts that can fit into each subnet is essential for efficient IP address usage and network optimization. This calculation not only ensures efficie
8 min read
Subnetting Implementation in Cisco Packet Tracer
A subnet, or subnetwork, is a part of a larger network. Subnets are a logical part of an IP network into multiple, smaller network components. The Internet Protocol (IP) is the method for transmitting data from one computer to another over the internet network. Each computer, or host, on the interne
3 min read
Subnet Mask Cheat Sheet
A Subnet Mask is a numerical value that describes a computer or device's how to divide an IP address into two parts: the network portion and the host portion. The network element identifies the network to which the computer belongs and the host part identifies the unique computer on that network. An
9 min read
Heuristics of subnet guessing in Software Defined Networks(SDN)
Overview :To guess the subnet for a given IP address, there are 3 basic heuristics that will be used in Software Defined Networks Algorithm. The three heuristics are as follows. Subnet guessing using broadcast pingSubnet guessing from a cluster of addressGuessing valid address in a domainLet's discu
3 min read