The way that IP addresses have been used and allocated over the years has changed somewhat, however the principles have not changed. In order to better manage IP addresses they were put into classes and each class followed certain rules. In this post we are going to focus on the Class-full address structures, and understand where they come from.
Class-full addresses are broken down into 5 different classes, A – E. In order to find out what class an IP address belongs to, all we need to do is look at the first octet and look at the below table.
Number in the first octet: 1 – 126
Subnet mask: 255.0.0.0
Number in the first octet: 128 – 191
Subnet mask: 255.255.0.0
Number in the first octet: 192 – 223
Subnet mask: 255.255.255.0
Number in the first octet: 224 – 239
Number in the first octet: 240 – 255
You will notice in the above I have not mentioned the subnet mask values for class D and E. At this point I’m only concerned with the Unicast Traffic (one-to-one) which are Classes A,B and C. Class D is used for Multicast traffic (one-to-many), and class E is used for Broadcast (one-to-all).
You will also notice that I have left out a start IP address of 127, this is deliberate as any IP address that starts with 127 is reserved for local loopback testing. The local loopback exists on every machine in the world, and you will be able to ping the IP address 127.0.0.1 from the machine you are reading this on. The purpose of this loopback, is to test that your network card is working and functional, assuming you cannot ping 127.0.0.1 there is a good chance you have a fault with your network card.
NOTE: Although 127 is not allowed in the first octet… it IS ALLOWED EVERYWHERE ELSE!!!
The next question I have been asked many times while teaching the concept, is “Why the funny numbers, why not something easy to remember?” And the answer goes back to binary…
If we look at the below table, you will notice a distinctive pattern. And if we look closer you will see the first line is for Class A, if we were to change the first bit our number would now be 128, which is what line 2 for Class B is. So based on the below pattern we can see where the ‘funny numbers’ come from. The below table, shows us not only a pattern which was used to create the numbers for each class, but also shows us what the first bits MUST be in order to fall under each class. In other words, Classs A has to have a first bit of ‘0’, Class B has to have ’10’ in its first bits, Class C = ‘110’ Class D = ‘1110’ and Class E = ‘11110’
128 64 32 16 8 4 2 1
1 1 0
1 1 1 0
1 1 1 1 0
So in conclusion, if I had an IP address of 10.2.3.5 I would be able to tell that it’s a Class A address as the first octet is between 1-126, similarly if I had the IP address 172.16.2.3 if would be a class B since its first octet is between 128 – 191, and the IP address 192.168.1.2 would be a class C since its first octet is between 192-223.