Blog

Subnetting Demystified: Learn How IP Networks Really Work

Subnetting Demystified: Learn How IP Networks Really Work

IP Subnetting is one of the most fundamental but also among the most misunderstood subjects with regard to a particular field. One popular misconception regarding this topic focuses on the benefits that come from using Subnet Works. By breaking up larger networks into many smaller networks (subnetting), these businesses will experience better performance, higher levels of Security, Ease of Management, and more efficient use of available IP Address Space.

What is an IP Address?

Internet Protocol Address is the unique identification of every device connected to any network whether it is public or private. Every device gets a unique IP in the particular network to identify itself with others devices and to communicate with each other they need it. 

Any device that connects with any network will get an IP from its ISP for identifying the device and network traffic in the public or worldwide network. The IP is very necessary for any device validation on the internet for many things like communication with another device, file sending, and receiving.

An IP address is known as the logical address of the devices which is very necessary for device validation. Mostly the IP address is divided into classes which are likely to be A, B, C, D, and E class.

192.168.10.25

Every IP address consists of two parts:

Network Portion → Identifies the network
Host Portion → Identifies a device inside the network

IPv4 Address Structure

An IPv4 address is made of 32 bits divided into 4 octets, each ranging from 0 to 255.

Example:
192.168.1.10
→ 192 | 168 | 1 | 10
→ each octet = 8 bits
→ total = 32 bits

What is a Subnet?

A subnet (short for “subnetwork”) is a smaller logical network created from a larger network. Subnetting divides one network into multiple segments.

Example:
A company’s 192.168.1.0 network can be divided into:

  • 192.168.1.0 → HR
  • 192.168.1.64 → Finance
  • 192.168.1.128 → CCTV
  • 192.168.1.192 → Students/WiFi

Every subnet works independently and is separated by routers or Layer 3 switches.

Why Do We Need Subnetting?

Subnetting solves multiple problems in modern networks:

  1. Avoids wasting IPs, especially in big networks.
  2. Subnetting decreases broadcast traffic and improves network performance.
  3. Each subnet can be isolated using ACLs, firewalls, VLANs, and routing.
  4. Different departments, floors, or functions get different networks.
  5. Large organizations may need hundreds of manageable subnets.
  6. AWS VPCs, Azure VNets, and Kubernetes all use subnetting.

What is a Subnet Mask?

A subnet mask tells us which part of the IP is the Network and which part is the Host.

Subnet MaskCIDRMeaning
255.255.255.0/24First 24 bits are network bits
255.255.0.0/16First 16 bits are network bits
255.255.255.128/25First 25 bits are network bits
255.255.255.240/28First 28 bits are network bits

The Subnet Mask is a 32-bit value used to distinguish between the Network and Host portions of an IP address.

  • The bits in the mask corresponding to the Network Portion are set to 1 (all contiguous 1s).
  • The bits corresponding to the Host Portion are set to 0 (all contiguous 0s).

bitwise AND operation between the IP address and the Subnet Mask reveals the Network Address.

CIDR Notation (Classless Inter-Domain Routing)

The length of the network portion is often represented using CIDR notation, written as a slash followed by a number (e.g., /24). This number indicates the total count of Network Bits (the 1s) in the subnet mask.

CIDRSubnet Mask (Binary)Subnet Mask (Decimal)
/811111111.00000000.00000000.00000000255.0.0.0
/1611111111.11111111.00000000.00000000255.255.0.0
/2411111111.11111111.11111111.00000000255.255.255.0

Examples:

  • /24 = 255.255.255.0
  • /20 = 255.255.240.0
  • /28 = 255.255.255.240

CIDR simply counts how many bits are for the network portion.

How Subnetting Works Internally

Subnetting works by borrowing bits from the host portion and turning them into network bits.

Example:

A Class C network default mask = /24
Borrow 1 bit → /25
Borrow 3 bits → /27
Borrow 4 bits → /28

Every bit borrowed increases the number of subnets, but decreases the available hosts. By “borrowing” one or more bits from the Host Portion of the IP address and adding them to the Network Portion. These borrowed bits become the Subnet Bits.

This process achieves two main goals:

  1. Creates more subnets: Each combination of the new Subnet Bits represents a unique subnetwork.
    • Number of Subnets =2n (where n is the number of borrowed bits).
  2. Reduces the number of hosts per subnet: Fewer bits are left for the host portion.
    • Number of Usable Hosts =2h−2 (where h is the number of remaining host bits. We subtract 2 because the first and last addresses in each subnet are reserved).

Reserved Addresses in a Subnetting

