What is a subnet mask and how does it work?
A subnet mask is a 32-bit number that divides an IP address into a network portion and a host portion. It uses consecutive 1-bits for the network part and 0-bits for the host part. For example, 255.255.255.0 (/24) means the first 24 bits identify the network and the last 8 bits identify hosts, allowing 254 usable addresses. The subnet mask is applied using a bitwise AND operation with the IP address to determine the network address.