Tuesday, August 30, 2005

IP Subnetting

If you're persuing any certification such as CCNA, MCSE, CNE, LPI, or CLP be it Cisco, Microsoft, or Linux, you're going to get test questions on IP Subnetting.

I've come across some web sites that give good tutorials for IP Subnetting:
CertCities.com Linux Certification

Test Question Example:
You have been allocated a IP address for your network. At present we need 13 subnets. In the future we will need to allow for the expansion up to 28 subnets. You need to be able to connect up to 2000 IP addresses available in each subnetwork.

Devise an IP addressing scheme, giving the subnetwork, first host, last host and broadcast IP addresses for each subnet. Also specify the subnet mask you would use.
Use the methodology described next.
You will need to
i. Determine the required number of bits to borrow for subnetting.
ii. Determine the subnet mask
iii. Determine all subnet network addresses
iv. Determine the addresses of the first host, last host and broadcast on each subnet.
You need to include all the calculations and explanations for each item; no marks will be awarded for any unjustified correct answers.

Range: to

Now, the others from the calc is:
2 - to
3 - to

More info:
The number of subnets will define how many bits of the IP address you need to use for the network portion of the address, and the number of hosts per subnet will define how many bits of the IP address you need to use for the host portion of the address.

Okay... you're given the Class B address Normally, for a Class B address, 16 bits are used for the network portion and 16 bits are used for the host portion. At present, we need 13 subnets, but we must be prepared for future expansion. Therefore, we should allocate 28 subnets (yes, ignore the 13 subnet part - it's there to make sure you're reading the whole question correctly). That means we need to steal, at a minimum, 5 bits that we would normally use for host addresses and use them for subnets. Why 5 bits? Because 2 to the 5th power is equal to 32 (2 to the 4th power only gives 16 subnets... 2 to the 6th power gives 64 subnets). Even discounting the "all-zeros" and "all-ones" subnets, we still have 30 subnets we can use.

Okay, so how many bits does that leave us for host addresses for each of those subnets? Well, we used to have 16 bits... but we stole 5 for subnets. Is 11 bits enough to handle 2000 IP addresses per subnet? Let's calculate... 2 to the 11th power is 2048 - minus 2 addresses for the network address and broadcast address, and we've got 2046 available IP addresses per subnet. Barely enough!

Back to the subnet portion... how do you get the increase of 8 for each range? Here's how I look at it:

A /16 mask (normal Class B) has 1 big subnet, with an "increase" of 256 per range.
A /17 mask (stealing one bit for subnets) makes 2 subnets (provided you can use the all-zeros and all-ones subnets), with an "increase" of 128 per range.
An /18 mask makes 4 subnets, with an "increase" of 64 per range.
A /19 mask makes 8 subnets, with a 32 increase per range.
A /20 mask makes 16 subnets, with a 16 increase per range.
A /21 mask (stealing 5 bits, which is what you have), makes 32 subnets, with an 8 increase per range. Your calculations are accurate.

No comments: