PracticeVideosBlogFlashcards

3.2 IPv4 Subnetting, CIDR, and VLSM

Key Takeaways

  • A prefix length counts network bits; a mask uses contiguous leading ones.

  • Conventional LAN host counts use 2^h−2, while /31 point-to-point and /32 host routes have different semantics.

  • VLSM assigns differently sized non-overlapping subnets from a parent block.

  • A valid exact summary must cover the intended components and begin on its own binary boundary.

  • Four /24s from 10.24.4.0 through 10.24.7.0 summarize exactly as 10.24.4.0/22.

Last updated: October 2026

3.2 IPv4 Subnetting, CIDR, and VLSM

Quick Answer: Subnetting divides a larger network into smaller, manageable subnets by borrowing host bits for the network portion. Classless Inter-Domain Routing (CIDR) uses prefix notation (/n) to indicate how many bits represent the network prefix. The number of created subnets equals 2s2^s (where ss is borrowed bits), while usable hosts per subnet equals 2h−22^h - 2 (where hh is remaining host bits). Specialized prefixes include /30 (traditional point-to-point links with 2 usable hosts), /31 (RFC 3021 point-to-point links with 2 usable hosts and zero waste), and /32 (host routes for Nokia SR OS system interfaces). Variable Length Subnet Masking (VLSM) matches subnet mask sizes to actual host counts.

As internetworking expanded, the rigid boundaries of classful addressing led to severe address inefficiency. A company needing 300 host addresses was forced to request a Class B block (65,534 host addresses), wasting over 65,000 addresses. Conversely, assigning a Class C block provided only 254 addresses, insufficient for their needs. To solve this scalability crisis, the networking industry introduced Subnetting (RFC 950) and Classless Inter-Domain Routing (CIDR) (RFC 1519).


Subnet Masks and Classless Inter-Domain Routing (CIDR)

A subnet mask is a 32-bit value that informs network devices which portion of an IP address represents the network (and subnet) identifier and which portion represents the host identifier.

Binary Anatomy of a Subnet Mask

A valid subnet mask consists of a contiguous string of binary 1s followed by a contiguous string of binary 0s:

  • The binary 1s designate the network and subnet portion.
  • The binary 0s designate the host portion.
  • A mask cannot have alternating or interleaved 1s and 0s (such as 11111111.11110000.11111111.00000000, which is invalid).

The Bitwise AND Operation

When a router (such as a Nokia 7750 SR) receives an IP packet, its forwarding silicon extracts the destination IP address and performs a bitwise logical AND operation with the configured subnet mask to determine the destination network address. In a bitwise AND operation, the result is 1 only if both corresponding input bits are 1; otherwise, the result is 0:

Destination IP:   192.168.10.75   -> 11000000.10101000.00001010.01001011
Subnet Mask (/26): 255.255.255.192 -> 11111111.11111111.11111111.11000000
Bitwise AND Result:                -> 11000000.10101000.00001010.01000000
Network Address:  192.168.10.64

CIDR Prefix Notation

Rather than typing out long dotted-decimal masks like 255.255.255.224, CIDR introduces prefix notation (or slash notation). The prefix length /n specifies the exact number of contiguous high-order bits set to binary 1 in the mask. For instance:

  • /24 represents 24 ones: 255.255.255.0
  • /26 represents 26 ones: 255.255.255.192
  • /28 represents 28 ones: 255.255.255.240

CIDR also allowed route aggregation (supernetting), collapsing multiple contiguous Class C network prefixes into a single BGP route announcement (such as advertising sixteen /24 prefixes as a single /20 route), preventing global Internet routing tables from exploding.


Subnetting Mathematical Formulas

To compute subnet quantities and host capacities accurately, memorize two fundamental mathematical formulas:

1. Number of Subnets Created

Number of Subnets=2s\text{Number of Subnets} = 2^s

Where ss is the number of bits borrowed from the host field of the default classful mask or previous parent prefix.

2. Number of Usable Host Addresses per Subnet

Usable Hosts per Subnet=2h−2\text{Usable Hosts per Subnet} = 2^h - 2

Where hh is the number of remaining host bits (calculated as 32−prefix length32 - \text{prefix length}). The subtraction of 2 accounts for the two non-assignable addresses in any standard subnet:

  1. The Network Address (all host bits 0).
  2. The Directed Broadcast Address (all host bits 1).

