Course contentsShow
← Computer Science
Lesson 1463 of 2,87234. Internet Protocol SuiteFree lesson

Subnet Masks and Network/Host Portions

Understanding how subnet masks divide IP addresses into network and host portions for routing decisions.

Subnet Masks and Network/Host Portions

You'll learn how subnet masks split an IP address into its network and host parts, enabling routers to route packets efficiently.

What Is a Subnet Mask?

A subnet mask is a 32-bit number that divides an IPv4 address into two components: the network portion (which identifies the network itself) and the host portion (which identifies individual devices on that network). Think of it like a postal address: the network portion is the street name, and the host portion is the house number.

How It Works

Subnet masks use consecutive 1 bits to mark the network portion and consecutive 0 bits to mark the host portion. When written in dotted-decimal notation, common masks look like:

  • 255.255.255.0 → binary: 11111111.11111111.11111111.00000000 (24 network bits, 8 host bits)
  • 255.255.0.0 → binary: 11111111.11111111.00000000.00000000 (16 network bits, 16 host bits)

Applying the Mask

Routers perform a bitwise AND operation between an IP address and its subnet mask to extract the network address:

  • IP: 192.168.10.75 → 11000000.10101000.00001010.01001011
  • Mask: 255.255.255.0 → 11111111.11111111.11111111.00000000
  • Network: 192.168.10.0 (the 1 bits preserve the network part)
  • Host: .75 (the 0 bits allow 256 possible hosts, from .0 to .255)

This tells the router: "All addresses from 192.168.10.0 to 192.168.10.255 belong to the same local network."

Why It Matters

Subnet masks enable routers to make routing decisions quickly—packets destined for the same network don't need to be routed externally, while others are forwarded to the appropriate gateway.

Key Takeaway: Subnet masks use binary masking to divide IP addresses into network and host portions, allowing routers to determine which devices share a local network and how to route traffic accordingly.