Introduction
Welcome back! Today, in our Networking For Hackers Series, we’re onto Day 3. Our focus? Subnetting—an essential skill for hackers and penetration testers. In your engagements, you’ll encounter numerous cases involving networks of all sizes. It’s essential to grasp the basics, such as IP address types, available hosts, and ranges, to conduct thorough network analyses. Let’s jump into today’s blog and explore the subnetting together.
What is Subnetting in Networking ?
Subnetting in computer networking is the practice of dividing a larger network into smaller, more manageable subnetworks, or subnets. This helps improve network performance, organization, and security by allowing for better traffic management and segmentation of devices within the network.
Why We Need Subnetting ?
IP addresses are designed to help routers route data efficiently across the Internet. However, in large networks like Class A, with millions of devices, it can take time for data to reach its intended destination. Subnetting solves this by narrowing down IP addresses to specific ranges of devices.
Since an IP address only identifies the network and device, it can’t specify which subnet a packet should go to. That’s where subnet masks come in. Routers use subnet masks to organize data into subnetworks, ensuring it reaches the right destination smoothly.
Subnetting Cheat sheet
There are alternative of this Subnetting Cheat Sheet Available too on Google.
Some Details About Above Cheat Sheet:
- Hosts is double each increment of a CIDR.
- We had always need to subtract 2 from local host.
- Network ID = First Address
- Brodcast = Last Address
Let’s Understand Everything Using Examples
Subnetting comes in handy to answer these basic questions:
- Identify the network and broadcast address
- No. of hosts available in the network range?
- What masks allow the particular host?
Example: 1
CIDR Range: 192.168.0.0/24
Now we had to find Subnet Mask , No. Of Hosts, Network ID, Brodcast 🙂
- Subnet Mask:
Looking in the Cyber Mentor Cheat sheet we get subnet mask 255.255.255.0
This is because we had Subnet for this range in Cyber Mentor Cheat sheet is 255.255.x.0 and if for our CIDR range which is /24 we need to replace x value to 255
- No. Of Hosts
As we said earlier we had to Subtract always from 2 for finding no. of host i.e, 2^(n)-2
The subnet mask for /24 indicates that the first 24 bits are used for the network portion, leaving 32 – 24 = 8 bits for the host portion.
now 2^8 = 256, as we can see in the above cheat sheet too. Subtract this value with -2 i.e, 256-2 = 254
So we had Available No. Of Hosts = 254
- Network ID
Network ID is the first address and in our case first address is 192.168.0.0
- Broadcast
Broadcast is last address
To find the broadcast address, you set all the host bits to 1 within the subnet. Since there are 8 host bits, the binary representation of the host portion for the broadcast address will be 8 consecutive 1s.
Converting 8 bits of all 1s to decimal gives you the maximum value for the host portion, which is 2^8 – 1 = 255.
So, to calculate the broadcast address, we add 255 to the last octet of the network address:
i.e, 192.168.0.0+255
For adding this let’s first convert the IP address in binary form
192 = 11000000
168 = 10101000
0 = 00000000
0 = 00000000
Then we have 8 1’s, Let’s add them in last octet
00000000 (original last octet)
+ 11111111 (8 host bits, all set to 1)
———————-
11111111 (result of adding)
which make 255 in Decimal Form
Replace the last octet of the original IP address with the decimal value obtained. So, the resulting IP address would be:
192.168.0.0+255 = 192.168.0.255
Example 2:
CIDR Range: 10.10.0.0/16
- Subnet Mask
255.255.0.0
- No. Of Hosts
The subnet mask for /16 indicates that the first 16 bits are used for the network portion, leaving 32 – 16 = 16 bits for the host portion.
So, 2^(n)-2 = 65,536 – 2 = 65,534
- Network ID
Network ID is the first address and in our case first address is 10.10.0.0
- Broadcast
To find the broadcast address, you set all the host bits to 1 within the subnet. Since there are 16 host bits, the binary representation of the host portion for the broadcast address will be 16 consecutive 1s.
Converting 16 bits of all 1s to decimal gives you the maximum value for the host portion, which is 2^16 – 1 = 65,535
Now, we need to represent 65535 in binary. Since it exceeds the maximum value for an 8-bit binary number (which is 255), we need to use more than one octet.
So, to calculate the broadcast address, we add 65,535 from the last octet of the network address:
i.e, 10.10.0.0+65,535
For adding this let’s first convert the IP address in binary form
10 = 00001010
10 = 00001010
0 = 00000000
0 = 00000000
Then we have 16 1’s, Let’s add them in last two octet
00000000 (original last octet)
+ 11111111 (8 host bits, all set to 1)
———————-
11111111 (result of adding)
which make 255 in Decimal Form.
Same for the next octet which give value 255 too.
Replace the last two octet of the original IP address with the decimal value obtained. So, the resulting IP address would be: 10.10.255.255
Conclusion
In conclusion, subnetting is a valuable tool for managing networks effectively. By breaking down large networks into smaller, more manageable parts, it simplifies tasks and enhances security. It’s an essential networking skill for anyone working with networks, offering practical benefits in resource allocation and organization. In our next “Networking For Hacker’s | Part-4”, we’ll explore the TCP/IP Model and OSI Model, providing a deeper understanding of how data moves through networks. Stay tuned for more insights into these fundamental concepts!
Subscribe to Our FREE Daily Newsletter For Hacker’s & Tech. Students
New here? Start From “Networking For Hacker’s | Part-1” & Follow Us on Instagram, LinkedIn, Facebook