What is a subnet mask?
A subnet mask is a 32-bit number that separates an IP address into its network and host portions. It does the same job as CIDR's prefix-length notation but written in the more verbose dotted-decimal form.
Examples:
/24CIDR ≡255.255.255.0subnet mask — first 24 bits network, last 8 bits host/16CIDR ≡255.255.0.0— first 16 bits network/8CIDR ≡255.0.0.0— first 8 bits network (entire Class A)
Usage: when a device wants to send a packet, it ANDs its own IP with its subnet mask to find its network address, then ANDs the destination IP the same way. If the two networks match, the destination is local (send directly); otherwise route via the default gateway.
Modern tools default to CIDR notation (/24) instead of subnet masks (255.255.255.0), but both describe the same thing.