Home » Computer Network » How is a Subnet Mask Useful in IP Addressing? (Example)

How is a Subnet Mask Useful in IP Addressing? (Example)

Last updated:

Support this post with a reaction:

2,762 views

In computer networks, efficient and reliable communication depends on how well we organize and identify devices. Internet Protocol (IP) addressing provides a way to uniquely identify every device on a network. However, simply assigning IP addresses is not enough.

We also need a method to separate which part of an IP address refers to the network and which part identifies the specific device (host). This is where the subnet mask becomes essential.

This answer explains what a subnet mask is, why it is a vital component of IP addressing, and how it is used in practice. You will learn core concepts, real-world applications, step-by-step calculations, and detailed examples that make the idea easy to understand.

By the end, you will be able to determine the network address, broadcast address, usable host range, and the number of hosts per subnet using a subnet mask.

What is a Subnet Mask?

A subnet mask is a 32-bit number used in IPv4 networking to divide an IP address into two parts: the network portion and the host portion. It “masks” (i.e., selects) the bits of the IP address that belong to the network while leaving the remaining bits for individual hosts (devices) within that network.

IPv6, this concept exists as a prefix length (for example, /64), but in IPv4 we usually write subnet masks in dotted-decimal format like 255.255.255.0 or in prefix length format like /24.

Why is the Subnet Mask Useful in IP Addressing?

  • It defines the boundary between the network ID and the host ID of an IP address.
  • It enables the calculation of the network address (the identifier of the subnet).
  • It allows finding the broadcast address (used to send a message to all hosts in a subnet).
  • It helps determine the range of usable host addresses within a subnet.
  • It enables subnetting (dividing a larger network into smaller networks) and VLSM (Variable Length Subnet Masking).
  • It supports efficient routing by allowing routers to perform longest-prefix matching and route aggregation (summarization).
  • It aids in IP conservation and efficient address planning, especially in large enterprise networks.
  • It is used in access control lists (ACLs) and firewall rules via wildcard masks derived from subnet masks.

Core Concepts and Terminology

  • Network address (or network ID): The first address in a subnet; identifies the subnet itself, not a host.
  • Broadcast address: The last address in a subnet; used to send to all hosts on that subnet.
  • Usable host range: Addresses between the network and broadcast addresses that can be assigned to devices.
  • Prefix length: The number of bits set to 1 in the mask (e.g., /24 means 24 ones followed by 8 zeros).
  • CIDR (Classless Inter-Domain Routing): A modern addressing method that uses variable-length prefixes (e.g., /27), replacing older classful boundaries.
  • Wildcard mask: The bitwise inverse of a subnet mask (subtract each mask octet from 255); used in ACLs (e.g., mask 255.255.255.0 corresponds to wildcard 0.0.0.255).

How a Subnet Mask Works: Step-by-Step

Internally, devices and routers use binary operations to separate the network and host parts. The primary operation is the bitwise AND between the IP address and the subnet mask:

  • Write the IP address in binary.
  • Write the subnet mask in binary.
  • Perform a bitwise AND: 1 AND 1 = 1; anything AND 0 = 0.
  • The result is the network address.

From the network address and the mask, you can determine the broadcast address and the usable host range.

Example 1: Finding Network, Broadcast, and Host Range

Suppose you have the IP address 192.168.10.75 with subnet mask 255.255.255.224 (this is also written as /27 because 27 bits are 1).

  • IP address: 192.168.10.75
  • Subnet mask: 255.255.255.224 (/27)

Step 1: Convert both to binary conceptually (described, not fully rewritten):

  • IP in binary: 11000000.10101000.00001010.01001011
  • Mask in binary: 11111111.11111111.11111111.11100000
  • Bitwise AND result (network): 11000000.10101000.00001010.01000000

Step 2: Convert the result back to decimal:

  • Network address: 192.168.10.64

Step 3: Compute the block size to find the range of the subnet. The block size is 256 minus the last octet of the mask:

  • Block size = 256 − 224 = 32
  • So subnets are 0–31, 32–63, 64–95, 96–127, and so on within the last octet.
  • Our network address is 192.168.10.64, so this subnet spans 64 to 95 in the last octet.

Step 4: Find the broadcast address and usable host range:

  • Broadcast address = last address in the block = 192.168.10.95
  • Usable host range = 192.168.10.65 to 192.168.10.94

Step 5: Hosts per subnet. In a /27 mask, there are 32 − 27 = 5 host bits. The number of usable hosts is 25 − 2 = 30 (subtracting network and broadcast).

  • Usable hosts per subnet: 30

Interpretation: The mask 255.255.255.224 splits a typical /24 network into eight equal-sized subnets, each with 30 usable addresses. The device 192.168.10.75 belongs to the subnet 192.168.10.64/27, with usable range 65–94 and broadcast .95.

