Have you ever needed to know how an IP Address works? Have perhaps just wondered how they worked? Well in my line of work it has eventually become necessary for me to fully understand exactly how IP addresses work and are made up. Therefore I aim to share my knowledge on such with anyone who cares to read about IP addresses here on my wonderful blog.
First of all it’s important to know that IP addresses are displayed in what is known as dotted-decimal format. For example your current IP address is
For anyone Interested, I got your IP address using the following PHP code:
$ipaddress2 = $_SERVER[REMOTE_ADDR];
echo “<h3>Your Current IP Address: $ipaddress2</h3>”;
Just notice the format of the IP address above for now though.
Two Main Parts of an IP Address
While an IP address appears to have 4 parts due to the dotted-decimal format used, in reality, IP addresses are made up of only two main parts. They are “Network ID” and “Host ID”. The two parts are not equal or consistent. The Network ID is defined first and the Host ID will be the remaining portion of the IP address.
IP Address Classes
IP addresses are divided into different classes. There are actually five IP classes, but only three are in common use, they are Classes A,B, and C. Classes D and E are reserved classes. Class D is Reserved for Multicasting. Class E is Experimental; used for research. The three main classes are shown in the following examples:
- Class A – Class A IP addresses use 8 bits for the Network ID(8 bits = 1 byte or 1 segment in dotted-decimal format or 1 octet). Class A addresses only include IP addresses from 1.x.x.x to 126.x.x.x. The IP range 127.x.x.x is reserved for loopback IP addresses. Therefore a Class A IP address might look like 22.214.171.124. From what we know about the two parts of an IP address now, we know that the “19.” portion of this example IP address defines the Network ID and the remaining part(23.20.100) represents the Host ID.
- Class B – Class B IP addresses use 16 bits for the Network ID(16 bits = 2 bytes or 2 segments in dotted-decimal format or 2 octets). The remaining 16 bits are used for the Host ID of course.
- Class C – Class C IP addresses use 24 bits for the Network ID(24 bits = 3 bytes or 3 segments in dotted-decimal format or 3 octets). The remaining 8 bits are used for the Host ID in this case.
How to Determine IP Address Class
Determining whether an IP address belongs to class A, B or C can be a daunting task if you don’t understand how IP addresses function. That is why I will explain it clearly here for you! First you need to realize that IP classes are determined by the first few bits of the IP address. Then you need to know that bits are not the same as the dotted-decimal format you are accustomed to! For example My IP address now shows as 126.96.36.199 if I open this post in my current browser. What class does 188.8.131.52 belong to? Well here is how I found out:
First, convert the dotted-decimal formatted IP address of 184.108.40.206 to its binary form and count the bits. Actually, you can do just the first octet or 173 in this case. Here is how to convert a decimal octet to a binary Byte:
You divide the number(173 in this case) by 2 and take the answer with the remainder and note both. Then divide the answer by two and note the answer and remainder again….do this eight times. Start at the top of a sheet of paper and move to a new line each time you start a new calculation. Be sure to circle the remainder each time as those are the 8 bits that make up the Byte we are after. Here is my sloppy example of how I did it with my IP address that began with 173:
Notice that I circled the remainder after each division problem above. The final step is to start at the bottom and write each circled remainder down in order.
So from the image above, I get the binary number: 10101101
The first three bits of the binary 10101101 determine it’s class. In my case, the first three bits are 101.
Then refer to the following table to determine your class:
- CLASS A: the binary will begin with a zero.
- CLASS B: the binary must start with 10.
- CLASS C: the binary must start with 110.
So as you can see from the above table and the image above that, my IP address of 220.127.116.11 converts to a binary number of 10101101 and can then be identified as a CLASS B IP address because its binary form begins with 10. Alot to do to figure out the class of an IP, but it is mostly for learning purposes that I have explained it all like I have. Really, all you have to do is refer to the following table of information which will allow you to convert it to a class using just the first octet of the IP address(173 in my case):
Quick & Easy Method to Determine IP Class
- CLASS A: First 3 digits of the IP address will be from 0 to 127.
- CLASS B: First 3 digits of the IP address will be from 128 to 191.
- CLASS C: First 3 digits of the IP address will be from 192 to 223.
So again, my IP(18.104.22.168) starts with 173 so I can use the above three lines of data to confirm that it is indeed a CLASS C IP address because 173 falls in between 128 and 191.