IP

VLSM and CIDR

Variable Length Subnet Masking and Classless Inter-Domain Routing techniques.

Fixed-size subnetting and address waste

In the previous topic on subnetting, we learned how to divide a large network block into smaller, more manageable subnets. This was a clear step beyond rigid classful addressing, but it retained a limitation: all the created subnets had to be the same size.

Consider a company parking lot in which every space is large enough for a bus. That size is suitable for the company bus, but wastes space when the lot serves employee cars, motorcycles, and delivery vans. Fixed-size subnets create a similar mismatch between capacity and actual demand.

This is the issue we face in networks. A point-to-point link between two routers only needs two usable IP addresses, yet with fixed-size subnetting, we might be forced to allocate a subnet with 30, 62, or even more addresses, wasting the rest. This inefficiency contributed to the rapid depletion of IPv4 addresses. Two related techniques address the problem: VLSM for internal network efficiency and CIDR for global Internet scalability. Point-to-point links can also use a /31 prefix, where both addresses are host addresses and no broadcast address is present. This example uses /30 to retain the conventional network and broadcast addresses.

VLSM: Variable Length Subnet Masking

is a technique for dividing one subnet into smaller subnets. It removes the limitation of having one subnet mask for the entire network. VLSM allows a large block of addresses to be divided into several medium-sized subnets, with one of them divided further into smaller ones.

The same relation can be shown with a planned office building: the entire building represents the main network block, floors represent large subnets, and one floor can be divided into spaces of different sizes: a large open-plan area for the sales team, medium-sized offices for managers, and a small closet for network equipment. Each space can then be allocated according to its purpose, reducing wasted area.

Classless routing is required for VLSM

VLSM requires the network to use a classless routing protocol that carries the subnet mask or prefix length in its updates. The update must carry that prefix length for every route.

  • Classful Protocols (e.g., RIPv1, IGRP): These older protocols do notsend the subnet mask along with the IP address in their routing updates. They assume a default classful mask (e.g., /24 for a Class C address). Because they don't know the mask, they cannot understand that 192.168.10.64/26 and 192.168.10.128/27 are different, valid subnets of the same parent network.
  • Classless Protocols (e.g., RIPv2, OSPF, EIGRP): These modern protocols do include the subnet mask (or prefix length) with the IP address in their updates. This allows routers to have an unambiguous understanding of the network structure, regardless of how it has been subnetted with VLSM.

Example: Designing a network with VLSM

The following example applies VLSM to an organization given the Class C network block 203.0.113.0/24. It needs four subnets with the following host requirements:

  • Network A (Engineering): 100 hosts
  • Network B (Sales): 50 hosts
  • Network C (WAN Link 1): 2 hosts
  • Network D (WAN Link 2): 2 hosts

VLSM allocation order: start with the largest requirement

Allocate the largest subnets first to keep the remaining address space contiguous. The remaining blocks can then be divided for smaller needs.

Step 1: Network A (Engineering) - 100 hosts

We need space for 100 hosts. We use the formula 2H−2≥required hosts2^H - 2 \ge \text{required hosts} to find the number of host bits (HH) needed. 26−2=622^6-2=62 is too small. 27−2=1262^7-2=126 is sufficient. So, we need 7 host bits.
The prefix length is 32−7=2532 - 7 = 25. The mask is /25, or 255.255.255.128.
We allocate the first available block: 203.0.113.0/25.

  • Network Address: 203.0.113.0
  • Host Range: 203.0.113.1 to 203.0.113.126
  • Broadcast: 203.0.113.127

Step 2: Network B (Sales) - 50 hosts

We need space for 50 hosts. 25−2=302^5-2=30 is too small. 26−2=622^6-2=62 is sufficient. So, we need 6 host bits.
The prefix length is 32−6=2632 - 6 = 26. The mask is /26, or 255.255.255.192.
The first subnet used up to .127, so the next available address is .128. We allocate: 203.0.113.128/26.

  • Network Address: 203.0.113.128
  • Host Range: 203.0.113.129 to 203.0.113.190
  • Broadcast: 203.0.113.191

Step 3 and 4: WAN Links C and D - 2 hosts each

We need 2 hosts for each point-to-point link. 22−2=22^2-2=2 matches the requirement. So, we need 2 host bits.
The prefix length is 32−2=3032 - 2 = 30. The mask is /30, or 255.255.255.252.
The last used address was .191. We allocate the next two available /30 blocks.

  • Network C: 203.0.113.192/30
    (Network: .192, Hosts: .193, .194, Broadcast: .195)
  • Network D: 203.0.113.196/30
    (Network: .196, Hosts: .197, .198, Broadcast: .199)

Conclusion of VLSM

With VLSM, each subnet is sized for its requirement, using addresses from .0 to .199 of the /24 block. All requirements are covered, while the block from 203.0.113.200 to 203.0.113.255 remains available for future expansion. This reduces waste compared with using one fixed mask for all subnets.

CIDR: Classless Inter-Domain Routing

VLSM addressed wasted address space within an organization's network. The Internet faced a larger scaling problem: classful allocation caused global routing tables to grow rapidly, increasing the load on routers in the Internet backbone.

was introduced to address this problem. CIDR applies variable-length prefixes to inter-domain address allocation and routing. It has two results:

  1. It makes Class A, B, and C boundaries irrelevant to routing. Under CIDR, an IP address block is defined by its address and prefix length (e.g., 198.51.100.0/22). Classless routing protocols carry that prefix length so routers can interpret the block correctly.
  2. It enables Route Summarization (or Aggregation). This helps manage the size of the global routing table.

CIDR and route summarization

Route summarization, also known as aggregation or supernetting, is the process of combining several smaller, contiguous network routes into a single, larger summary route.

Analogy:A central postal sorting office in New York would need a separate mail bin for every street in London without summarization. The list would be very long. With summarization, it needs one large bin labeled "All Mail for London." After the container arrives in London, a local sorting office handles the detailed sorting by street. CIDR applies the same principle to routing by advertising one general route for a large address block instead of many specific routes.

Example: Summarizing Four Networks

An Internet Service Provider (ISP) serves four customers, giving each a /24 block of addresses:

  • 198.51.100.0/24
  • 198.51.101.0/24
  • 198.51.102.0/24
  • 198.51.103.0/24

Without CIDR, the ISP would have to announce four separate routes to the rest of the internet. With CIDR, we can summarize them.

Step 1: Convert to Binary

We focus on the third octet, which is where the addresses differ:

  • 100 → 01100100
  • 101 → 01100101
  • 102 → 01100110
  • 103 → 01100111

Step 2: Find the Common Prefix

We look for the number of bits that are identical from left to right for all addresses.

01100100
01100101
01100110
01100111

The first 6 bits of the third octet are common to all four networks.

Step 3: Calculate the Summary Route

The first two octets were already part of the common prefix (16 bits). We add the 6 common bits from the third octet.
Total common bits (new prefix length) = 16+6=2216 + 6 = 22.
The summary address is the first address in the block with the new, shorter prefix: 198.51.100.0/22.

The Result

With CIDR, the ISP advertises only one route (198.51.100.0/22) to the rest of the Internet instead of four. Route aggregation by many ISPs reduces the number of entries that must be carried in global routing tables.

Related articles