How IP Addresses Work
Understanding Subnets and Subnet Masks
A subnet mask answers one question: which part of an IP address identifies the network, and which part identifies the device on it?
Why split a network?
Large flat networks are inefficient and hard to secure. Subnetting divides one network into smaller sub-networks, which keeps local traffic local, improves performance, and lets administrators apply different rules to different segments.
What a subnet mask does
Every IPv4 address is paired with a subnet mask, such as 255.255.255.0. The mask marks which bits of the address belong to the network and which belong to the host. Where the mask has a 1, that bit is part of the network; where it has a 0, that bit identifies the specific device.
With 255.255.255.0, the first three octets are the network and the last octet is the host. So 192.168.1.7 and 192.168.1.42 are on the same network (they share 192.168.1), while 192.168.2.7 is on a different one.
Reading it as a slash
The mask 255.255.255.0 has 24 leading 1-bits, so it is commonly written as /24. This is CIDR notation: 192.168.1.0/24 means "the network whose first 24 bits are fixed," which contains 256 addresses (254 usable for devices).
Why some addresses are reserved
In each subnet, two addresses are set aside: the first identifies the network itself, and the last is the broadcast address used to reach every device on the subnet at once. That is why a /24 holds 256 addresses but only 254 are assignable to devices.
The practical upshot
You rarely calculate subnets by hand at home — your router handles it. But understanding masks explains why two devices can or cannot talk directly, why some addresses are "unusable," and how bigger organizations carve their address space into manageable, secure pieces.