How the Subnet Mask Helps in Real Networks

  • Subnetting a large network: An organization with 192.168.10.0/24 can create multiple departments’ networks, such as /26, /27, etc., to manage broadcast traffic and improve security.
  • Efficient routing: Routers use masks to aggregate routes (e.g., summarize 10.1.4.0/24 to 10.1.7.0/24 as 10.1.4.0/22). This reduces routing table size and improves performance.
  • Access control: In ACLs, wildcard masks derived from subnet masks help express “match these IPs” rules (for example, permit only the 192.168.1.0/24 network using wildcard 0.0.0.255).
  • Address conservation: Variable-length masks allow assigning just enough addresses to each subnet, preventing waste.

Example 2: Subnetting a /24 into Four /26 Subnets

Assume you have a single network 192.168.50.0/24 and you want to create four equal subnets for four departments (HR, Sales, IT, Admin). Each subnet should support up to 62 hosts.

Choose a /26 mask because 2(6) − 2 = 62 usable hosts, and 26 network bits leaves 6 host bits.

  • New mask: 255.255.255.192 (/26)
  • Block size in the last octet: 256 − 192 = 64

This divides the /24 into four /26 subnets:

  • Subnet A: 192.168.50.0/26 — usable: .1 to .62, broadcast: .63
  • Subnet B: 192.168.50.64/26 — usable: .65 to .126, broadcast: .127
  • Subnet C: 192.168.50.128/26 — usable: .129 to .190, broadcast: .191
  • Subnet D: 192.168.50.192/26 — usable: .193 to .254, broadcast: .255

Benefits of using a subnet mask here:

  • Logical separation of departments enhances security and fault isolation.
  • Reduced broadcast domains cut unnecessary traffic.
  • Easier to allocate and track IP addresses.
  • Scalable: future departments can be added with different masks (e.g., a /27 for a smaller team).

CIDR Notation vs Dotted-Decimal Masks

Subnet masks can be expressed in two common ways:

  • Dotted-decimal: 255.255.255.0, 255.255.255.224, etc.
  • CIDR prefix length: /24, /27, etc., representing the number of 1 bits in the mask.

They are equivalent but CIDR notation is more compact and widely used in routing, firewall rules, and documentation. For example, 255.255.255.224 is /27.

How Routers Use Subnet Masks

Routers examine incoming packets and choose an outgoing interface based on the destination IP. The subnet mask enables the router to:

  • Identify the destination network by performing a bitwise AND (just like hosts do).
  • Apply the “longest prefix match” rule: among all possible routes, the route with the most 1 bits (the most specific mask) that matches the destination is selected.
  • Support route summarization: combining several adjacent networks into one larger route, for example, summarizing 10.1.4.0/24 to 10.1.7.0/24 as 10.1.4.0/22 to reduce routing entries.

In essence, subnet masks keep routing tables efficient and speeds up decision-making across the internet and enterprise networks.

Advantages of Using Subnet Masks

  • Efficient address utilization through subnetting and VLSM.
  • Improved performance by reducing broadcast traffic (smaller broadcast domains).
  • Enhanced security and policy control by separating departments or functions into different subnets.
  • Scalability: networks can grow while maintaining structure.
  • Better routing efficiency via longest prefix match and route summarization.
  • Clear network planning and documentation.

Potential Drawbacks and Considerations

  • Incorrect mask selection can lead to wasted IPs or insufficient hosts per subnet.
  • Complexity: VLSM planning requires careful documentation and management to avoid overlaps.
  • Misconfiguration risks: wrong mask can break communication or cause routing loops.
  • Legacy classful thinking can conflict with modern CIDR-based designs if not updated.

Common Mistakes and How to Avoid Them

  • Forgetting network and broadcast addresses when counting usable hosts. Always subtract 2 (except in special cases like point-to-point /31 and /32 in some implementations).
  • Mixing classful defaults with CIDR without clarity. Always document using CIDR (e.g., 192.168.1.0/24).
  • Overlapping subnets due to poor planning. Keep a subnet allocation chart and verify ranges.
  • Ignoring growth. Choose masks that leave room for future hosts or plan for new subnets.
  • Misusing wildcard masks in ACLs. Remember: wildcard = inverse of subnet mask.

Additional Practical Example: ACL Wildcard and Mask Relationship

Suppose you want to permit traffic from 192.168.20.0/24 in a router ACL. The wildcard mask is the inverse of the subnet mask:

  • Subnet mask: 255.255.255.0
  • Wildcard mask: 0.0.0.255

This tells the router: match any IP from 192.168.20.0 through 192.168.20.255. The subnet mask helps you express this rule precisely and correctly.

Real-World Applications of Subnet Masks

  • Enterprise segmentation: Finance, HR, Engineering each on their own subnet, such as /26 or /27, to align with security policies.
  • Data center design: Different tiers (web, application, database) in separate subnets to control east-west traffic.
  • Campus networks: Per-floor or per-building subnets to localize failures and manage broadcast traffic.
  • Service provider networks: Route summarization using masks to reduce global routing table size.
  • Cloud VPCs/VNETs: Defining subnets with CIDR blocks (e.g., 10.0.1.0/24, 10.0.2.0/24) for autoscaling groups, NAT, and load balancers.

