Network mask

📘 CCNA 200-301 v1.1

3.1 Interpret the components of routing table

3.1.c Network Mask

🔹 What is a Network Mask?

A network mask (also called a subnet mask) is a 32-bit number that divides an IP address into two parts:

  1. Network portion – identifies the network where the device belongs.
  2. Host portion – identifies a specific device (host) inside that network.

The network mask helps routers and devices understand which part of an IP address refers to the network and which part refers to the host.


🔹 Why is the Network Mask Important?

In routing, the network mask tells the router how many bits of the IP address are the network bits.
This helps routers:

  • Match routes correctly
  • Determine the destination network for forwarding packets
  • Avoid sending packets to the wrong network

Without a network mask, routers would not know how to separate network and host addresses.


🔹 Format of a Network Mask

A subnet mask is 32 bits long, just like an IPv4 address.
It is usually written in two forms:

  1. Dotted-decimal notation (DDN):
    Example: 255.255.255.0
  2. Prefix notation (CIDR):
    Example: /24

Both mean the same thing.


🔹 How It Works

Each “1” bit in the mask represents the network part, and each “0” bit represents the host part.

Example:

TypeBinaryDecimal
IP Address192.168.10.5
Subnet Mask11111111.11111111.11111111.00000000255.255.255.0

In this example:

  • First 24 bits are 1s → Network part
  • Last 8 bits are 0s → Host part

So, /24 means:

  • 24 bits for network
  • 8 bits for host

🔹 Network Mask and Routing Table

Every entry in a routing table contains:

  • Destination network
  • Subnet mask (or prefix length)
  • Next hop
  • Outgoing interface
  • Metric (cost)

The network mask in each entry helps the router decide which route matches a destination IP.

Example:

Destination NetworkMaskNext HopInterfaceMetric
192.168.10.0255.255.255.010.0.0.2Gig0/01
192.168.20.0255.255.255.010.0.0.3Gig0/11

If a packet is going to 192.168.10.15,
the router checks:

  • Does 192.168.10.15 match 192.168.10.0/24? ✅ Yes → Send via Gig0/0
  • Does it match 192.168.20.0/24? ❌ No

That’s how the mask helps the router select the correct route.


🔹 CIDR and Prefix Length

The prefix length (after the slash) shows how many bits are network bits.

Examples:

PrefixSubnet MaskNetwork BitsHost BitsNumber of Hosts
/8255.0.0.082416,777,214
/16255.255.0.0161665,534
/24255.255.255.0248254
/30255.255.255.2523022 (used for point-to-point links)

Routers use these masks to group IPs into networks and know how big or small each network is.


🔹 Network Mask in Route Matching (Longest Match Rule)

When a router checks the routing table, it can find multiple routes that match a destination IP.
In that case, it uses the Longest Prefix Match Rule.

👉 The route with the longest subnet mask (most network bits) is chosen because it’s the most specific match.

Example:

If the routing table has:

  • 192.168.0.0/16
  • 192.168.10.0/24

A packet to 192.168.10.25 will match both routes.
The router will choose 192.168.10.0/24 (because /24 is longer than /16).


🔹 Default Masks (Classful Networks)

Older (classful) IP systems used default subnet masks:

IP ClassFirst Octet RangeDefault MaskPrefix
Class A1–126255.0.0.0/8
Class B128–191255.255.0.0/16
Class C192–223255.255.255.0/24

Modern networks (classless) use CIDR (Classless Inter-Domain Routing), so routers use custom subnet masks instead of default ones.


🔹 Key Points for CCNA Exam

✅ The network mask defines how many bits are for the network and host.
✅ It is used by routers to match routes in the routing table.
✅ It appears in both dotted-decimal and prefix (CIDR) formats.
✅ The longest prefix match rule decides the most specific route.
✅ Default masks exist for traditional (classful) networks but modern networks use classless masks.


🔹 Summary

ConceptDescription
PurposeDivide IP into network and host parts
Used byRouters and devices to route packets correctly
FormatDotted-decimal or CIDR (/notation)
Example255.255.255.0 = /24
In Routing TableDefines which IPs belong to the destination network
Rule UsedLongest Prefix Match

Leave a Reply

Your email address will not be published. Required fields are marked *

Buy Me a Coffee