Subnetting Secrets: How to Slice an IP Address Without Starving Your Guests

So, in today's concept, we have IPv4 subnetting. IPv4 is an IP address of 32 bits (v4), which divides itself into 4 sections. 32/4 = 8 bits each. 8.8.8.8 This is the format we write IPv4 addresses in. Each decimal place can range from 0 to 255. That means an IPv4 address can range from: 0.0.0.0 to 255.255.255.255. It can be either 255.0.0.0 or 0.0.255.255. The digits in each decimal place can range from 0 to 255. Now, about how to write the IP address if the hosts of the network are given. I know the word host sounds technical and clueless, but for now, just remember that in host-given subnetting questions, the number of hosts is what we care about.
Let's suppose there is a massive building of 4 storeys where any person can book and throw a party. Usually, bookings come from multiple people at the same time frame. Ram books it for a wedding at 6:10 am, Sita books it for a birthday at 6:50 am, and both want space in the building.(This time frame falls under 6 am to 7 am) Now every storey can accommodate 255 people. For some random Tuesday, 100 hosts(people) booked it from 6 am to 7 am. Same day, 10 hosts booked again in a different time frame of 8:30 am to 9 am, and 8 hosts booked again in a different time frame.
Now we have three cases with us that give us:
Case 1 = 100 hosts (people)
Case 2 = 8 hosts (people)
Case 3 = 10 hosts (people)
And mind you, in IPv4 cases where hosts are already given, the first few decimal numbers of the network address are usually fixed. So let's assume the building already belongs to the owner and has its own street address: 192.168.0.0/24. In our building analogy, imagine the owner's guests occupy the top two storeys because the view is nicer there. But this does NOT mean 192 guests are on one floor and 168 guests are on another floor. The numbers 192 and 168 are simply part of the building's address, just like a house number on a street. The important thing for us is the /24. Think of that as 24 tables already given in place by the owner. We are only allowed to rearrange the remaining space for our own guests and ask for more tables if needed, or just return the one we don’t need.
Now comes the question: Which scenario gets priority?
The one with the most hosts. (the largest number of bookings)
That means Case 1 with 100 hosts. How do we book the building and give chairs to everybody?
There is a rule for it: 2^h - 2 ≥ Hosts, where h is the number of host bits (or the number of zeros we need to leave for hosts).
I will explain where this formula comes from in another blog, but for now, let's memorize it. For Case 1: 2^h - 2 ≥ 100 To find h, let's temporarily convert it into: 2^h - 2 = 100 2^h = 102 Now we know: 2^6 = 64 2^7 = 128 Here comes the clutch. We need at least 102 addresses. 2^6 gives only 64, which starves us of 38 hosts. That would be very mannerless of us. 2^7 gives us 128. Sure, it gives us 26 extra addresses, but we can accept over-love and a little waste. What we cannot accept is scarcity. So we choose: h = 7. Now we have the value of h, and remember I told you this was the number of zeros we need to reserve for hosts.
A subnet mask made entirely of 1s looks like: 11111111.11111111.11111111.11111111
Now we leave the last 7 bits as 0s for our hosts: 11111111.11111111.11111111.10000000
We now convert the last section: 10000000 into decimal. That gives us: 128. So our subnet mask becomes: 255.255.255.128. Now let's figure out the prefix length. (that /24 we did earlier, the prior structure changed now that tables and chairs are decided). We started with 32 total bits. 7 bits are reserved for hosts. That leaves: 32 - 7 = 25 network bits. So our original network: 192.168.0.0/24 becomes: 192.168.0.0/25
Now, to assign each and every guest their own chair, we need something called the block size. The rule is: Block Size = 256 - Last Octet of Subnet Mask. For us: 256 - 128 = 128. Therefore, Block Size = 128. Now we can determine our first subnet. It starts at: 192.168.0.0 and ends at: 192.168.0.127. This subnet is represented by: 192.168.0.0/25. Now you might be thinking: Why not go all the way to .128? Because in networking, we start counting from 0. Think of it like chairs. Chair 0 is still a chair. Chair 1 is another chair. Chair 2 is another chair. By the time we reach 127, we have already counted 128 positions. That is why the first subnet runs from 192.168.0.0 to 192.168.0.127. Now, Case 2 has 8 hosts, and Case 3 has 10 hosts. Since Case 3 has more hosts, it gets priority. But remember: Case 1 has already occupied everything from .0 to .127. So our next available starting point becomes: 192.168.0.128. Why not .127? Because that space is already taken.
Think of it like ice cream. Suppose there are 3 vanilla and 2 chocolate ice creams. If 2 vanilla and 1 chocolate are already sold, the next customer starts with the remaining stock. You cannot sell what has already been given away. The same thing happens in subnetting. Case 1 has already taken its space. Therefore, Case 3 must begin from: 192.168.0.128. Now we repeat the same subnetting math again for Case 3...