Common Prefixes Reference Table (/24 to /32)

PrefixSubnet MaskHost Bits (hh)Total IPs (2h2^h)Usable Hosts (2h−22^h - 2)Magic Number (Block Size)Primary Use Case
/24255.255.255.08256254256 (256−0256 - 0)Standard LAN segment
/25255.255.255.1287128126128 (256−128256 - 128)Mid-size department LAN
/26255.255.255.1926646264 (256−192256 - 192)Medium user subnet
/27255.255.255.2245323032 (256−224256 - 224)Small office / branch
/28255.255.255.2404161416 (256−240256 - 240)Server cluster, DMZ subnet
/29255.255.255.2483868 (256−248256 - 248)Firewall / router transit link
/30255.255.255.2522424 (256−252256 - 252)Traditional point-to-point link
/31255.255.255.254122 (RFC 3021)2 (256−254256 - 254)Router point-to-point link
/32255.255.255.2550111 (256−255256 - 255)Host route, Loopback/System IP

Step-by-Step Subnet Calculation: The Magic Number Method

In certification exams like Nokia NRS I, calculating subnets mentally within 30 to 45 seconds is crucial. The fastest, most reliable technique is the Magic Number (Block Size) method.

The Four-Step Process

  1. Identify the Interesting Octet: Locate the octet in the subnet mask that contains a value other than 255 or 0.
  2. Calculate the Magic Number: Subtract the decimal value of the interesting octet from 256:
Magic Number=256−Mask Value of Interesting Octet\text{Magic Number} = 256 - \text{Mask Value of Interesting Octet}
  1. Determine the Network Address: Count upwards in multiples of the magic number (starting at 0, then magic number, 2×magic number2 \times \text{magic number}, etc.) until reaching the highest multiple that is less than or equal to the IP address value in that octet.
  2. Calculate Host Boundaries:
    • First Usable Host: Network Address +1+ 1.
    • Next Network Address: Current Network Address ++ Magic Number.
    • Directed Broadcast Address: Next Network Address −1- 1.
    • Last Usable Host: Directed Broadcast Address −1- 1.

Worked Example 1: 192.168.10.138/27

  • Target IP and Mask: 192.168.10.138 with /27 (255.255.255.224).
  • Interesting Octet: The fourth octet (224).
  • Magic Number: 256−224=32256 - 224 = 32.
  • Multiples of 32: 0, 32, 64, 96, 128, 160, 192, 224.
  • The fourth octet value is 138, which falls between 128 and 160.
  • Network Address: 192.168.10.128.
  • First Usable Host: 192.168.10.129.
  • Next Network Address: 192.168.10.160.
  • Directed Broadcast Address: 192.168.10.159 (160−1160 - 1).
  • Last Usable Host: 192.168.10.158 (159−1159 - 1).
  • Total Usable Hosts: 25−2=302^5 - 2 = 30.

Worked Example 2: 172.16.45.60/22

  • Target IP and Mask: 172.16.45.60 with /22 (255.255.252.0).
  • Interesting Octet: The third octet (252). The fourth octet mask value is 0, meaning all fourth-octet host bits can vary from 0 to 255.
  • Magic Number: 256−252=4256 - 252 = 4 in the third octet.
  • Multiples of 4: 0, 4, 8, ..., 36, 40, 44, 48.
  • The third octet value is 45, which falls between 44 and 48.
  • Network Address: 172.16.44.0.
  • First Usable Host: 172.16.44.1.
  • Next Network Address: 172.16.48.0.
  • Directed Broadcast Address: 172.16.47.255 (172.16.48.0−1172.16.48.0 - 1).
  • Last Usable Host: 172.16.47.254.
  • Total Usable Hosts: 210−2=1024−2=10222^{10} - 2 = 1024 - 2 = 1022.

Specialized Prefix Lengths in Service Provider Networks

In Nokia Service Router topologies and enterprise WAN designs, engineers encounter three specialized prefix lengths that diverge from standard user LAN requirements:

1. /30 Prefixes (Traditional Point-to-Point Links)

