How Do You Calculate The Prefix, Network, Subnet, and Host Numbers?
How Do You Calculate The Prefix, Network, Subnet, and Host Numbers?
IP: 128.42.5.4
Subnet: 255.255.248.0
How could you determine the prefix, network, subnet, and host numbers?
Let's assume we will break 128.42.0.0/21 into 4 subnets that must hold at least 100 hosts
each...
In this example, we know that you need at least a /25 prefix to contain 100 hosts; I chose a /
24 because it falls on an octet boundary. Notice that the network address for each subnet
borrows host bits from the parent network block.
How did I know that I need at least a /25 masklength for 100 hosts? Calculate the prefix by
backing into the number of host bits required to contain 100 hosts. One needs 7 host bits to
contain 100 hosts. Officially this is calculated with:
Since we only want four subnets from the whole 128.42.0.0/21 block, we could use /23
subnets. I chose /23 because we need 4 subnets... i.e. an extra two bits added to the
netmask.
Using the example subnet of 128.42.0.0/21 above, the number of hosts is...
NOTE: If you try starting from the right-hand side, don't get tricked just because you find
one matching column of bits; there could be unmatched bits beyond those matching bits.
Honestly, the safest thing to do is to start from the left-hand side.
…………………………………………
Edit: As per YLearn's suggestion, I'll try to grab the relevant parts from Part 1 of my series,
without pasting the whole entry here.
As it is a /30, we know the host portion is going to be in the fourth octet. Let's convert that to
binary:
128 64 32 16 8 4 2 1
SN SN SN SN SN SN H H
1 0 0 1 1 1 1 1
Now to find out the network address all we do is add the SN bits that have a 1 underneath
them, together. (128 + 16 + 8 + 4 = 156).
When you add this 156 to the first three octets of the address, we’re left with the Network
Address 195.70.16.156.
Now, as we know that the first usable address is always the Network Address plus one, all we
need to do is perform the following calculation: (156 + 1 = 157).
This gives us a First Usable Address of 195.70.16.157.
Now let’s skip the Last Usable Address for a moment and find the Broadcast Address. To
find out what it is, all we need to do is add all of the H bits together (regardless of whether
they are a 1 or a 0) and then add this number to the Network Address. (2 + 1 + 156 = 159).