Javith

Subnet Masks: How Networks Divide and Conquer

6 minutes (1612 words)
Subnet mask fundamentals with visual diagrams

When I first encountered subnet masks, they looked like random numbers: 255.255.255.0. I had no idea why they existed or what those 255s meant.

Here’s the truth: without understanding subnet masks, you can’t properly:

Subnet masks are the invisible boundary markers that determine which devices are on the same network and which need a router to communicate. Master this, and networking suddenly makes sense.

What Problem Does This Solve?🔗

Imagine you’re managing a massive apartment complex with 10,000 units. You could treat it as one giant building, but that would be chaos. Instead, you divide it into smaller buildings (A, B, C…), with floors, and apartments on each floor.

This hierarchy makes management possible:

Early computer networks faced the exact same problem. If you gave someone a Class A network (16 million addresses), they’d have a nightmare:

Subnetting solves this by dividing large networks into smaller, manageable sub-networks. And subnet masks are the tool that defines these boundaries.

Core Concept: Subnet Masks as Network Boundaries🔗

Think of a subnet mask as a stencil laid over an IP address. It reveals which part is the network and which part is the host.

Okay lets use this analogy: if an IP address is a full street address, the subnet mask is the highlighter that shows you which part is the city (network) and which part is the house number (host).

A typical subnet mask looks like: 255.255.255.0

Applied to an IP address like 192.168.1.100, it tells us:

Subnet-Representation

Plain English: The subnet mask defines where the network ends and individual device addressing begins.

The Binary Truth: How Masks Actually Work🔗

Here’s where subnet masks finally make sense. Remember, computers see everything in binary.

Let’s break down 255.255.255.0:

Decimal:  255      .  255      .  255      .  0
Binary:   11111111 .  11111111 .  11111111 .  00000000

See the pattern? Where the mask has 1s, that’s the network portion. Where it has 0s, that’s the host portion.

Now let’s apply this mask to an IP address:

IP Address:     192.168.1.100
Binary IP:      11000000.10101000.00000001.01100100

Subnet Mask:    255.255.255.0
Binary Mask:    11111111.11111111.11111111.00000000
                ↓         ↓         ↓         ↓
                Network   Network   Network   Host

The router uses a binary AND operation:

IP:             11000000.10101000.00000001.01100100
Mask:           11111111.11111111.11111111.00000000
----------------------------------------------------- AND
Network ID:     11000000.10101000.00000001.00000000
                = 192.168.1.0

The network ID is 192.168.1.0 - this identifies the network itself.

Subnet-Operation

Common Subnet Masks and What They Mean🔗

Let’s look at the most common masks you’ll encounter:

255.255.255.0 (/24)🔗

Binary:    11111111.11111111.11111111.00000000
Network:   First 3 octets (24 bits)
Hosts:     Last octet (8 bits) = 2^8 - 2 = 254 usable addresses

Why -2? Two addresses are reserved:

This is the most common home/small office network size.

255.255.255.128 (/25)🔗

Binary:    11111111.11111111.11111111.10000000
Network:   First 25 bits
Hosts:     Last 7 bits = 2^7 - 2 = 126 usable addresses

This splits a /24 network into two /25 networks:

255.255.0.0 (/16)🔗

Binary:    11111111.11111111.00000000.00000000
Network:   First 2 octets (16 bits)
Hosts:     Last 2 octets (16 bits) = 2^16 - 2 = 65,534 usable addresses

This is what Class B networks used by default. Large organizations use this for big campus networks.

255.0.0.0 (/8)🔗

Binary:    11111111.00000000.00000000.00000000
Network:   First octet (8 bits)
Hosts:     Last 3 octets (24 bits) = 2^24 - 2 = 16,777,214 usable addresses

This is what Class A networks used. Only massive organizations have these.

CIDR Notation: The Modern Way🔗

Instead of writing 255.255.255.0, network engineers use CIDR (Classless Inter-Domain Routing) notation:

192.168.1.0/24

The /24 means “the first 24 bits are the network portion.”

CIDR-CALC

Here’s a quick reference:

CIDRSubnet MaskUsable HostsCommon Use
/32255.255.255.2551Single host
/30255.255.255.2522Point-to-point links
/29255.255.255.2486Very small network
/28255.255.255.24014Small office
/27255.255.255.22430Department
/26255.255.255.19262Small business
/25255.255.255.128126Half of /24
/24255.255.255.0254Standard network
/23255.255.254.0510Two /24s
/22255.255.252.01,022Four /24s
/21255.255.248.02,046Eight /24s
/20255.255.240.04,094Sixteen /24s
/16255.255.0.065,534Large network
/8255.0.0.016,777,214Huge network

Why Subnetting Exists: The Real-World Benefits🔗

1. Reduce Broadcast Traffic🔗

Without subnetting, every broadcast (like ARP requests) floods the entire network. In a network with 10,000 devices, that’s chaos.

With subnetting, broadcasts only reach devices in the same subnet.

2. Security Segmentation🔗

You can isolate different parts of your network:

Firewall rules between subnets control traffic flow.

3. Efficient Address Allocation🔗

Instead of wasting a Class B (65,000 addresses) on a department with 50 people, you give them a /26 (62 addresses).

4. Organizational Clarity🔗

Subnet-Org

Calculating Subnet Boundaries🔗

Let’s say you have 192.168.10.45/28. How do you find:

Step 1: Convert /28 to a subnet mask🔗

/28 means 28 network bits:

11111111.11111111.11111111.11110000 = 255.255.255.240

Step 2: Identify the “interesting octet”🔗

The last octet (240) is where the magic happens. The others are all 255 (or 0).

Step 3: Find the block size🔗

256 - 240 = 16

So networks increment in blocks of 16:

Step 4: Determine addresses🔗

For 192.168.10.32/28:

VLSM: Variable Length Subnet Masking🔗

Modern networks use VLSM - different subnet masks for different needs.

Imagine you need:

Instead of giving everyone a /24 (254 hosts), you use:

This conserves IP space and improves efficiency.

Common Misconceptions🔗

“All devices on a network must have the same IP structure”🔗

Not true. They need the same network portion, but the host portion differs. In 192.168.1.0/24, devices can be 192.168.1.1, 192.168.1.45, 192.168.1.200, etc.

“255.255.255.0 is the only valid mask”🔗

Wrong. Any bit pattern where 1s are contiguous from the left is valid: 11111111.11111111.11111000.00000000 (/21) works fine.

Try This Yourself🔗

Find your network information:

On Linux/macOS:

ip addr show
# or
ifconfig

# Look for something like:
# inet 192.168.1.100/24

On Windows:

ipconfig

# Look for:
# IPv4 Address: 192.168.1.100
# Subnet Mask: 255.255.255.0

Calculate your network: If you have 192.168.1.100/24:

Test connectivity within your subnet:

# Ping another device on your network
ping 192.168.1.1  # Usually your router

# Try to discover all devices (Linux)
nmap -sn 192.168.1.0/24

Where You’ll See This in Production🔗

In real systems:

Key Takeaways🔗

The mental model: A subnet mask is a binary stencil that reveals which part of an IP address identifies the network and which identifies individual devices. It’s the boundary that determines “us vs. them” in networking - devices in the same subnet can talk directly; different subnets need a router.

Tags: networking subnetting subnet-mask cidr fundamentals