# How to obtain maximum number of subnets and hosts from a give IP address

Let’s assume that the given IP address is 172.20.0.0 and the mask is 255.255.255.224

Or simply 172.20.0.0/27 in CIDR notation

Steps to find out the number of hosts:

1. Find out the block and subtract it by 2. Why 2? Because in a given network address, 1 bit is always reserved for network and one for broadcast address.

Let’s find the block, take the last octet of the subnet mask (224) and subtract it from 256; 256-224=32. So 32 is the block or the range for this ip address. And if you subtract 2 from 32, you get 30. And that’s the number of host achievable from this network. Easy!

Now what about the subnet?

1. Let me show another way of finding both the subnets and hosts. Again it is very easy!

For this we need to convert the subnet mask into binary number and distinguish the two (subnet & host):

255.255.255.224

11111111.11111111.11111111.11100000

From this we come to know that all 0s are the bits reserved for host and all 1s are reserved for subnets.

Now we know that this particular ip address belongs to Class B that means, first two octets are reserved for network and remaining two are for subnets and hosts.

nnnnnnnn.nnnnnnnn.ssssssss.ssshhhhh

Therefore, subnet is 2^11= 2048 and host 2^5-2=30