How to Calculate Number of Host in a Subnet? (original) (raw)

Last Updated : 2 Jan, 2026

Subnetting is a crucial process in network design that involves dividing a larger network into smaller, manageable subnetworks. Determining the number of hosts that each subnet can accommodate is crucial for efficient IP address allocation, preventing waste, and optimizing overall network performance. Proper subnet planning also improves security by isolating network segments and controlling traffic flow.

Subnetting and IP Addresses

Subnetting and IP addressing are fundamental components of network design, essential for efficient network management, performance optimization, and security. An IP address is a unique identifier assigned to each device on a network, allowing it to communicate with other devices. IPv4 addresses consist of 32 bits divided into four octets, while IPv6 addresses use 128 bits, providing a much larger address space. Subnetting divides a larger network into smaller, manageable segments called subnets, helping organize network traffic and optimize IP address usage.

**Key Benefits of Subnetting:

**Practical Application:

Subnet Mask CIDR Notation Total Subnets Usable Hosts per Subnet
255.255.255.0 /24 1 254
255.255.255.128 /25 2 126
255.255.255.192 /26 4 62
255.255.255.224 /27 8 30
255.255.255.240 /28 16 14
255.255.255.248 /29 32 6
255.255.255.252 /30 64 2

**Notes:

**Explanation:

We use fundamental networking formulas that are based on the number of bits allocated for network and host parts in the subnet mask. Here’s a breakdown of the calculations:

Basic Formulas:

  1. **Number of Usable Hosts: Usable Hosts = 2h - 2, Where h is the number of bits used for hosts in the subnet mask. The subtraction of 2 accounts for the network address and the broadcast address, which cannot be assigned to hosts.
  2. **Number of Subnets: Total Subnets = 2s Where s is the number of bits borrowed from the original host part to create more network bits in subnetting.

Example Calculation for a /25 Subnet Mask:

**Calculating Usable Hosts:

**Calculating Total Subnets: Assuming we are subnetting within a larger block (e.g., a /24 block):

Applying the Formulas to Different Masks:

The same process applies to other subnet masks, adjusting the number of host bits (h) and the number of borrowed bits (s) accordingly:

These calculations are essential for network engineers and administrators to efficiently plan and allocate IP addresses within a network, ensuring optimal utilization and avoiding address exhaustion.

Steps to Find the Number of Computers Connected in the Given IP Address

1) Identify the Class of the IP address

To find the number of computers connected in the network first we need to identify the class of the IP address, there are 5 classes of IP addresses they are A, B, C, D, and E.
Each IPv4 address consists of 32 bits, divided into 4 octets, 1 octet = 8 bits. Look at the first octet to find the class of the given IP address. The range of each class is given in the following table.

**IP Class **First Octet Range **Address Range **Description
Class A 1 – 126 1.0.0.0 – 126.255.255.255 Designed for very large networks
Class B 128 – 191 128.0.0.0 – 191.255.255.255 Suitable for medium-sized networks
Class C 192 – 223 192.0.0.0 – 223.255.255.255 Used for small networks
Class D 224 – 239 224.0.0.0 – 239.255.255.255 Reserved for multicast groups
Class E 240 – 255 240.0.0.0 – 255.255.255.255 Reserved for experimental use

**Example: If the IP address given is 64.19.23.0 then the first octet is 64 which is in the range of 0 to 127, so the given IP address belongs to **class A.

**2) Finding the Network IP address

Finding the network IP address involves determining the portion of an IP address that identifies the specific network to which a device belongs. This can be accomplished by using the subnet mask along with the device's IP address. Here's how you can find the network IP address:

**For example: If the IP address is 192.168.1.10 (11000000.10101000.00000001.00001010 **in binary) and the subnet mask is 255.255.255.0 (11111111.11111111.11111111.00000000 **in binary)

Then result of the AND operation would be 11000000.10101000.00000001.00000000, which corresponds to **192.168.1.0.

**3) Finding the number of hosts or number of computers connected to that network

The class it belongs will tell the range of hosts that can connect to that network, it's given in the below table.

Classes Number of networks possible Number of hosts possible in 1 network Number of usable hosts in 1 network
A 126 224 224 - 2
B 16384 65536 65534
C 221 256 254
D no networks no hosts -
E no networks no hosts -

****[Note:** Class D is reserved for_ _Multicasting, group email/ broadcast, possible IP address in class D are 2_ 28

_Class E is reserved for experimental and research / military purposes, possible IP addresses in class E is 2 28**]

In simple words, the Number of hosts in any network can be calculated with the formula = **2 x - 2, where x is the number of host ID bits in the IP address.

**Why do we subtract 2?

Becausethe first and last addresses are not used for any hosts because the first IP is used to **represent the whole network ID while the last IP is used as the **broadcast address.

**Example: The given IP address is 192.168.254.1 it belongs to class C, when we perform **AND operation on IP address with a default mask of class C, we get the network IP address as 192.168.254.0 this is the IP address used to represent the whole network and the broadcast address will be the last IP address of this network which is 192.168.254.255

Example 1: Find the Class, network IP address, number of hosts (computers), and broadcast address of 9.1.5.31

Answer: **Finding the Class to which the given IP address belongs to
The first octet has a value of 9 which is in the range of 0 to 127 so the given IP address belongs to **Class A.

**Finding the Network IP address
The default mask for class A as given in the table is 255.0.0.0

Perform the **AND operation to get the network IP address
9.1.5.31 => 00001001.00000001.00000101.00011111
255.0.0.0 =>

11111111.00000000.00000000.00000000

00001001.00000000.00000000.00000000 => 9.0.0.0

IP address = 9.1.5.31, Network address= 9.0.0.0
So, Network ID bits= 8 (first octet), Host ID bits = 24 (Last three octets)

The network IP address of the given IP address is **9.0.0.0
The number of hosts in each network is 2 24 - 2
The broadcast IP address is **9.255.255.255

Example 2: Find the Class, network IP address, number of hosts (computers), and broadcast address of 201.20.30.40

Answer: **Finding the Class to which the given IP address belongs to
The first octet has a value of 201 which is in the range of 192 to 223 so the given IP address belongs to **Class C.
Finding the Network IP address
The default mask for class C as given in the table is 255.255.255.0

Perform the **AND operation to get the network IP address
201.20.30.40 => 11001001.00010100.00011110.00101000
255.255.255.0 =>

11111111.11111111.11111111.00000000

11001001.00010100.00011110.00000000 => 201.20.30.0
IP address = 201.20.30.40, Network address= 201.20.30.0
So, Network ID bits= 24 (first three octets), Host ID bits= 8 (Last octet)

The network IP address of the given IP address is **201.20.30.0
**The number of hosts in each network is 2 8 - 2= 254
The broadcast IP address is 201.20.30.255