Subnetting for Beginners

/ ... Views

I’ve been diving into networking recently, exploring the basic fundamentals like IP addressing, switching, routing, network security, etc. But there’s one topic I always forget how to do, even though I understand the concept. I’ve often found myself going back through my notes or searching online resources to get a refresher. After doing this enough times, I decided it might be best to write a blog dedicated to this topic.

So this blog is for those who want to learn how subnetting works step-by-step. My goal is to make subnetting easy to understand for anyone who wants to learn the process or just needs a refresher every once in a while.

Learning Objectives of This Blog:

  • Grasp the concept of subnetting
  • Learn how to interpret CIDR notation
  • Identify the number of hosts and the network ID from an IP CIDR notation
  • Determine the range of host addresses and the broadcast IP of a subnet

What is Subnetting?

Subnetting is the process of dividing a larger network into multiple smaller networks, known as subnets. This segmentation enhances network security, optimizes routing, and reduces the size of the broadcast domain, making the network more efficient.

I won’t go into detail on the benefits of subnetting here, but you can explore them in other resources.

How Do We Subnet?

To create subnets, we split the host portion of an IP network address into two sections. This involves borrowing bits from the host part of the IP address and assigning them as subnet bits. The number of bits borrowed will depend on how many subnets you need.

 
notion image
 

For example, suppose you have a network address with the network ID 192.168.1.0, and you want to divide it into 6 separate networks. To achieve this, you would need to borrow 3 bits from the available 8 host bits to accommodate the 6 required subnets. The formula to determine the number of subnets is:

Number of subnets = 2^(subnet bits)

 
notion image

CIDR Address Notation:

You may have encountered IP addresses like 192.168.190.9/18 or subnet masks like 255.255.192.0, which differ from the common 255.255.255.0 subnet mask. In this notation, the “/18” indicates that the first 18 bits of the address are used for the network part, leaving 14 bits for hosts.

To calculate the number of hosts in this setup:

  • Host bits left = 32 - subnet bits
  • Number of hosts = 2^(number of host bits left) - 2

(The subtraction of 2 accounts for the network ID and broadcast address.)

For example, an IP address commonly seen in internal networks, like 192.168.10.32/24, has 24 bits dedicated to the network portion and the remaining 8 bits for hosts.

 
notion image
 

The illustration above can help clarify how CIDR notation works.

Example: Finding Hosts, Network ID, and Subnet

Let’s try an example with the IP address 192.168.190.9/18. Here, the “/18” signifies that 18 bits are allocated for the network, leaving 14 bits for hosts.

To identify the network ID, sum up the first 18 bits, giving you a network ID of 192.168.128.0.

Determining IP Subnet’s Host Range and Broadcast Address:

Take the IP address 192.168.10.32/24 as an example. Suppose you need 3 subnets, which means you’ll borrow 2 bits from the remaining host bits. Your first subnet would then start at 192.168.10.128. To find the range of host IPs in this subnet, remember that the range doesn’t include all 000000 or all 111111 in the host portion. Thus, the usable host IP range would be from 192.168.10.129 to 192.168.10.190.

The broadcast address for this subnet, as always, is the last IP in the range: 192.168.10.191.

 
But the best way is to practice! go to this site . Watch the videos and do the practice scenarios until it clicks.
 

Also, here is a trick that I use to map out the hosts and subnets:

Just remember this table:

|CIDR| | Hosts | | Subnets |

/30    4           64

/29    8           32

/28    16          16

/27    32          8

/26    64          4

/25    128         2

/24    256         1

Don't forget to subtract two hosts, the first address in the subnet is the network address and the last is the broadcast.

Realistically, If you can remember CIDR /30 and CIDR /24 you're golden, remember that:

Counting down from CIDR /30 the Hosts double and the subnets half.

|CIDR| | Hosts | | Subnets |

/30      4         64

Counting up for CIDR /24, the hosts half and the subnets double.

|CIDR| | Hosts | | Subnets |

/24      256       1
 

Not needed to memorize:

Also, there is a Cisco specific /31 CIDR which for a point to point connection between two routers. This one has no subnet or network address so you don't subtract 2.

|CIDR| | Hosts | | Subnets |

/31      2         128

Also:

|CIDR| | Hosts | | Subnets |

/23      512       128

This one is only here to emphasize that when you go below /24 subnet mask 255.255.255.0 becomes 255.255.0.0 and the hosts start counting back up and the subnets start counting down from 128.

 
Here is the full cheat sheet for you: subnetting.PDF

Here is some examples on how to solve in 24-32 range :

notion image
 

How to solve with the Cheat sheet for 17-24 range :

notion image
 
Any feedback or constructive criticism is welcomed!
 
Reshad Sadik
Developer + writter from 🇧🇩
@reshad_sadik

Continue reading

View all →