Even if there are a tonne of papers on the topic of subnetting, I’ve taken the risk of writing a step-by-step tutorial called “How to Calculate Subnet Mask from IP Address Step by Step” to share with you the knowledge I’ve obtained about subnetting in the actual world.
Have you ever encountered a task that seems intimidating because it has a lot of prefixes? You are in the right place at the right moment to finally gain a deeper understanding of subnetting.
Understanding subnetting and binary conversion is a prerequisite to calculating a subnet mask from an IP address.
Calculate the Subnet Size
Choose the appropriate subnet size, usually indicated by a CIDR notation (e.g., /24 for a subnet containing 256 IP addresses).
Convert Binary from CIDR Notation
Transform the binary notation from CIDR. Twenty-four network bits, for instance, are represented by the symbol /24 (11111111.11111111.11111111. 00000000).
Complete Subnet Mask
To build the subnet mask, enter “1” for the network bits and “0” for the host bits. The subnet mask in the /24 example is 255.255.255.0 in decimal notation.
An Illustrated Calculation
For example, here’s how to figure out the subnet mask for IP address 192.168.1.0/24:
11111111.11111111.11111111. 00000000 is the binary representation of /24.
Subnet mask 255.255.255.0 should be filled in.
Here is a straightforward six-step procedure that I use to calculate subnetting.
Let’s examine the following query:
1: You are assigned the IP address 10.20.4.13/29 and tasked with learning the following information:
- Broadcast Address
- Subnet Address
- First Valid Host Address
- Last Valid Host Address
- Subnet Mask
Step-by-Step Instructions for Determining Subnet Mask from IP Address
Find the Subnet Number in Step 1
Take the Prefix Number Out of /32 32-29=3
Determine the Subnet Mask
Eight bits less than 3 equals 5 bits (network bits enabled).
Why are eight bits needed for every octet?
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
1 | 1 | 1 | 1 | 1 | 0 | 0 | 0 |
128+ | 64+ | 32+ | 16+ | 8+ | = | 248 |
Mask for the subnet: 255.255.255.248
Determine Subnet Size in Step 2
Raise 2 to the deduction power of (8-3 = 5 Bits). The bits will be called n!
Subnet Size = 2**n
Subnet sizes for every subnet are 2**5.
2 * 2 * 2 = 8
Note: Since the subnet’s block size is 8, the increments, for instance, will now be 0 8 16 32 40, and so forth!
Step 3: Determine Subnet Size for Broadcast Addresses Broadcast Address (2**3) – 1 = (8-1) = 7 – 1 (2**n)
Find the IP Address Subnet in Step 4
Subnet Block Identification for IP Address:
Where is the address 10.20.4.13/29 in each increment—0 8 16 32 40?
Since 13 is between 8 and 16, the address is within the subnet 10.20.4.8/29’s permitted host range.
Step 5: Determine Applicable
Hosts How to determine the subnet’s host count
Valid Host Range = 2**n-2
8-2) = 6 = 2**3 – 2.
The current response to your query is as follows:
- Address of Subnet: 10.20.4.8/29
- Min URL of the host: 10.20.4.9/29
- Maximum Host IP: 10.20.4.14/29
- Link to Broadcast: 10.20.4.15/29
That’s it for you. A straightforward six-step manual for efficient subnetting.
Ascertain the IP address’s class (if classful networking is used).
Classful networking divides The IP address space into five classes (A, B, C, D, and E). For these classes, the default subnet masks are:
1.0.0.0 to 126.0.0.0 is class A.
255.0.0.0 is the default subnet mask.
128.0.0.0 to 191.255.0.0 is class B.
Subnet mask by default: 255.255.0.0
192.0.0.0 to 223.255.255.0 is Class C.
Subnet mask by default: 255.255.255.0
Class D: used for multicast, 224.0.0.0 to 239.255.255.255
Class E: 240.0.0.0 to 255.255.255.255
(set aside for research and development purposes in the future)
Conclusion:
Understanding CIDR notation, binary conversion, and subnetting principles is necessary to calculate a subnet mask from an IP address. Determining the available IP addresses inside a subnet and defining the network boundaries depends on the subnet mask. Network administrators and engineers must know how to compute subnet masks to administer and configure IP networks effectively.