Subnet Mask Overview
A subnet mask is a 32-bit numerical value used in IPv4 networking to determine which part of an IP address identifies the network ID and which part identifies the host ID. This mask is configured on networking devices alongside the device's IPv4 address.
In the subnet mask, when a bit is set to 1, it designates that the corresponding bit in the IP address belongs to the network ID. Conversely, when a bit is set to 0 in the subnet mask, it designates that the corresponding bit in the IP address is part of the host ID.
As you can see in the image above, an IPv4 address is divided into network and host segments. In this example, the network portion aligns with the octet boundary, consistent with IPv4 address class distinctions. The address belongs to class B, where the first 16 bits represent the network ID, and the last 16 bits signify the host ID. Therefore, the subnet mask is created by setting the first 16 bits to binary 1 and the remaining 16 bits to 0.
The prefix "/16" is an alternative way of expressing the subnet mask, matching the number of network bits set to binary 1. Networks may have different prefixes based on the number of hosts they accommodate. A distinct prefix number alters the host range and broadcast address for each network, allowing for flexibility in network design.