A /30 subnet mask is 255.255.255.252, leaving 2 host bits (22=42^2 = 4 total addresses). Subtracting 2 gives exactly 2 usable host addresses:

  • For example, in 10.1.1.0/30:
    • Network address: 10.1.1.0
    • Router A interface: 10.1.1.1
    • Router B interface: 10.1.1.2
    • Directed broadcast: 10.1.1.3
  • The Inefficiency Problem: A /30 wastes 50% of the allocated addresses (2 out of 4 addresses are consumed by network and broadcast overhead). In large telecommunications networks with tens of thousands of point-to-point links, this waste consumes significant IPv4 address space.

2. /31 Prefixes (RFC 3021 Point-to-Point Links)

To resolve /30 address waste, RFC 3021 (Using 31-Bit Prefixes on IPv4 Point-to-Point Links) was published:

  • A /31 subnet mask is 255.255.255.254, leaving 1 host bit (21=22^1 = 2 total addresses).
  • On a dedicated point-to-point link connecting exactly two routers, there are no other hosts to hear broadcasts, nor is there any ambiguity about destination routing.
  • Under RFC 3021, both addresses are usable as unicast host addresses: the address with host bit 0 is assigned to one router endpoint, and the address with host bit 1 is assigned to the opposite router endpoint.
  • There is no dedicated network address and no directed broadcast address.
  • For example, in 10.1.1.0/31, Router A receives 10.1.1.0 and Router B receives 10.1.1.1.
  • Nokia SR OS Support: Nokia 7750 SR and 7705 SAR support /31 addressing on appropriate point-to-point interfaces; check the selected platform and release. Both addresses are usable under RFC 3021.

3. /32 Prefixes (Host Routes and System Interfaces)

A /32 subnet mask is 255.255.255.255, leaving 0 host bits (20=12^0 = 1 address).

  • A /32 specifies a single host without any subnet broadcast or network address overhead.
  • In Nokia SR OS, every router is configured with a logical loopback interface designated as the system interface (interface "system").
  • The system interface is assigned a /32 IPv4 address.
  • Because the system interface is logical and never tied to the physical state of any individual Ethernet port or MDA, it is independent of an individual physical port, subject to the router and interface’s own operational conditions. It is commonly used as the router's BGP Router ID, OSPF Router ID, LDP Transport Address, and management endpoint.

Variable Length Subnet Masking (VLSM) Design Principles

Under Fixed Length Subnet Masking (FLSM), every subnet in an organization uses the identical subnet mask. If the largest department requires 100 hosts, every subnet must be allocated a /25 (126 usable hosts)—even a point-to-point link that only needs 2 addresses, wasting 124 addresses per link.

Variable Length Subnet Masking (VLSM) allows engineers to apply different subnet masks across subnets carved from the same major network block, matching the prefix size directly to the specific host requirement of each segment.

The Golden Rule of VLSM Allocation

When designing a VLSM scheme from a parent address block, allocating the largest required blocks first is a useful planning method.

Allocating the largest subnets first ensures that large blocks align naturally on valid binary power-of-two boundaries, preventing address overlap and fragmentation.

Practical VLSM Allocation Scenario

An engineer must subnet the private block 192.168.1.0/24 to satisfy the following requirements:

  1. Engineering LAN: 50 hosts
  2. Sales LAN: 25 hosts
  3. Support LAN: 12 hosts
  4. WAN Link 1: 2 router interfaces
  5. WAN Link 2: 2 router interfaces