Comparing Classful Addressing to CIDR

Historically, IP addresses were divided into classes (A, B, C) with fixed default masks:

  • Class A: default mask 255.0.0.0 (/8)
  • Class B: default mask 255.255.0.0 (/16)
  • Class C: default mask 255.255.255.0 (/24)

Limitations of classful addressing included wasted address space and lack of flexibility. CIDR allows any prefix length (e.g., /13, /21, /27) for fine-grained control. Subnet masks remain the mechanism that makes this possible, by clearly defining the network/host boundary. Modern networks and the internet rely on CIDR for route efficiency and address conservation.

Step-by-Step Checklist for Solving Subnet Problems

  • Identify the given IP and subnet mask (in decimal or CIDR).
  • Convert the mask to prefix length if needed (count the number of 1 bits).
  • Find the block size in the relevant octet (256 − mask octet).
  • Determine the network address by rounding down the IP to the nearest block boundary.
  • Compute the broadcast address (last address in the block).
  • List the usable range (network + 1 to broadcast − 1).
  • Calculate usable host count: 2(host bits) − 2.
  • Verify no overlap if multiple subnets are involved.

How Subnet Masks Enable Summarization (Supernetting)

Subnet masks also support summarizing multiple networks into a single route. For example, consider four /24 networks that are contiguous: 10.1.4.0/24, 10.1.5.0/24, 10.1.6.0/24, 10.1.7.0/24. A router can advertise a single summary: 10.1.4.0/22. The /22 mask groups these four /24 networks because their first 22 bits are identical. This reduces routing table entries and improves scalability across large networks.

Security and Policy with Subnet Masks

Security teams often write policies by subnet: “Allow only 172.16.10.0/24 to access the database.” The subnet mask (or CIDR prefix) clearly defines which set of IPs is allowed. Firewalls and routers translate these into hardware-friendly comparisons using the mask. Similarly, guest Wi-Fi, IoT devices, and sensitive servers can be isolated in distinct subnets with different access rules.

Performance Optimization via Subnetting

In large Layer-2 networks, broadcast packets (like ARP) can become noisy and inefficient. Dividing a large network into smaller subnets (smaller broadcast domains) reduces this overhead. Each subnet has its own broadcast address; devices will only see broadcasts from their own subnet, improving performance and reliability. The subnet mask is the tool that defines and enforces these boundaries.

Planning Tips for Choosing a Subnet Mask

  • Estimate the number of devices now and in the near future; pick a mask that fits growth (e.g., if you need 40 hosts, a /26 with 62 usable is safer than a /27 with 30).
  • Keep consistent documentation: always write networks in CIDR (e.g., 192.168.10.64/27).
  • Use hierarchical design: core, distribution, access layers with summarizable prefixes.
  • Avoid overlapping subnets; maintain an IP address management (IPAM) sheet or tool.
  • Separate critical services (e.g., servers, VoIP phones, management interfaces) into distinct subnets with appropriate masks.

Short Contrast: IPv4 vs IPv6 in Masking

While IPv4 uses dotted decimal masks and has limited address space, IPv6 uses a 128-bit address space and standardizes on prefix lengths without dotted masks. Common IPv6 subnets are /64, which simplifies operations such as Stateless Address Autoconfiguration (SLAAC). The conceptual role (defining network vs interface identifier) is similar, but the format and scale differ.

Frequently Observed Exam Pitfalls

  • Miscounting usable hosts due to ignoring the network and broadcast addresses.
  • Mistaking 255.255.255.224 as /28 instead of /27 (remember: 224 corresponds to 3 network bits in the last octet; 24 + 3 = 27).
  • Not using the block size trick (256 − mask octet) to quickly find ranges.
  • Confusing wildcard masks with subnet masks (they are inverses).

End-to-End Walkthrough: From IP to All Key Values

Let’s revisit the earlier example and present it as a compact procedure you can reuse:

Given IP 192.168.10.75 and mask 255.255.255.224:

  • Convert mask to prefix: 255.255.255.224 = /27
  • Host bits = 32 − 27 = 5; usable hosts = 25 − 2 = 30
  • Block size in last octet = 256 − 224 = 32
  • Find nearest multiple of 32 less than or equal to 75: that is 64 → Network = 192.168.10.64
  • Broadcast = 64 + 31 = 95 → 192.168.10.95
  • Usable range = 65 to 94 → 192.168.10.65–192.168.10.94

This pattern works for most IPv4 subnetting problems and demonstrates how essential the subnet mask is in identifying the structure of the network.

Conclusion

A subnet mask separates the network and host portions of an IP address, allowing efficient subnetting, reduced broadcast traffic, and better security. It supports scalable routing through CIDR and summarization, helping design organized and efficient IP networks. From calculating network and broadcast addresses to defining host ranges, subnet masks are essential for structured and reliable communication across all network sizes.

How addresses are grouped is covered in IP addressing and classification.