The subnet mask divides an IP address into its network portion and host portion: the bits set to 1 in the mask mark the network part, the 0 bits mark the host part. This is what lets a device decide whether a destination is on its own local network or somewhere remote, it bitwise-ANDs both its own IP and the destination IP with the mask and compares the results; if the network parts match, the destination is on the same subnet and can be reached directly over the local link (resolving its MAC with ARP), and if they differ, the packet must be sent to the default gateway for routing onward. CIDR notation expresses the mask as the count of network bits, like /24 for 255.255.255.0, which yields 256 addresses (254 usable hosts, since the all-zeros host is the network address and all-ones is the broadcast). Getting the mask wrong breaks reachability in subtle ways, too-narrow and the device routes local traffic through the gateway, too-wide and it tries to ARP for hosts that aren't actually local and gets no reply. So the mask is fundamentally the local-vs-remote decision boundary, not just a number you copy.
Networking & IoT · Interview question
What does the subnet mask do?
A strong answer
What a weak answer sounds like
You know the answer. Do you know what gets you dinged?
Pro breaks down the answer most candidates actually give to this question — and the specific reason an interviewer marks it down. It’s the difference between sounding correct and sounding senior, on all 472 questions.
From the lesson
IP Addressing
How a packet finds a device: IPv4/IPv6 addresses split into network and host by the subnet mask, the same-subnet-vs-gateway decision, plus DHCP, NAT, and why IoT devices dial out.