Post

Understanding Network IPv4, Subnet masking, CIDR basics

Lets understand the structure of IPv4 address

IPv4 address looks something like this 192.23.9.0, this represents the decimal notation of IP address.
Each part of the address is binary octet (i.e. 8 values that can be either 0 or 1)

IPv4 is represented in 32 bit form hence 4 parts with 8 (octets) bits each and in binary form each part is represented as

11111111
1286432168421

So letโ€™s break down 192.23.0.9 based on the above mentioned logic:

PartOctet
1921 1 0 0 0 0 0 0
230 0 0 1 0 1 1 1
90 0 0 0 1 0 0 1
00 0 0 0 0 0 0 0

The above section is important to understand what subnet masking is.

Now, letโ€™s see how to identify the Network ID and Host ID from IP

Considering our example IP address, let us divide it into network ID and host ID like below:

Network IDHost ID
1922390


Now, how did we come to know what is the Network ID and Host ID, thatโ€™s where the subnet masking comes into picture, so if our subnet mask is:

2552552550

This means that first 3 parts of the IP address are all 1s in the octet and hence cant be changed and that is the network ID.
The last octect is 0 that means that's the host ID, i.e. each machine with in the network will have a different host ID.
So, this is /24 subnet mask as the first 3 octets are fixed and only the last octet can change.
This means our network and subnet mask can be written as 192.23.9.0/24 (This representation is also called the CIDR, Classless Interdomain Routing), that means there are going to be 0 to 255 host machines that can be part of the this network.
however, in general you dont have all 255 as host IDs, we get 254 host IDs, as the last part i.e. 255 is used as the boardcasting ID. So, we will have host addresses from 192.23.9.1 to 192.23.9.254

This post is licensed under CC BY 4.0 by the author.