Subnetting & VLSM: How to Allocate IP Addresses Without Wasting Space
“Subnetting is not merely dividing IP blocks. VLSM is the art of precisely allocating address space so each interface, hotspot segment, and PTP link receives an exact allocation without a single wasted byte.”
Table of Contents
1 Why We Need Subnetting & The Problem of Wasteful IP Space
IPv4 addresses have an absolute mathematical ceiling: exactly 4,294,967,296 addresses (32-bit). In an era with billions of smartphones, IoT devices, base stations, and expanding ISP subscriber networks, address space is scarce.
Consider a residential development with 10 sectors. If the builder assigns 256 plots to every sector irrespective of actual requirements — even when one sector only needs 2 houses and another needs 50 — hundreds of plots sit abandoned and unused while others face severe shortages.
2 Core Concepts: Network ID, Broadcast ID, Host ID, and Subnet Mask
Every IPv4 address consists of two logical parts: the Network Portion (identifying the subnet boundary) and the Host Portion (identifying the specific endpoint on that subnet).
The first address in the subnet block (all host bits equal 0). It identifies the subnet itself and is referenced by router routing tables. Never assign this to an individual host device!
The last address in the subnet block (all host bits equal 1). Packets addressed here are flooded to all active nodes in the subnet. Never assign this to an individual device!
Usable Host Capacity Formula
When a subnet reserves h bits for host addresses:
The - 2 subtraction is mandatory because the very first address is reserved as the Network ID and the last address is reserved as the Broadcast ID.
3 Understanding CIDR Notation (/24, /27, /30) & Quick Reference Table
CIDR (Classless Inter-Domain Routing) superseded legacy classful networking (Class A, B, C) by using prefix notation (/n), specifying how many bits from the left belong to the Network ID.
| Prefix | Subnet Mask | Total IPs | Usable Hosts | Optimal Use Case |
|---|---|---|---|---|
| /24 | 255.255.255.0 | 256 | 254 | Large hotspot zones, main office networks |
| /25 | 255.255.255.128 | 128 | 126 | Medium WISP clusters / distribution nodes |
| /26 | 255.255.255.192 | 64 | 62 | Guest VLANs / Cafe Hotspots (up to 60 users) |
| /27 | 255.255.255.224 | 32 | 30 | Staff departments, training labs |
| /28 | 255.255.255.240 | 16 | 14 | Local server VLANs, executive suites (10-14 hosts) |
| /29 | 255.255.255.248 | 8 | 6 | CCTV camera networks, NVR management |
| /30 | 255.255.255.252 | 4 | 2 | Point-to-Point (PTP) inter-router links |
4 Traditional Subnetting (FLSM) & Its Limitations
In traditional subnetting, also known as FLSM (Fixed Length Subnet Mask), a major network is carved into subnets of identical prefix size.
For example, dividing 192.168.1.0/24 into 4 equal /26 blocks (64 addresses each):
Allocated 64 IPs (62 usable). Clean and efficient fit.
Only needs 2 IPs, but assigned 64 IPs. 60 IPs wasted completely and unavailable to other subnets!
This severe inefficiency motivated the development of VLSM.
5 VLSM (Variable Length Subnet Masking): Flexible Allocation
VLSM empowers network engineers to apply varying subnet masks across the same parent address space. Each segment receives the smallest power-of-two block size capable of accommodating its required host count.
Primary Advantages of VLSM:
- Maximum Efficiency: Conserves up to 70% address space compared to uniform FLSM carving.
- High Scalability: Leaves continuous unassigned blocks at the tail end for future VLAN or branch rollouts.
- Route Summarization: Simplifies hierarchical routing table aggregation (OSPF / BGP).
6 The VLSM Golden Rule: Order Allocations from Largest to Smallest
This is the single most essential operational rule in VLSM engineering:
A subnet with block size B must start on an integer multiple of B (e.g. a 64-block must start at .0, .64, .128, or .192). If you allocate a small subnet first (e.g. a 4-block for a PTP link starting at .0 through .3), the subsequent large 64-block cannot begin at .4 because 4 is not a multiple of 64! You would be forced to skip from .4 to .63, leaving 60 unallocated, fragmented addresses in limbo.
The Solution: Always sort segments from LARGEST host requirement to SMALLEST.
7 Step-by-Step Field Scenario (Real-World Case Study)
Let us divide a major network 192.168.1.0/24 (256 addresses) for the following 4 segments:
Needs 50 + 2 = 52 addresses. Nearest power of two is 26 = 64 addresses (/26).
• Network: 192.168.1.0/26
• Usable Hosts: 192.168.1.1 to 192.168.1.62
• Broadcast: 192.168.1.63
Needs 10 + 2 = 12 addresses. Nearest power of two is 24 = 16 addresses (/28). Starts immediately after prior broadcast (.63) at .64 (valid multiple of 16).
• Network: 192.168.1.64/28
• Usable Hosts: 192.168.1.65 to 192.168.1.78
• Broadcast: 192.168.1.79
Needs 5 + 2 = 7 addresses. Nearest power of two is 23 = 8 addresses (/29). Starts at .80 (valid multiple of 8).
• Network: 192.168.1.80/29
• Usable Hosts: 192.168.1.81 to 192.168.1.86
• Broadcast: 192.168.1.87
Needs 2 + 2 = 4 addresses. Nearest power of two is 22 = 4 addresses (/30). Starts at .88 (valid multiple of 4).
• Network: 192.168.1.88/30
• Usable Hosts: 192.168.1.89 to 192.168.1.90
• Broadcast: 192.168.1.91
View visual allocation block maps and copy RouterOS configuration scripts instantly.
8 Production Configuration on MikroTik RouterOS (Address, Pool, DHCP)
Translating the calculations above into MikroTik RouterOS CLI commands is clean and systematic:
1. Assign IP Addresses to Interfaces / VLANs
/ip address
add address=192.168.1.1/26 interface=vlan-hotspot comment="Hotspot Gateway"
add address=192.168.1.65/28 interface=vlan-office comment="Office Gateway"
add address=192.168.1.81/29 interface=vlan-cctv comment="CCTV Gateway"
add address=192.168.1.89/30 interface=ether2-ptp comment="PTP Link Gateway"
2. Configure IP Pools & DHCP Server Networks
/ip pool
add name=pool-hotspot ranges=192.168.1.2-192.168.1.62
add name=pool-office ranges=192.168.1.66-192.168.1.78
/ip dhcp-server network
add address=192.168.1.0/26 gateway=192.168.1.1 dns-server=8.8.8.8,1.1.1.1 comment="Hotspot Subnet"
add address=192.168.1.64/28 gateway=192.168.1.65 dns-server=8.8.8.8,1.1.1.1 comment="Office Subnet"
9 5 Fatal Mistakes Network Engineers Make in Subnetting
Assigning the first or last IP of a subnet (e.g. 192.168.1.63 on /26) induces severe ARP conflicts and packet drop issues.
Placing /30 at the beginning breaks boundary alignment for subsequent /26 blocks, stranding dozens of IPs in dead space.
Assigning a /24 subnet to a two-router link squanders 252 IPs. Always utilize a /30 (or /31 RFC 3021) subnet.
If segment A ends at .63 and segment B begins at .60, an overlap causes router routing tables to reject routes or produce routing loops.
If the router gateway is 192.168.1.1, the DHCP pool must start at 192.168.1.2 to prevent the router DHCP server from leasing out its own gateway address to an unsuspecting client.
Software Engineering, Network Architecture & Telecommunications Specialist. This guide helps network engineers structure efficient, zero-waste subnet topologies ready for RouterOS production deployment.