Understanding Subnet Masks in Networking: A Comprehensive Guide
Written on
Chapter 1: Introduction to Subnet Masks
The network settings of a device often display both IP addresses and subnet masks. But what exactly is a subnet mask? To grasp this concept, it’s essential to first understand how IP addresses are structured.
An IP address can be categorized into two versions: IPv4 and IPv6. IPv4 consists of 32 bits while IPv6 comprises 128 bits. For instance, the address 192.168.0.1 is an example of IPv4.
IP Address Structure
IPv4 addresses are typically formatted as four decimal numbers separated by periods. These numbers represent 8-bit units, referred to as octets. The breakdown is as follows:
192.168.0.1 in binary:
11000000 . 10101000 . 00000000 . 00000001
Each octet represents 8 bits, totaling 32 bits (or 4 bytes) for an IPv4 address. The decimal values for each octet range from 0 to 255, since 11111111 in binary equals 255 in decimal.
Network and Host Addresses
An IP address is split into two segments: the network address and the host address. The network address identifies a collection of devices on the same local network, while the host address distinguishes individual devices within that network. However, there is no strict boundary separating these two components in an IP address.
To clarify this distinction, various classes of IP addresses were established, denoted as Class A, B, C, D, and E. Each class serves different purposes and is allocated a specific number of IP addresses.
- Class A: Approximately 16 million addresses
- Class B: Approximately 65,000 addresses
- Class C: Approximately 250 addresses
The criteria for identifying network and host addresses differ by class:
- Class A: network.host.host.host
- Class B: network.network.host.host
- Class C: network.network.network.host
To determine which class an address belongs to, examine the first octet:
- Class A: 1-127
- Class B: 128-191
- Class C: 192-223
- Class D: 224-239
For instance, the address 192.168.0.1 falls into Class C.
Current practices have moved beyond class-based segmentation. Instead, a more precise method divides networks into 1-bit segments based on specific requirements, leading to the adoption of Classless Inter-Domain Routing (CIDR).
Classless Addressing and Subnet Masks
In classful addressing, one can identify network and host addresses by examining the leading bits. However, in classless addressing, a delimiter is required, known as a subnet mask. This mask indicates which parts of the IP address represent the network (1s) and which represent the host (0s).
Here are the basic subnet masks for each class:
- Class A:
255.0.0.0
11111111.00000000.00000000.00000000
- Class B:
255.255.0.0
11111111.11111111.00000000.00000000
- Class C:
255.255.255.0
11111111.11111111.11111111.00000000
For example, if the subnet mask for the IP address 102.4.31.57 is 255.255.255.0, the network address would be 102.4.31.0, while the host address is represented by 0.0.0.57.
Conclusion
In summary, a subnet mask serves as a crucial tool for distinguishing between network and host addresses in a classless IP addressing scheme.
This video titled "Subnet Mask - Explained" provides a clear explanation of how subnet masks function within networking.
The second video, "What is a Subnet Mask?", offers further insights into the concept and application of subnet masks in network configuration.