Tutorials Logic
Tutorials Logic, IN info@tutorialslogic.com
Navigation
Home About Us Contact Us Blogs FAQs
Tutorials
All Tutorials
Services
Academic Projects Resume Writing Website Development
Practice
Quiz Challenge Interview Questions Certification Practice
Tools
Online Compiler JSON Formatter Regex Tester CSS Unit Converter Color Picker
Compiler Tools

Subnetting — Subnet Mask, CIDR, VLSM Guide

Why Subnetting?

Subnetting is the process of dividing a large network into smaller, more manageable sub-networks (subnets). Benefits include:

  • Reduces network congestion (smaller broadcast domains)
  • Improves security (isolate network segments)
  • Efficient use of IP address space
  • Easier network management and troubleshooting

Subnet Mask and CIDR Notation

A subnet mask is a 32-bit number that separates the network portion from the host portion of an IP address. It uses 1s for the network bits and 0s for the host bits.

CIDR (Classless Inter-Domain Routing) notation expresses the subnet mask as a prefix length (number of 1 bits).

CIDRSubnet MaskNetwork BitsHost BitsUsable Hosts
/8255.0.0.082416,777,214
/16255.255.0.0161665,534
/24255.255.255.0248254
/25255.255.255.128257126
/26255.255.255.19226662
/27255.255.255.22427530
/28255.255.255.24028414
/29255.255.255.2482936
/30255.255.255.2523022

Formula: Usable hosts = 2n - 2, where n = number of host bits. We subtract 2 for the network address and broadcast address.

Subnetting Example: /24 Network

Given network: 192.168.1.0/24

  • Network Address: 192.168.1.0 (all host bits = 0)
  • Broadcast Address: 192.168.1.255 (all host bits = 1)
  • Usable Host Range: 192.168.1.1 - 192.168.1.254
  • Number of Usable Hosts: 28 - 2 = 254

Dividing /24 into Subnets

Divide 192.168.1.0/24 into 4 equal subnets (/26):

SubnetNetwork AddressBroadcastHost RangeHosts
1192.168.1.0/26192.168.1.63192.168.1.1 - .6262
2192.168.1.64/26192.168.1.127192.168.1.65 - .12662
3192.168.1.128/26192.168.1.191192.168.1.129 - .19062
4192.168.1.192/26192.168.1.255192.168.1.193 - .25462

VLSM (Variable Length Subnet Masking)

VLSM allows using different subnet masks for different subnets within the same network, enabling more efficient use of IP addresses. Instead of dividing a network into equal-sized subnets, you allocate exactly the right size for each subnet.

Example: You have 192.168.1.0/24 and need:

  • Subnet A: 100 hosts -> use /25 (126 hosts) -> 192.168.1.0/25
  • Subnet B: 50 hosts -> use /26 (62 hosts) -> 192.168.1.128/26
  • Subnet C: 25 hosts -> use /27 (30 hosts) -> 192.168.1.192/27
  • Subnet D: 10 hosts -> use /28 (14 hosts) -> 192.168.1.224/28
Key Takeaways
  • Subnetting divides a large network into smaller, more manageable sub-networks.
  • A subnet mask determines which part of an IP address is the network and which is the host.
  • CIDR notation (e.g., 192.168.1.0/24) specifies the network address and prefix length.
  • /24 means 24 bits for network, 8 bits for hosts - allowing 254 usable host addresses.
  • The first address in a subnet is the network address; the last is the broadcast address.
  • Subnetting improves security, reduces broadcast traffic, and makes IP address management easier.

Level Up Your Networking Skills

Master Networking with these hand-picked resources

10,000+ learners
Free forever
Updated 2026

Ready to Level Up Your Skills?

Explore 500+ free tutorials across 20+ languages and frameworks.