Worked examples — Routing — forwarding table, routing table
Before we start, let us re-earn the three symbols we lean on the whole page:
The scenario matrix
Think of LPM like the arctan story: the naive move ("just take the first thing that fits") breaks in specific cells, and each cell needs its own picture. Here is the full grid this topic can throw at you.
| Cell | What makes it tricky | Covered by |
|---|---|---|
| A. Plain nested match | several prefixes match, pick longest | Ex 1 |
| B. Sub-byte boundary () | the split happens inside a byte, so decimal intuition lies | Ex 2 |
| C. Only default matches | address hits nothing specific | Ex 3 |
D. Zero / degenerate: /32 host route |
prefix as long as the address itself | Ex 4 |
| E. Two prefixes, same length | LPM ties — routing table (metric/AD) must break it | Ex 5 |
| F. "Contained but not matching" | address is numerically between prefix bounds but LPM sends it elsewhere | Ex 6 |
| G. Real-world word problem | ISP + branch office, resolve next-hop to interface | Ex 7 |
| H. Exam twist: overlapping supernet vs default | /0 vs a /1, limiting behaviour of |
Ex 8 |
Each example below is tagged with its cell.

The figure above is our reading key for the whole page: a 32-bit address is a road of bits; a prefix "claims" the first of them. Longer claim = pickier = more specific = the winner.
Worked example 1 — Cell A: plain nested match
Steps:
- Turn the address' relevant bytes to bits: , , . Why this step? LPM compares bits, not decimal; we must see the bits to judge who matches.
- Test
/12: mask keeps 12 bits = first byte + top 4 bits of second. , and base = same 12 bits. Match ✓. Why? . - Test
/22: mask = 22 ones =255.255.252.0. Third byte ; keep its top 6 bits → , top 6 =000010= . So . Match ✓. Why? claims 6 of the third byte's 8 bits; and share those 6 bits. - Matches have . Largest = 22 → eth2. Why? Most specific route knows the destination best.
Worked example 2 — Cell B: the split happens inside a byte

Steps:
- Only the last byte differs between the prefixes, so focus there. .
Why this step? A
/26claims 26 bits = all of bytes 1–3 plus the top 2 bits of byte 4. The decision lives in those 2 bits. /26mask on last byte: 2 ones then 6 zeros =11000000= . So mask =255.255.255.192. Why? means ones in the fourth byte.- : . Base of
/26= . Match ✓. Why? The top two bits of are11, same as the top two bits of . /24also matches (10.1.1agrees). Lengths vs → longest = 26 → B.
Worked example 3 — Cell C: only the default matches
Steps:
- Test both
/24s: first byte matches neither nor . No match. Why this step? If even the first claimed byte disagrees, the AND-equality already fails. - Test
/0: mask = zero ones =0.0.0.0. . Match ✓. Why? ANDing with all-zeros erases everything, so any collapses to . That is why the default matches every address — see Default Gateway and 0.0.0.0/0. - Only match has → eth9.
Worked example 4 — Cell D (degenerate): a /32 host route
Steps:
/32mask = 32 ones =255.255.255.255. It claims all bits — so a/32names exactly one host, not a network. Why this step? host bits ⇒ zero-sized "network" ⇒ a single machine. This is the limiting case of "longer mask = smaller network".- Packet
10.5.5.5: . Match ✓, . Also/8matches. Longest = 32 → B. Why? A/32is the most specific possible route — nothing can out-specify it. - Packet
10.5.5.6: , so/32fails. Only/8matches → A. Why? One bit of difference ( vs ) breaks a/32because every bit is claimed.
Worked example 5 — Cell E: two prefixes, SAME length (LPM ties)
Steps:
- Note LPM sees identical for both. LPM is silent on ties. Why this step? LPM compares specificity; equal specificity means we need a different judge — this is a routing-table decision, not a forwarding one.
- The routing table applies administrative distance first: OSPF = 110, RIP = 120, lower is more trusted. OSPF wins. Why? Administrative distance ranks how much we trust the protocol — see OSPF and Link-State Routing and Distance Vector — RIP.
- Only the OSPF route is installed into the FIB → one entry per prefix, exactly as the parent note promised. Why? The data plane must be unambiguous; per-packet lookup returns one answer.
Worked example 6 — Cell F: "contained numerically" but LPM routes elsewhere
Steps:
10.1.4.250: third byte = the/24base's third byte, so/24claims bytes 1–3 =10.1.4and they agree. Match, ./16also matches. Longest = 24 → B. Why this step? The host byte is never tested by/24; only bytes 1–3 are claimed.10.1.5.9:/24claims third byte and needs it , but here it is ./24fails./16still matches (10.1). → A. Why? Being "numerically close" ( next to ) is irrelevant — LPM tests exact claimed bits, and .
Worked example 7 — Cell G: real-world word problem (next-hop resolution)

Steps:
- LPM on
142.250.72.14: not in192.168.10.0/24(first byte ). Falls to0.0.0.0/0. → next-hop203.0.113.1. Why this step? Web address is not local, so the default route (gateway of last resort) takes it. - Resolve the next-hop IP → interface:
203.0.113.1is reachable on g0/0. So the FIB entry is(0.0.0.0/0 → g0/0, next-hop 203.0.113.1). Why? The data plane needs a physical port, not an IP — this is the route-resolution step from the parent note. - Get the next-hop's MAC via ARP — Address Resolution Protocol, build the frame, ship it out g0/0. Why? Layer-2 delivery on the wire to the next hop needs its MAC; ARP maps IP→MAC. See also IP Addressing and Subnetting.
Worked example 8 — Cell H: exam twist, /0 vs /1 (limiting behaviour)
Steps:
- A
/1claims exactly one bit: the top bit of the first byte. Base0.0.0.0/1= top bit ; base128.0.0.0/1= top bit (since ). Why this step? ⇒ mask =128.0.0.0. This partitions all addresses into "top bit 0" and "top bit 1". 10.0.0.0: , top bit → matches/1A (and/0C). Longest = 1 → A. Why? Any beats the default.200.0.0.0: , top bit → matches/1B (and/0C). Longest = 1 → B. Why? Same rule, other half.- Because the two
/1s together cover every address, the/0default (C) is never the longest match here — it is dead code. Why? is the smallest possible length; it only wins when nothing longer matches, and something longer always does now. This is the limiting behaviour of .
Recall Rapid re-check across all cells
Default matches every address because ::: ANDing with the all-zero mask collapses any to , which equals the prefix.
A /32 route names ::: exactly one host (0 host bits), the most specific match possible.
LPM ties (same ) are broken by ::: the routing table using administrative distance, then metric.
/25 splits the last byte at ::: 128 — you compare only the top bit(s) of that byte, not the whole decimal value.
When two /1 routes exist, the /0 default is ::: never the longest match (it becomes unreachable).
🇮🇳 Prefer Hinglish? 4.3.13 Routing — forwarding table, routing table (Hinglish)