Subnet Masks and Subnetting in IP Addressing: Understanding Network Segmentation

Learn about subnet masks and subnetting in IP addressing. This guide explains how subnet masks delineate network and host portions of IP addresses, enabling efficient network segmentation and allocation of IP addresses within a network.



Subnet Masks and Subnetting in IP Addressing

Introduction to Subnet Masks

Every device on a network has an IP address, which is divided into two parts: the network address (identifying the network the device belongs to) and the host address (identifying the specific device within that network). A subnet mask is a 32-bit number that helps separate these two parts of an IP address. It works like a mask, showing which bits represent the network and which bits represent the host.

What is a Subnet Mask?

A subnet mask is created by setting the network bits to '1' and the host bits to '0'. The subnet mask is applied using a bitwise AND operation between the subnet mask and the IP address. This results in the network address. The subnet mask itself isn't assigned to any specific device; it's a tool for identifying network boundaries.

Subnet Masks and IP Address Classes

Historically, IP addresses were categorized into classes (A, B, C, D, E). Each class had a default subnet mask that defined the number of bits used for the network address and the host address:

Class IP Address Range Default Subnet Mask Network Bits Host Bits
A 1.0.0.0 - 127.255.255.255 255.0.0.0 8 24
B 128.0.0.0 - 191.255.255.255 255.255.0.0 16 16
C 192.0.0.0 - 223.255.255.255 255.255.255.0 24 8

Classes D and E are reserved for multicast and experimental use, respectively.

Note: Classful addressing is largely obsolete. Classless Inter-Domain Routing (CIDR) notation is the modern standard.

Subnetting: Dividing a Network

Subnetting divides a network into smaller subnets. This improves network organization, reduces broadcast traffic, and allows for more efficient IP address allocation. The subnet mask is essential in identifying devices within the same subnet. Subnetting is applied by borrowing bits from the host portion of the IP address to create additional network bits.

Classless Inter-Domain Routing (CIDR)

CIDR uses a simpler notation: IP address/number of network bits (e.g., 192.168.1.0/24). This is more flexible and efficient than the older class-based system.

Subnet Mask Calculators

Manually calculating subnet masks can be tedious. Subnet mask calculators provide tools to simplify this process:

  • IPv4/IPv6 Calculators: Convert between different notations.
  • Wildcard Mask Calculators: Calculate wildcard masks used in routing.
  • Subnet Range Calculators: Determine the range of addresses in a subnet.

Example: Calculating a Subnet Mask

Let’s calculate the subnet mask for the IP address 128.38.130.89, needing 6 subnets:

  1. Identify the IP address class (Class B).
  2. Calculate the number of bits needed for subnetting: log₂(number of subnets + 2) = log₂(8) = 3 bits.
  3. Borrow 3 bits from the host portion of the default Class B subnet mask (255.255.0.0): 11111111.11111111.11100000.00000000
  4. Convert the binary mask to decimal: 255.255.224.0

The subnet mask is 255.255.224.0.

Conclusion

Subnet masks are crucial for efficient network management. They define network and host address boundaries, facilitating effective IP address allocation and improving network organization. CIDR notation has simplified IP address management.