Posts Tagged Subnet
Classful IP Addressing 101
Posted by Harv in Networking on December 30, 2009
Let’s explore the different IP address classes!
We’ll address (ha) the IP classes, their ranges and classful subnets. There’s also some binary math involved- nothing too difficult, but if it’s too confusing, drop me a comment and I’ll write up a binary math article. My notes include ways to make it easy to remember everything. I am studying for an exam, after all. Okay, onward!
There are three classes available to the general public. They are conveniently called Class A, Class B, and Class C. Class D and E exist as well, but are reserved. Class D are multicast, and E is experimental. We might talk about them later – for now let’s focus on the big three.
Before I get into the actual IP ranges of each class, let’s quickly cover the subnet mask. Each class has what’s called a default subnet mask. If you wanted to, you could customize a class with a different subnet mask in order to produce a tailored number of networks and hosts. That’s called subnetting and is more advanced, so for the moment, forget about it.
When you see a subnet mask, that basically splits up the network part of the IP address, and the host part. Every IP address defines a network, and a host. My CCENT/CCNA ICND 1 book uses the example of zip codes; everyone within a certain radius has the same zip code. So when sorting mail, you can sort it by zip code, and then break it down by street or what have you. By that analogy, you can break a big problem (think all of the mail coming into a country) into a smaller one – next would be state/provincial level into district/city, into a smaller one zip code into street, and then onto house number. It makes finding the recipient way simpler.
The subnet mask defines which part of the IP address is the network.
For instance- 255.0.0.0 in binary translates into 11111111.00000000.00000000.00000000
If an IP address uses that subnet mask, the first byte is used for the network, and the other three bytes are used for the host. The first byte would be like the zip code, and the other three would be the house number. That means that per zip code, there are a LOT of houses. Poor mailman.
255.255.0.0 translates to 11111111.11111111.00000000.00000000, and 255.255.255.0 translates to- you got it! 11111111.11111111.11111111.00000000.
Right, onto the important stuff.
One thing you should take note of now, is that each class has “leading bits”;
depending on the class, when looking at the IP, it will always start with specific bits.
Class A’s reserved bit is 0.
Class B: 10
Class C: 110
We will get back to this and how it relates to IP addresses.
Class A
Subnet: 255.0.0.0
IP Range: 0.x.x.x – 127.x.x.x
The first thing you need to know: 0.0.0.0 and 127.0.0.0 are reserved. That leaves us with an actual, valid range of 1.x.x.x – 126.x.x.x.
If you’re confused about this whole network/subnet thing, let’s break an IP and Subnet down into binary. We’ll use 8.22.118.45 as the IP and 255.0.0.0 as the subnet.
Subnet 255.0.0.0 - 11111111.00000000.00000000.00000000 IP 8.22.118.45 - 00001000.00010110.01110110.00101101
Now if we disregard the parts of the IP address that are “masked” (represented by a zero in the subnet mask), we can see which part is the network.
255.0.0.0 - 11111111.00000000.00000000.00000000
|NETWORK-|-----------HOST-----------|
8.22.118.45 - 00001000.00010110.01110110.00101101
So there’s a network address of 8.0.0.0 and a host address of 22.118.45, and when put together, we get the IP 8.22.118.45.
Rule 1: The Subnet Mask dictates which portion of an IP address represents a network, and which portion represents a host.
|NETWORK-|HOST-| 00000000.x.x.x - 01111111.x.x.x
should be the range. Note that we’re not concerned with the host for now.
That comes out to 0.x.x.x through 127.x.x.x. As said before, 0.x.x.x and 127.x.x.x are restricted.
So 1-126, inclusive, are available for use as network numbers. But we’re not finished! What about how many hosts we can fit on any given network?
Rule 2: On any given network, the all-zero’s and all-ones IP’s are reserved for “whole network” and “broadcast” IP’s.
Let’s look back on our example.
8.22.118.45 – 00001000.00010110.01110110.00101101
The all-zero’s IP would look like this:
8.0.0.0 – 00001000.00000000.00000000.00000000
This IP address is used to identify the network.
The other special case..
8.255.255.255 – 00001000.11111111.11111111.11111111
is used to “broadcast” a message to all devices connected to the 8.0.0.0 network.
Keeping that rule in mind, we could calculate the number of hosts per network using the formula 2n-2, where n is the number of bits available in the hosts portion of the IP. We subtract two from 2n so we can respect the whole-network and broadcast IP’s.
For example:
255.0.0.0 - 11111111.00000000.00000000.00000000
|NETWORK-|-----------HOST-----------|
8.22.118.45 - 00001000.00010110.01110110.00101101
here we have 24 bits available for the host. 224-2 is 16,777,214 hosts per network.
Class B
Default Subnet: 255.255.0.0
Reserved bits: First two, 10.
IP Range: 128.0.x.x – 191.255.x.x
Alright. Quick recap. Class A’s range was 1.x.x.x – 126.x.x.x, keeping in mind that 0.x.x.x and 127.x.x.x are reserved.
Now, with Class B, we have not one but two reserved bits for this class, and a different subnet mask.
Let’s calculate our range.
Subnet: 11111111.11111111.00000000.00000000
|-----NETWORK-----|-------HOST------|
IP Range: 10000000.00000000.xxxxxxxx.xxxxxxxx -
10111111.11111111.xxxxxxxx.xxxxxxxx
Note that we have to pay attention to the reserved bits. I’ve bolded them in the example above.
The IP range above comes out, in decimal form, to 128.0.x.x – 191.255.x.x
Let’s calculate how many networks this class can support.
Note in the network field, we have 14 bits available. You may have thought we’d have 16, however the first two are reserved and never change, remember? Always 10 for Class B!
214 = 16,384 networks. 216-2 = 65534 hosts per network.
Class C
Default Subnet: 255.255.255.0
IP Range: 192.0.0.x – 223.255.255.x
This time the first three bits don’t get modified, and are fixed at 110.
We have 21 bits available for the network and 8 available for the host.
221 = 2,097,152 networks, 28-2 = 254 hosts per network.
Quick summary of the rules involved here:
- Remember that Class A includes 0.0.0.0 and 127.0.0.0, both of which are reserved.
– Classes A, B and C use one two or three reserved bits, respectively. They are 0, 10, and 110.
– Total networks is calculated by checking the subnet mask for that class (255.0.0.0, 255.255.0.0, 255.255.255.0, for class A, B, and C, respectively),
and turning it into binary. Count the number of ones in the network portion. Subtract the number of reserved bits. Take that number, and apply the 2n rule. Subtract two if calculating for Class A,
as 0.x.x.x and 127.x.x.x are reserved and so don’t count.
– Total hosts is calculated by figuring out how many bits is available for hosts. Apply the 2n-2 rule.
– Remember that the all-zero’s and all-ones (x.255.255.255, x.x.255.255, x.x.x.255 for classes A, B and C, respectively) are reserved for “whole network” and “broadcast” addresses.
– You should realise now that you only need to know the “reserved bits” for each class in order to calculate (if you know how to convert binary)
the IP ranges of each class.
Phew! This can be, at first, a difficult concept to grasp. But it is absolutely essential. Please leave me a comment if people feel I should write up a quick blurb on binary math.
Originally posted 2008-12-30 00:29:22.
Recent Comments