Check the number of hosts that is in a subnet on CIDR
Result
To calculate the number of hosts that are in a given subnet you can use the formula 2^h-2, The variable h is based on the number of host bits of an IP address. Negative two represents the network address and broadcast address in the network which would be unusable for the hosts. Therefore two addresses are always removed. For example /28 would have 28 network bits and four host bits. The formula would be 2^4-2 which would result in 14 hosts per subnet.
Fig.1 The formula to calculate the number of hosts in a subnet.
Private IP addresses are allocated in private networks, These networks usually are Local Area Networks (LANs). In IPv4 there are three private IP address spaces. A device that does not require connection with the outside internet, the device can be assigned a private address. With a private IP address enables a device to communicate only with other devices on the same private network. Each device within the private network will have a unique IP assigned. The router will also be assigned a private IP address in order to communicate with the devices on the private network. The router would usually be assigned the first usable address (192.168.1.1) after the network identifier(192.168.0.0). Other external networks on the internet can avail of the same private addressing space for their internal networks. The private address of a device is not exposed to the internet. The private address block spaces are:
The number of hosts in a subnet would depend on the Classless Interdomain Routing (CIDR) and the class range of the IP address. Class A networks or anything greater than a /8 CIDR, would have the largest number of hosts ranging in the millions. Class B networks or greater than /16 CIDR would have thousands of hosts. In a class C subnet any CIDR greater than /24 would be a couple of hundred.
| CIDR | Number of hosts (Available) | |------|------------------------------| | /30 | 2 | | /29 | 6 | | /28 | 14 | | /27 | 30 | | /26 | 62 | | /25 | 126 | | /24 | 254 |
| CIDR | Number of hosts (Available) | |------|------------------------------| | /23 | 510 | | /22 | 1,022 | | /21 | 2,046 | | /20 | 4,094 | | /19 | 8,190 | | /18 | 16,382 | | /17 | 32,766 | | /16 | 65,534 |
| CIDR | Number of hosts (Available) | | ------ | ------------------------------ | | /15 | 131,070 | | /14 | 262,142 | | /13 | 524,286 | | /12 | 1,048,574 | | /11 | 2,097,150 | | /10 | 4,194,302 | | /9 | 8,388,606 | | /8 | 16,777,214 |