Risk Free Quote

OpenclarITy has a team of dedicated consultants who can provide customized IT solutions that assist you in meeting your business needs.


CIDR Value Conversion to Subnet Mask

Continuing on from our last blog post about subnetting, this one will cover converting a given CIDR (Classess Internet Domain Routing) value into its respective Subnet Mask. Then given that Subnet Mask plot out the subnet range, number of hosts, etc..

Now you may be thinking that you cannot possibly have to remember the whole CIDR table for dealing with questions like this and you’re right. There is a simple and easy way to covert a given CIDR value to its respective subnet mask, you simply take the CIDR value and plot it out in binary 1’s. This means we will have 4 octets of 8 bits per octet that are either 1’s or 0’s. To plot out the CIDR value, you take the given value and write it out in 1’s from left to right with a period to separate your octets, so let’s say we have a CIDR value of /29 written out in binary it would look like:


Notice how there are twenty-nine 1’s from left to right, then the remaining 3 bits are filled with 0’s (remember this is because we have to have 4 octets of 8 bits per octet).

Now let’s take that binary value and convert it to decimal form (this will be our subnet mask):

11111111.11111111.11111111.11111000 =

If you are un-familiar with binary to decimal conversion it’s easiest to remember that from the 1st bit to the 8th bit in the octet we simply do ‘X’ to the power of 2, starting with 1. So the decimal values of each bit would be:

128, 64, 32, 16, 8, 4, 2, 1

So if our first octet is 11111111 then the decimal value would be 255 (128+64+32+16+8+4+2+1=255).

So now that you have the CIDR value converted to a subnet mask in decimal form you can easily extract the number of hosts per subnet:

256-248 = 8

The formula above is a little cheat formula (256-subnet mask) which shows us our beginning addresses using the mask in question. In this case:

256-248 = 8 (note that you only use the “non 255 or 0” number in this formula. The position of the 248 in this case also shows us the octet to work in. In this case the fourth octet).

Then remember we need to take away 2 hosts from the 8 due to the network mask and broadcast address. This leaves us with a total of 6 usable hosts per subnet. Basic subnet separation can be done from here on… = first subnet = second subnet = third subnet = fourth subnet
… and so on …