Step-by-Step Allocation:

  1. Engineering LAN (50 hosts):

    • Formula: 2h−2≥50→h=62^h - 2 \ge 50 \rightarrow h = 6 (26−2=622^6 - 2 = 62 usable hosts).
    • Prefix length: 32−6=/2632 - 6 = /26 (block size 64).
    • Subnet allocated: 192.168.1.0/26 (Range: .0 to .63, usable .1–.62, broadcast .63).
  2. Sales LAN (25 hosts):

    • Formula: 2h−2≥25→h=52^h - 2 \ge 25 \rightarrow h = 5 (25−2=302^5 - 2 = 30 usable hosts).
    • Prefix length: 32−5=/2732 - 5 = /27 (block size 32).
    • Next available boundary: .64.
    • Subnet allocated: 192.168.1.64/27 (Range: .64 to .95, usable .65–.94, broadcast .95).
  3. Support LAN (12 hosts):

    • Formula: 2h−2≥12→h=42^h - 2 \ge 12 \rightarrow h = 4 (24−2=142^4 - 2 = 14 usable hosts).
    • Prefix length: 32−4=/2832 - 4 = /28 (block size 16).
    • Next available boundary: .96.
    • Subnet allocated: 192.168.1.96/28 (Range: .96 to .111, usable .97–.110, broadcast .111).
  4. WAN Link 1 (2 hosts):

    • Formula: 2h−2≥2→h=22^h - 2 \ge 2 \rightarrow h = 2 (22−2=22^2 - 2 = 2 usable hosts) using /30 (or /31).
    • Prefix length: /30 (block size 4).
    • Next available boundary: .112.
    • Subnet allocated: 192.168.1.112/30 (Range: .112 to .115, usable .113–.114, broadcast .115).
  5. WAN Link 2 (2 hosts):

    • Prefix length: /30 (block size 4).
    • Next available boundary: .116.
    • Subnet allocated: 192.168.1.116/30 (Range: .116 to .119, usable .117–.118, broadcast .119).
  6. Unassigned Address Space for Future Growth:

    • Addresses 192.168.1.120 through 192.168.1.127 (one unallocated /29).
    • Addresses 192.168.1.128 through 192.168.1.255 (one unallocated /25 block supporting 126 additional hosts).

Through VLSM, all five network segments are fully accommodated with zero address overlap, leaving 136 of the original 256 addresses unallocated for growth.

Worked route summarization

A correct summary contains the intended component prefixes and begins on its own binary boundary. Contiguous addresses alone are not enough.

The four /24s 10.24.4.0/24, 10.24.5.0/24, 10.24.6.0/24, and 10.24.7.0/24 form exactly 10.24.4.0/22. Their third octets are 00000100 through 00000111: the first six bits agree, which together with the first sixteen address bits gives /22. The summary spans 10.24.4.0 through 10.24.7.255, or 1,024 addresses.

By contrast, 10.24.5.0/24 and 10.24.6.0/24 do not form an exact /23. Valid /23 boundaries have even third octets. Their smallest single covering prefix is 10.24.4.0/22, which also includes the .4 and .7 networks. Either advertise the two specifics or explicitly accept that additional coverage and provide suitable discard handling for holes.

A summary reduces advertisements; it does not create reachability to every address it covers. Check the summary boundary, component coverage, overlap, and forwarding action for absent components.

Primary technical reference

Specification or Nokia manual, checked October 20, 2026. Examples are teaching scenarios, not captured router execution.

Test Your Knowledge

A network engineer configures a Nokia 7750 SR router interface with the IP address 10.50.180.75/21. What are the network address, directed broadcast address, and first usable host address for this subnet?

A

Network: 10.50.180.0, Broadcast: 10.50.187.255, First Usable: 10.50.180.1

B

Network: 10.50.176.0, Broadcast: 10.50.183.255, First Usable: 10.50.176.1

C

Network: 10.50.176.0, Broadcast: 10.50.180.255, First Usable: 10.50.176.1

D

Network: 10.50.180.0, Broadcast: 10.50.183.255, First Usable: 10.50.180.1

Test Your Knowledge

Under RFC 3021, how does a /31 subnet mask function on a point-to-point Ethernet link between two Nokia Service Routers?

A

It provides exactly 2 usable host addresses without allocating dedicated network or broadcast addresses

B

It provides 4 total addresses with 2 usable host addresses and 2 reserved addresses

C

It creates a single host address dedicated strictly to router system loopback interfaces

D

It is unsupported on Ethernet interfaces and can only be used on serial or ATM links

Test Your Knowledge

In Nokia SR OS, what is the standard subnet mask prefix assigned to the logical system interface, and what is its primary operational role?

A

A /30 prefix, providing a point-to-point management tunnel to adjacent routers

B

A /24 prefix, providing a local broadcast subnet for out-of-band management traffic

C

A /32 prefix, creating a unique loopback host route used as the router ID and signaling endpoint

D

A /31 prefix, conserving public IP address space for inter-chassis failover links

Sections you finish are checked off in the contents.