A subnet mask is a crucial component of computer networks, as it is used to conserve IP addresses. The number of computers has exceeded the total possible IPv4 addresses, so we now use subnetting and subnet masks to handle this issue.
In this article, we will introduce the concepts of subnetting and subnet masks, explain their working and uses in tackling the issue of limited IPv4 address space. We have also covered the calculations related to the subnet mask and IP address.
Furthermore, if you are looking to get expert training on Subnetting and subnet masks, joining our Network Security training will help you understand the concept better.
Subnetting is the process of dividing a larger IP network into smaller segments called subnets. These subnets reduce the overall network congestion and enhance the efficiency and security of the network.
For example, Organizations use subnetting to create separate networks for different departments. By dividing the big company network into smaller networks for departments, companies optimize communication within a network, security, and broadcast resources.
Each subnet has its subnet mask and range of IP addresses, allowing devices within the subnet to communicate directly without routing through a gateway.
Subnetting is important for the following reasons:
● Subnetting helps divide a large network into smaller parts, preventing IP address wastage.
● Smaller subnets reduce broadcast traffic, leading to faster and more efficient communication.
● Devices in different subnets can be isolated, making it easier to control access and monitor traffic.
● Subnetting makes it easier to manage, troubleshoot, and maintain networks by organizing devices logically.
● Routers can handle smaller routing tables, improving speed and reducing complexity.
● Subnetting allows networks to grow in a structured and manageable way.
A subnet mask is a 32-bit number that divides an IP address into two parts: network address and host address. The network address determines the subnet to which the device belongs, and the host address determines the device.
Different subnet masks can be used in a network based on requirements. Here are some commonly used subnet masks:
Subnet Mask | Usable Hosts | Common Use |
---|---|---|
255.255.255.0 | 254 | Small to medium-sized LANs |
255.255.0.0 | 65,534 | Large enterprise networks |
255.0.0.0 | 16,777,214 | Very large networks (rarely used today) |
255.255.255.252 | 2 | Point-to-point links |
255.255.255.255 | 1 | Single host (loopback or specific device) |
IP addresses and subnet masks are usually written in a CIDR notation. CIDR stands for Classless Inter-Domain Routing, and it is a compact way to write IP addresses and their associated subnet mask. If you see an IP address written in the format:
192.168.1.0/24
This means that the first 24 bits are the network part. Since an IPv4 address and subnet mask are 32 bits, this means the remaining 8 bits are the host part.
The subnet mask is a 32-bit number, consisting of a series of 1s and 0s. The 1s represent the network part, and the 0s represent the host part. When a device needs to determine the network portion of an IP address, it performs a bitwise AND operation between the IP address and the subnet mask.
The image below shows how a subnet mask is used to split an IP address.
From the resulting address, you can determine that the network address is 192.168.1 and the host address is 0. Routers also use these network addresses to make routing decisions.
In this section, we have covered a simple process to find the subnet mask based on the IP address and number of hosts required.
Let's say you have an IP address of 192.168.1.10 and you want to create a subnet mask that allows for 30 hosts in your subnet.
First, determine the Number of Hosts Needed, which is 30 in this case.
Then we need to find the number of bits required to accommodate 30 hosts. So we'll use the formula:
number of hosts ≥ 2n-2 (Here, n is the number of bits for the host portion).
Filling in the values,
30≥ 2n -2
which gives us n=5.
Now we know, the 5 bits of the subnet mask will be used for the host address, and the remaining 27 bits will be used for the network address, as the subnet has 32 bits in total.
So, our subnet mask will be 11111111.11111111.11111111.11100000.
Now, converting it to decimal, the subnet mask will be 255.255.255.224.
Using the subnet mask on the given IP address, we will get the network address as: 192.168.1.0
The usable IP addresses for 30 hosts will in between 192.168.1.1 to 192.168.1.30
IP addresses are divided into 5 classes- A, B, C, D, and E. A, B, and C are commonly used, as classes D and E hold exception privileges. The first octet of the IP address determines its class. Each class of IP address is linked to its default subnet mask, shown below:
Class | Address Range | Default Subnet Mask | Number of Networks | Number of Hosts per Network |
---|---|---|---|---|
A | 1.0.0.0 to 126.255.255.255 | 255.0.0.0 or /8 | 126 | 16,777,214 |
B | 128.0.0.0 to 191.255.255.255 | 255.255.0.0 or /16 | 16,384 | 65,534 |
C | 192.0.0.0 to 223.255.255.255 | 255.255.255.0 or /24 | 2,097,152 | 254 |
Note:
● The number of usable networks and hosts for Classes A, B, and C excludes reserved addresses (network and broadcast).
● Class D is used for multicast, not for standard host addressing.
● Class E is reserved for experimental use and not for general assignment.
The subnet mask's purpose is to optimize the use of IP addresses in a network. Here are some benefits of using subnetting and subnet masks in a computer network:
1. By reducing broadcast traffic and network congestion, it helps networks operate more efficiently.
2. It increases security by isolating different parts of the network.
3. It allows for better management and maintenance of these diverse segments, ensuring seamless integration.
4. It enables organizations to allocate specific IP ranges for remote users, allowing them to access the network securely while maintaining control over their connectivity.
5. By dividing a large address space into subnets, organizations can make better use of their IP addresses, preventing wastage and ensuring that every device has a unique identifier.
● Subnetting can be complex to design and manage in very large networks.
● Managing multiple subnets requires additional administrative personnel.
● Incorrectly configured subnet masks can lead to network issues.
In conclusion, subnet masks are essential for efficient IP address management and network performance. They enable subnetting, which divides larger networks into smaller, manageable subnets, improving communication, security, and troubleshooting.
Understanding IP address classes and subnet mask calculations is crucial for effective network design. Despite their benefits, subnet masks come with limitations like complexity and potential misconfiguration. Balancing these factors is key to optimizing network performance and security.
Ravish Rathi is a currently working as a Senior Network Consultant with one of the world's largest Internet Service Provider. He started his career as network support engineer with HCL and since than he has been working on different roles with various organizations such as Accenture, IBM, HCL, HP etc. Now he is having more than 15 years of ...
More... | Author`s Bog | Book a Meeting