close
close

Basic Guide to Subnetting – DEV Community

Understanding Subnetting: A Comprehensive Guide

Subnetting is a fundamental concept in computer networking that involves dividing a single network into smaller, more manageable subnets or subnets. This technique improves network performance and security, increases the efficiency of IP address allocation, and simplifies administration. In this article, we explore the basics of subnetting, the benefits it provides, and how to calculate and implement subnets.

What is subnetting?

Subnetting is the process of dividing a large network into smaller, logical subnets. Each subnet functions as an independent network, with its own set of IP addresses, but they all share the same network ID. This is accomplished by manipulating the subnet mask, which is used to distinguish the network portion of an IP address from the host portion.

Image description
Graph Credit: gcore

Why subnetting is important

  1. Efficient IP address management:By dividing a large network into smaller subnets, IP addresses can be allocated more effectively, reducing waste.
  2. Enhanced security:Subnetting allows you to better manage network traffic and segment and isolate sensitive parts of the network.
  3. Improved performance:Smaller subnets reduce broadcast traffic, which can improve network performance and reduce congestion.
  4. Simplified Troubleshooting:Managing and troubleshooting smaller networks is easier than managing one large network.

Understanding Subnet Masks

Subnet graph

A subnet mask is a 32-bit number that masks an IP address and divides it into network and host portions. It consists of a series of consecutive 1s followed by 0s. The number of 1s defines the network portion, while the 0s represent the host portion.

For example in the subnet mask 255.255.255.0the first 24 bits are set to 1, indicating that the first 24 bits of the IP address are the network portion and the remaining 8 bits are for host addresses.

Calculate subnets

To create subnets, follow these steps:

  1. Determine the required number of subnets or hosts: Determine how many subnets or hosts per subnet you need.
  2. Calculate the number of bits required: Use the formula 2^n >= number of subnets to find the number of bits (n) needed for subnetting.
  3. Adjust subnet mask: Extend the default subnet mask by the number of calculated bits.
  4. Calculate the new subnet addresses: Use the extended subnet mask to determine the range of IP addresses for each subnet.

Network and Host Bits

This example shows how a network mask divides an IP address into network, subnet, and host parts.

Example calculation

Let’s assume we have a class C network 192.168.1.0/24 and we need 4 subnets.

  1. Number of subnets required: 4
  2. Calculate the required bits: 2^n >= 4n = 2
  3. Adjust subnet mask: The original mask is /24 (255.255.255.0). We add 2 bits for the subnet, resulting in a /26 mask (255,255,255,192).
  4. Calculate subnet addresses:

    • Subnet 1: 192.168.1.0 - 192.168.1.63
    • Subnet 2: 192.168.1.64 - 192.168.1.127
    • Subnet 3: 192.168.1.128 - 192.168.1.191
    • Subnet 4: 192.168.1.192 - 192.168.1.255

IPv4 Classes and Subnet Masks

Graph credit: gcore
Check out the extensive article on What is a subnet? | How it works

Each subnet has 64 IP addresses (including network and broadcast addresses), giving hosts 62 usable addresses.

Implementing subnetting

Implementing subnetting in a network:

  1. Plan the subnet structure: Define the number of subnets and the size of each subnet based on the needs of the organization.
  2. Configure network devices: Update routers and switches with the new subnet information.
  3. Assign IP addresses: Assign IP addresses to devices within each subnet.
  4. Update Documentation: Provide updated network documentation to reflect the new subnet structure.

Conclusion

Subnetting is a core technique for network design and management. Subnetting offers many benefits for network efficiency, security, and performance. By learning and implementing subnetting techniques, network administrators can create networks that can scale and be managed. Whether you are studying for a networking certification exam or want to improve your organization’s network, mastering this skill is essential for computer networking.


                                Ilyas Filali
                                 @nayetwolf 
Go to full screen mode

Exit full screen