What is a subnet mask?

Answer

A subnet mask is a 32-bit number that divides an IP address into the network portion (identifying the network) and the host portion (identifying the individual device on that network). It uses 1s for network bits and 0s for host bits. Example: 255.255.255.0 (or /24) means the first 24 bits are the network address and the last 8 bits identify hosts — allowing 254 usable host addresses (2^8 - 2, excluding network and broadcast addresses). The network address is found by ANDing the IP with the subnet mask. CIDR notation: 192.168.1.0/24. Understanding subnet masks is fundamental to IP routing — routers use them to determine if a destination is on the local network or must be sent to a gateway.