In a world brimming with articles on subnetting, I’ve ventured to craft a comprehensive guide entitled “How to Calculate Subnet Masks from IP Addresses, Step by Step.” It’s a practical roadmap born from real-world subnetting experience, and it’s here to demystify this intimidating topic once and for all.
For a broader understanding of subnetting, you can dive into Cisco’s extensive resources on the subject.
You can read more on the subject broadly from Cisco’s website here.
Step by step guide to IP Subnetting Video
Below is a simple 6 step by step method I use to perform subnetting calculations.
Let us look at this question below;
1: You have been given an IP Address 10.20.4.13/29 and been asked to find out the following pieces;
- Subnet Address
- First Valid Host Address
- Last Valid Host Address
- Broadcast Address
- Subnet Mask
How to Calculate Subnet Mask from IP Address Step by Step
Before we attempt this question, let us understand that each bit in an IPv4 subnet mask corresponds to a specific value based on powers of 2. These values are represented by the following sequence:
– 128
– 64
– 32
– 16
– 8
– 4
– 2
– 1
Each bit’s position in the subnet mask corresponds to one of these values, with the leftmost bit being the highest value (128) and the rightmost bit being the lowest value (1).
Here’s how it works:
– The leftmost bit in an 8-bit subnet mask, when turned on (set to 1), represents a value of 128.
– The second leftmost bit, when turned on, represents a value of 64.
– The third leftmost bit represents 32.
– The fourth leftmost bit represents 16.
– The fifth leftmost bit represents 8.
– The sixth leftmost bit represents 4.
– The seventh leftmost bit represents 2.
– The rightmost bit, when turned on, represents a value of 1.
By combining these bits in various combinations (turning them on or off), you can create different subnet mask values that allow you to define the network and host portions of an IP address. For example, a subnet mask of 255.255.255.0 (or /24 in CIDR notation) means that the leftmost 24 bits are used for the network, and the rightmost 8 bits are used for hosts within that network. This allows for up to 256 host addresses (2^8) within that subnet.
Let us do it the hard way;
The given IP Address is 10.20.4.13/29. In IPv4, the subnet mask is represented as four 8-bit octets, so the subnet mask 255.255.255.255 is represented in binary as:
11111111.11111111.11111111.11111000
In CIDR notation, “/29” means that the leftmost 29 bits are used for the network portion of the address, leaving 3 bits for host addresses within the subnet.
To calculate the subnet mask:
Start with the binary representation of the subnet mask: 11111111.11111111.11111111.11111000.
Convert each octet to decimal: 11111111 = 255, 11111111 = 255, 11111111 = 255, 11111000 = 248.
The correct subnet mask is 255.255.255.248
With the above step, we now have a real understanding of how to calculate the Subnet Mask from a Network Prefix.
Now let us use a simpler or perhaps call it the easier way to calculate the same below;
Step 1: Find Subnet Number
Subtract the prefix number from /32: 32-29 = 3.
Calculate the subnet mask: 8 Bits – 3 Bits = 5 Bits (Network Bits Turned On).
You might wonder why 8 bits? Well, each octet requires 8 bits for a subnet mask.
To visualize this:
128 64 32 16 8 4 2 1
1 1 1 1 1 0 0 0
128 + 64 + 32 + 16 + 8 = 248
Subnet Mask = 255.255.255.248
Subnet Mask = 255.255.255.248