Network masks

In the vast world of networking, the effective management and segmentation of networks are essential for optimal data transmission and security. Network masks, also known as subnet masks, play a pivotal role in dividing IP addresses into network and host portions. In this chapter, we will delve into the concept of network masks, explore their significance, and provide practical examples to deepen your understanding.

Understanding network masks

At its core, a network mask is a binary pattern that helps differentiate the network and host portions of an IP address. By combining an IP address with a network mask, network administrators can determine which part represents the network and which part represents the hosts within that network.

Network masks can be represented as octets, such as 255.255.255.0, or as the number of bits set to 1, such as 24. Both 172.16.32.32/255.255.255.0 and 172.16.32.32/24 represent the same IP and network.

Binary representation

Network masks are typically represented using the dotted decimal notation, making them easily readable. In this notation, a network mask consists of a series of 1s followed by a series of 0s. The consecutive 1s signify the network portion, while the subsequent 0s indicate the host portion. For instance, a network mask of 255.255.255.0 has 24 1s, representing a network size of 24 bits.

Applying network masks

To determine the network and host portions of an IP address, we perform a bitwise AND operation between the IP address and the network mask. The result of this operation yields the network portion. Let's consider an example to illustrate this process:

Example 1

IP address: 192.168.0.101 Network mask: 255.255.255.0

Performing the bitwise AND operation:

 IP address:      11000000.10101000.00000000.01100101
 Network mask: 11111111.11111111.11111111.00000000
 Network portion: 11000000.10101000.00000000.00000000

In this example, the network portion is 192.168.0.0, while the host portion is 0.0.0.101.

Example 2

IP address: 10.0.0.5 Network mask: 255.255.0.0

Performing the bitwise AND operation:

 IP address:      00001010.00000000.00000000.00000101
 Network mask: 11111111.11111111.00000000.00000000
 Network portion: 00001010.00000000.00000000.00000000

In this example, the network portion is 10.0.0.0, while the host portion is 0.0.0.5.

Network mask sizes

Network masks can have varying lengths, denoted by the number of consecutive 1s in their binary representation. Common network mask lengths include 8 bits (255.0.0.0), 16 bits (255.255.0.0), and 24 bits (255.255.255.0). Each length defines the size of the network and the number of available hosts.

Network segmentation

By employing network masks, network administrators can effectively segment networks. Devices with IP addresses within the same network segment, as defined by the network mask, can communicate directly without the need for routing through a gateway. Conversely, devices with IP addresses in different network segments require routing through a gateway to communicate.

Summary

Network masks are fundamental tools in networking that allow for efficient network segmentation and routing. By combining an IP address with a network mask, administrators can ascertain the network and host portions of an address.

Last updated