DEV Community

Cover image for Subnetting Demystified: Concepts, Importance, and a Real-World Example
daniel💻
daniel💻

Posted on • Edited on

2 1 1 1 1

Subnetting Demystified: Concepts, Importance, and a Real-World Example

Prerequisites

The goal of this article is to give you a clear understanding of what subnetting is, its importance, and a real-world example of subnetting in action. To fully grasp the concepts in this article, you need a good understanding of what an IP address is, its structure, subnet masks, and CIDR notation. All of these topics are covered in this article: [Decoding IP Addresses: Mastering Subnet Mask and CIDR Notation].


How Subnetting Works

A network is simply a group of computers that can communicate with each other. In technical terms, it is a group of hosts within the same IP range. As the size of a network grows, communication becomes increasingly difficult due to heavy traffic loads. To address this issue, large networks can be divided into smaller, more manageable subnetworks (subnets) using a process called subnetting. Subnetting helps reduce congestion by limiting broadcast traffic to smaller groups of hosts.

Subnetting is the method used to divide large networks into smaller, more manageable networks called subnetworks or subnets.

Flat Network

A flat network is a network without subdivisions (subnets), where all devices share the same broadcast domain. This can lead to issues like increased broadcast traffic, scalability problems, and security risks, which subnetting aims to address.

Example of Subnetting

Suppose you have a Class C IP address 192.168.1.0/24 that needs to be divided into 4 subnets. The total number of possible IPs is 256, ranging from 192.168.1.0 to 192.168.1.255.

Note: Only 254 IP addresses are available for use because the Network address (192.168.1.0) and the Broadcast address (192.168.1.255) are reserved and cannot be assigned to devices. The Network address is the first IP address in the range, and the Broadcast address is the last.

The subnet can be divided as follow:

  • Subnet 1: 192.168.1.0/26. This provides a total of 64 IPs from range 192.168.1.0 to 192.168.1.63

  • Subnet 2: 192.168.1.64/26. This provides a total of 64 IPs from range 192.168.1.64 to 192.168.1.127

  • Subnet 3: 192.168.1.128/26. This provides a total of 64 IPs from range 192.168.1.128 to 192.168.1.191

  • Subnet 4: 192.168.1.192/26. This provides a total of 64 IPs from range 192.168.1.192 to 192.168.1.255.


Importance of Subnetting

Some of the importance of dividing a network into subnetworks include:

  • Efficient Use of IP Addresses: Subnetting allows the administrator to allocate only the necessary number of IPs required for that subnet, preventing waste.

  • Improved Security: Subnetting reduces security risks by limiting access between subnets. Unlike a flat network, which broadcasts packets and resources to every single host on the network.

  • Enhanced Performance: Each subnet runs faster because of the reduced broadcasting traffic burden. For example, it is easier to broadcast a packet to 10 hosts in a subnetwork than to 200 hosts in an undivided, flat network.

  • Simplifies Network Management: By dividing networks into subnetworks, the workflow on a topology becomes clearer, making it easier to manage, detect problems, and reduce downtime. When one network goes down, the others can still function properly.

  • Privacy: Subnetting limits visibility between subnets by isolating sensitive traffic from the general network. For example, the HR department does not need to see the data that travels within the Admin department.


A Real-World Application of Subnetting

Your company has been assigned the IP network: 192.168.1.0/24. As the Network Admin, you are tasked with dividing this network to serve four different departments in your company:

  • Admin (50 hosts)
  • HR (25 hosts)
  • Staff (30 hosts)
  • Guest (14 hosts)

Each subnet must accommodate the required number of hosts. The formula for calculating how many hosts are available to a network is:

Hosts Available = 2^h - 2
Enter fullscreen mode Exit fullscreen mode

Where:

  • h is the number of host bits in the IP address.
  • 2 is subtracted because the network address and the broadcast address are reserved and cannot be used.

Finding the Number of Host Bits (h)

Let's use the Admin subnet as an example. Remember, the Admin subnet needs 50 hosts.

To find h for this subnet, find the smallest power of 2 that can accommodate the required number of hosts (50) in the subnet using this formula:

2^h ≥ Required Hosts + 2
Enter fullscreen mode Exit fullscreen mode
**Number of host bits(h)** => 2h ≥ 50 + 2
Enter fullscreen mode Exit fullscreen mode

After solving, h will equal 6 (approximately 5.7, which rounds up to 6).

We can solve for the total number of hosts that will be available to the subnet:

**Hosts Available** => 26 - 2 = 62
Enter fullscreen mode Exit fullscreen mode

The subnet mask for this subnet will be: 32 - 6, where 32 is the number of bits in an IP address and 6 is the number of host bits (h). This will give us a subnet mask of /26.

Allocating the Admin Subnet

From the example above, we can now set the Admin Subnet as follows:

- Department: Admin
- Number of host bits(h): 6
- Hosts Needed: 50
- Hosts Available: 62
- Subnet mask: `/26` or `255.255.255.192`
- Network Address: `192.168.1.0`
- Broadcast Address: `192.168.1.63`
- Usable IP Range: `192.168.1.1` to `192.168.1.62`
Enter fullscreen mode Exit fullscreen mode

Using this example, allocate the subnet for the HR, Staff, and Guest subnets. If you get stuck anywhere, feel free to reach out to me or leave a comment.

Image of Timescale

Timescale – the developer's data platform for modern apps, built on PostgreSQL

Timescale Cloud is PostgreSQL optimized for speed, scale, and performance. Over 3 million IoT, AI, crypto, and dev tool apps are powered by Timescale. Try it free today! No credit card required.

Try free

Top comments (3)

Collapse
 
mohasinkr profile image
Mohasin K R •

worst explanation of subnetting ever!

Collapse
 
daniel_idoko profile image
daniel💻 •

can you be more specific

Collapse
 
daniel_idoko profile image
daniel💻 •

Ask questions here

Some comments may only be visible to logged-in visitors. Sign in to view all comments.

Image of Timescale

Timescale – the developer's data platform for modern apps, built on PostgreSQL

Timescale Cloud is PostgreSQL optimized for speed, scale, and performance. Over 3 million IoT, AI, crypto, and dev tool apps are powered by Timescale. Try it free today! No credit card required.

Try free

👋 Kindness is contagious

Explore a sea of insights with this enlightening post, highly esteemed within the nurturing DEV Community. Coders of all stripes are invited to participate and contribute to our shared knowledge.

Expressing gratitude with a simple "thank you" can make a big impact. Leave your thanks in the comments!

On DEV, exchanging ideas smooths our way and strengthens our community bonds. Found this useful? A quick note of thanks to the author can mean a lot.

Okay