In every subnetwork, two addresses are reserved and cannot be assigned to hosts:

  • Network Address: The first address in the range. All host bits are set to 0. This address is used by routers to identify the network.
  • Broadcast Address: The last address in the range. All host bits are set to 1. Data sent to this address reaches all devices on that specific subnet.

Binary Rules of Subnetting (Universal Rules)

These rules never change:

1. Network/Subnet Address

All host bits = 0

2. Broadcast Address

All host bits = 1

3. First Host

All host bits = 0, except the last bit = 1

4. Last Host

All host bits = 1, except the last bit = 0

This is how every router, switch, firewall, and OS calculates subnets.

Step-by-Step Subnetting Method (Easy Student Method)

This method works for ANY subnetting question:

  • Find first and last usable hosts
  • Convert CIDR → subnet mask
  • Calculate block size
  • Find subnet range
  • Determine network address
  • Determine broadcast address

Scenario: Subnet the network 192.168.10.0 /24 to create at least 5 new subnets.

Step 1: Determine the Number of Borrowed Bits (n)

The original subnet mask is /24, which means 32−24=8 host bits are available (the last octet).

We need at least 5 subnets. We use the formula 2n≥Number of required subnets.

  • 21=2 (Not enough)
  • 22=4 (Not enough)
  • 23=8 (Enough!)

We need to borrow n=3 bits from the host portion.

Step 2: Calculate the New Subnet Mask (New Prefix)

The original prefix was /24. By borrowing 3 bits, the new prefix is 24+3=/27.

The new subnet mask will have 27 contiguous ‘1’s.

Octet 1Octet 2Octet 3Octet 4 (Subnetting occurs here)
8 bits8 bits8 bits3 Subnet Bits, 5 Host Bits
11111111111111111111111111100000
255255255128+64+32 = 224

The new custom subnet mask is 255.255.255.224.

Step 3: Calculate Remaining Host Bits (h) and Hosts per Subnet

Total bits in an octet is 8. We borrowed n=3 bits, leaving h=8−3=5 host bits.

  • Total Addresses per Subnet =2h=25=32
  • Usable Hosts per Subnet =2h−2=32−2=30

Step 4: Determine the Subnet Ranges

The 3 borrowed bits create 23=8 subnets. The block size or increment for the new subnets is determined by the value of the last ‘1’ bit in the subnet mask’s last octet. In the 224 octet, the binary representation is 11100000. The last ‘1’ is in the 32 position.

The subnets will increment by 32 in the last octet.

Subnet NumberNetwork Address (All Host Bits are 0)Host Range (Usable IPs)Broadcast Address (All Host Bits are 1)
0192.168.10.0 /27192.168.10.1 – 192.168.10.30192.168.10.31
1192.168.10.32 /27192.168.10.33 – 192.168.10.62192.168.10.63
2192.168.10.64 /27192.168.10.65 – 192.168.10.94192.168.10.95
3192.168.10.96 /27192.168.10.97 – 192.168.10.126192.168.10.127
….….….….
7192.168.10.224 /27192.168.10.225 – 192.168.10.254192.168.10.255

You have successfully divided the original network into 8 smaller, manageable subnets, each with 30 usable IP addresses.

How Routers Use the Bitwise AND Operation

When a router needs to determine if a destination IP address is on the local network (i.e., within the same subnet) or needs to be forwarded to another network, it performs a Bitwise AND operation.

Example: Is 192.168.10.45 on the network 192.168.10.32 /27?

The router applies the new Subnet Mask 255.255.255.224 to the destination IP address:

OctetDecimal IPBinary IPDecimal MaskBinary MaskBinary ResultDecimal Result
1192110000002551111111111000000192
2168101010002551111111110101000168
31000001010255111111110000101010
44500101101224111000000010000032

The resulting Network Address is 192.168.10.32. Since the bitwise AND operation yields the Network Address of the subnet 192.168.10.32 /27, the device with IP 192.168.10.45 is indeed part of that subnet.

Benefits of Subnetting

  • Efficient IP Address Allocation: Prevents wastage of IP addresses by creating subnets of appropriate size, essential for the limited pool of IPv4 addresses.
  • Reduced Network Congestion: Limits the size of the broadcast domain. Broadcast traffic (messages sent to all devices) is contained within the smaller subnet, leading to less traffic on the overall network.
  • Enhanced Security: Subnets allow administrators to isolate different segments (e.g., servers, guest Wi-Fi, employee computers) using firewalls or Access Control Lists (ACLs), preventing unauthorized access between segments.
  • Simplified Management: Breaking a large, complex network into smaller, logical subnets makes it easier to manage, troubleshoot, and scale.

For any query contact us at [email protected]

Thank you for reading this post, don't forget to subscribe!