Skip to content

What is a subnet, and what does a subnet mask do?

Short answer

A subnet is a logical subdivision of an IP network. The subnet mask marks which bits of an IP address are the network portion and which are the host portion — for example, /24 (255.255.255.0) means the first 24 bits identify the network and the last 8 identify hosts. Subnetting controls how traffic is routed and lets you segment a network into smaller broadcast domains.

Subnetting is how a large IP address space is carved into manageable, routable pieces. The subnet mask is the tool that does the carving, and understanding it is foundational to routing and to network segmentation as a security control.

Network bits vs host bits

An IPv4 address is 32 bits. The subnet mask is a second 32-bit value where the leading 1s mark the network portion and the trailing 0s mark the host portion. For 192.168.1.0/24, the mask is 255.255.255.0 — the first 24 bits (192.168.1) identify the network, and the last 8 bits identify individual hosts within it. The /24 is CIDR notation, just shorthand for "24 network bits."

What the mask is used for

When a host wants to send a packet, it ANDs the destination IP with its own mask. If the result matches its own network, the destination is local and it delivers directly via ARP/MAC. If not, the packet is remote and goes to the default gateway. So the mask literally decides "talk directly or hand to the router."

Host counts

A /24 has 8 host bits = 256 addresses, but two are reserved: the network address (all host bits 0) and the broadcast address (all host bits 1), leaving 254 usable hosts.

Why it matters for security

Smaller subnets create smaller broadcast domains and natural boundaries you can put access controls on. Segmenting servers, user workstations, and IoT devices into separate subnets limits lateral movement — an attacker who lands in one subnet can't freely reach another if a firewall sits between them.

Interviewers want the network/host split, what /24 means, the local-vs-gateway decision, and ideally the segmentation security benefit.

Likely follow-ups

  • How many usable hosts are in a /24, and why isn't it 256?
  • How does a host decide whether a destination is local or needs the gateway?
  • What is the security benefit of breaking a flat network into subnets?

Sources

Certifications

Get 100 cybersecurity interview questions + answers

Drop your email and we'll send you the free PDF pack and the flashcard deck.

No spam. Unsubscribe anytime.