CIDR Notation – Understanding CIDR and Subnets

ipip addressipv4subnet

I've been given a script that will create a virtual network with the following IP range (in Azure): 10.0.0.0/16.

The script then goes on to create two subnets within that network with the following IP ranges: 10.0.5.0/24 and 10.0.6.0/24. My understanding is that this means the virtual network can address 2^16 host, while the subnets on the virtual network can address 2^24 hosts(?!). How can the subnets have a larger range than the network they reside on?

Best Answer

No. The number of bits in the CIDR notation is for how many network bits are in an address, not how many host bits are in an address. An IPv4 address is 32 bits, so you subtract the number of network bits from 32 to get the number of host bits:

10.0.0.0/16 = 32 - 16 = 16 host bits = 2^16 host addresses
10.0.5.0/24 = 32 - 24 =  8 host bits = 2^8  host addresses

Also, with IPv4 you must subtract two from the number of host addresses* to arrive at the possible number of hosts on a network because you cannot use the network and broadcast addresses for host addresses.


*except for /31 and /32 networks


See the excellent answer to this question for how subnetting works.

Related Topic