Cats
- arts (1)
- EvrythnElz (1)
- Fun (1)
- How2s (2)
- science (1)
Let’s try to make this easy.
Ok. In order to understand what lies beneath the main idea of sub-netting one should be familiar with the basics of binary arithmetic. Some knowledge in networks, ip addresses, subnet masks, interfaces and classes is required, too.
Suppose we are given the following IP address 192.168.157.0 /22 and we must use it to configure 8 (eight) subnets:
2 subnets having 2 hosts each (sn1 & sn2)
3 subnets having 60 hosts each (sn3, sn4, sn5)
1 subnet having 90 hosts (sn6)
1 subnet having 30 hosts (sn7)
1 subnet having 128 hosts (sn8)
It doesn’t usually matter which subnet would be the first to start with, but if there’s a requirement for lowest cost of hosts in a subnet (minimum number of hosts per subnet), then this should be the one with the maximum number of hosts within. That way we make sure we won’t waste too many IP addresses in the subnet, that are not needed anyway. (Try to keep in mind that 1 host = 1 IP address here).
So, following the logic from above we start with sn8, cause it has the greatest host number – 128.
Now, we could use the /25 mask for the subnet, cause 27 = 128 and that means all 128 addresses can fit into those 7 bits of the host part of the network address (see the picture below), BUT unfortunately it always has to be harder, right – we must actually take 8 bits, instead of 7, because there are 2 IP addresses in every network, that are preserved and cannot be used as host addresses – the Broadcast address and the Interface Address (which tells the router which interface to send the outgoing traffic through).
Here’s the picture and the explanation:
Taking the last 8 bits from the network address ensures that we’ll get 256 unique hosts in this subnet (28 = 256), which perfectly covers the need for 128 unique hosts + 2 preserved ip addresses. Yes, that way we sure waste 126 host addresses form the subnet (256-128-2), but were we to use 7 bits it would result in having only 126 unique host addresses (128 total – 2 preserved), which obviously doesn’t satisfy the condition.
So, the first subnet to configure is sn8:
It doesn’t really matter which of the subnet addresses is gonna be used as IA, but a good practice would be to always use the first available.
The next subnet to be configured should be sn6 – the one with 90 hosts inside (max to min). Since we msut supply 90 hosts (+2 preserved) we could use the /25 mask, cause 7 bits from the network address are pretty much enough to provide the needed number of hosts (27 = 128, which is bigger than 92). The mask is actually calculated very easy: the network address has 32 bits total, we take out 7 bits of it (so we can have 128 unique addresses) and we get 25 bits for the subnet address (32 – 7 = 25)
So, once again, sn6:
The next subnet to configure should be the three with 60 hosts (sn3, sn4 and sn5). We could use the same mask here (/25), but that would be a big waste of addresses in each subnet, because /25 means 128 unique hosts and we only need 62 (60 hosts + 2 preserved addresses). So we better use /26 mask – this means we will use the last 6 bits from the network address (26 = 64, which is just enough).
sn3:
sn4:
sn5:
Subnet sn7 must provide 30 HAs (+2 preserved), so we could use mask /27, because 25 = 32 (which is just about enough). This means we use the last five bits from the NA to determine the hosts and the first 27 bits to determine which subnet they belong to (32 – 5 = 27).
sn7:
The last 2 subnets must provide two unique hosts each. We cannot use just one bit to do this, because we still need to have +2 preserved (so each of the subnets should actually provide 4 unique host adresses). Since using 21 isn’t good enough we move on to 22, which is 4 – perfect. Using those 2 bits from the NA to determine the unique hosts leave us with 30 bits from the NA to determine the subnet. So the mask for sn1 and sn2 is /30
sn1:
sn2:
Usually subnets with 2 hosts are used for Layer 3 devices’ serial interfaces and the 2 hosts of the subnet are actually the addresses of the interfaces at both ends of the connection.
Here’s the complete transcription of the masks:
/24 – 255.255.255.0
/25 – 255.255.255.128 = 11111111.11111111.11111111.10000000
/26 – 255.255.255.192 = 11111111.11111111.11111111.11000000
/27 – 255.255.255.224 = 11111111.11111111.11111111.11100000
/30 – 255.255.255.252 = 11111111.11111111.11111111.11111100
To be continued
Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.
Social comments and analytics for this post…
This post was mentioned on Reddit by dougb: This isn’t 1997. Use a calculator and you’ll make considerably less mistakes….
December 22, 20091:01 am
true. unfortunately my mentors at the University won’t let me use a calculator on my exam
December 22, 2009 at 10:55 pm