In our last post, we explained about IP classes and we said every IP consists of Network ID and Host ID. Now let’s see how we can distinguish Network ID (the fixed octets) from Host ID (the variable octets).For this matter, we have to explain about subnet mask first.
Subnet mask:
In fact, Subnet mask is something to help us distinguish Network ID and Host ID in an IP. Like an IPv4, subnet mask is 32 bit in size. In another word it has 4 octets that each octet contains 8 bits. From left to right every bit can get the value of 0 or 1. All of the bits that have the value of 1, show the Network ID and all of the bits that have the value of 0 show our Host ID. This means that a subnet mask in binary is something like this:
11111111 00000000 00000000 00000000
Now if we want to show the exact subnet mask in decimal, It’ll be something like this:
255.0.0.0
As you might have understood from the example above, for every fixed octet of an IP, the octet is 255 in subnet mask.
Another example: 255.255.255.0
This subnet mask shows that this IP is a class C IP because the first three octets of our subnet mask are 255 that means they are fixed octets. In IP classes post we said that if the first three octets of an IP show our Network ID, that IP is class C.
We have to mention that all octets of a masks (in Decimal) that show us the Network ID aren’t always 255 in size. This only happens when all 8 bits of an octet are 1 in value. If the octets have less value than 255, it means that the whole octet is not our Network ID and we have to convert the decimal subnet mask to binary to figure it out. Look at the picture below for some examples:
The first column shows the number of bits that are 1 in value. So, /8 is class A, /16 class is B and /24 is Class C.