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:
- Subnet Mask: Differentiates the network and host portions of an IP address, guiding proper routing of network traffic.
- Reduces Broadcast Domains: Limits broadcast traffic within each subnet, improving overall network performance.
- Enhanced Security: Isolates subnet traffic, reducing exposure to unauthorized access or potential threats.
- Efficient IP Address Allocation: Prevents IP wastage by allocating addresses according to subnet size and need.
- Better Traffic Management: Allows control over traffic flow and departmental segmentation.
- Improved Network Efficiency: Optimizes routing and performance through organized and structured subnetting.
Practical Application:
- Adjusting the Subnet Mask: For example, changing from 255.255.255.0 to 255.255.255.192 allows administrators to create smaller, more manageable networks.
- Host Capacity Calculation: Uses formulas like 2(32-n)−2 to calculate the number of usable hosts per subnet, where n represents the number of bits designated for the network and subnet parts.
| 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:
- Usable hosts per subnet =
2^(32−n) − 2, wheren= number of bits in the subnet mask.- For
/31or/32subnets, adjustments are needed since the standard-2formula does not apply.
Explanation:
- Subnet Mask: This is the mask used to determine what portion of an IP address refers to the network and what part refers to the host.
- Subnet Notation: This is the CIDR (Classless Inter-Domain Routing) notation that also indicates the subnet mask.
- Total Subnets: The number of distinct networks that can be created with the given subnet mask.
- Usable Hosts per Subnet: The number of devices that can be assigned IP addresses within each subnet, excluding the network and broadcast addresses.
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:
- 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.
- 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:
- Subnet Mask: 255.255.255.128 or /25
- CIDR Notation: /25 indicates that 25 bits are used for the network part.
Calculating Usable Hosts:
- Total bits for IPv4 = 32
- Network bits = 25
- Host bits h = 32 - 25 = 7
- Usable Hosts = 27−2 = 126
Calculating Total Subnets: Assuming we are subnetting within a larger block (e.g., a /24 block):
- Bits borrowed for subnetting s = 25 - 24 (original block) = 1
- Total Subnets = 21 = 2
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:
- /26 Subnet Mask:
- Network bits = 26, Host bits h = 6
- Usable Hosts = 26−2 = 62
- Assuming subnetting within a /24, s = 2, Total Subnets = 22 = 4
- /27 Subnet Mask:
- Network bits = 27, Host bits h = 5
- Usable Hosts = 25−2 = 30
- Assuming subnetting within a /24, s = 3, Total Subnets = 23 = 8
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:
- Understand IP Address and Subnet Mask: Every device on a network has an IP address and a corresponding subnet mask. The subnet mask helps in identifying how the IP address is divided into network and host parts.
- Binary Conversion: Convert both the IP address and the subnet mask into binary. An IP address is composed of four octets (e.g., 192.168.1.15), as is the subnet mask (e.g., 255.255.255.0).
- Perform a Binary AND Operation: Perform a bitwise AND operation between the binary form of the IP address and the subnet mask. This operation compares corresponding bits of the IP address and the subnet mask and applies the logical AND operation, which results in the network portion.
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.
- Convert Back to Decimal: Convert the result of the AND operation back to decimal format to get the network address. This is the part of the IP address that identifies the network to which the device is connected.
- Verification: You can use various network tools or command-line utilities like
ipconfig(on Windows) orifconfig(on Unix/Linux) to display the IP address, subnet mask, and network address for verification.
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 228
Class E is reserved for experimental and research / military purposes, possible IP addresses in class E is 228]
In simple words, the Number of hosts in any network can be calculated with the formula = 2x- 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 224- 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 28- 2= 254
The broadcast IP address is 201.20.30.255