Intuition Why a whole page of examples?
The parent note told you the ideas . This page makes you run the machinery by hand for every kind of situation an exam or a real network can throw at you. Before each answer you will forecast — guess first, then check. Getting a guess wrong is where the learning happens.
Every routing problem you will meet falls into one of these cells . We enumerate them once, then hit each one with a worked example.
#
Cell (case class)
What makes it tricky
Example
A
Basic two-router static, both directions
forgetting the return route
Ex 1
B
Default route 0.0.0.0/0 (shortest prefix)
catch-all vs specific
Ex 2
C
Longest-prefix tie-break (overlapping routes)
two rows both match
Ex 3
D
Bellman–Ford pick with a cheap link but expensive path
link cost ≠ path cost
Ex 4
E
Degenerate input: destination = a directly connected network
do we even need a static route?
Ex 5
F
Zero / limiting case: a link fails (cost → ∞)
how each style reacts
Ex 6
G
Convergence-time / counting-to-infinity limiting behaviour
why loops form
Ex 7
H
Real-world word problem (which style to choose + why)
trade-off judgement
Ex 8
I
Exam twist: "ping works one way" debugging
asymmetric routing bug
Ex 9
Terms used below — all built in the parent — link back: Routing table , Longest prefix match , Default gateway , Bellman-Ford algorithm , Dijkstra's algorithm , Network convergence , RIP protocol , OSPF protocol , BGP .
Worked example Ex 1 — Teach two routers to reach each other
Topology: PC-A (192.168.1.0/24) — R1 — (10.0.0.0/30) — R2 — PC-B (192.168.2.0/24).
R2's link IP is 10.0.0.2, R1's is 10.0.0.1. Write the static routes so PC-A can ping PC-B and get a reply.
Forecast: How many ip route lines total? Guess before reading.
R1 must reach 192.168.2.0/24. The next hop is R2's near-side IP, 10.0.0.2.
ip route 192.168.2.0 255.255.255.0 10.0.0.2
Why this step? R1 only knows its directly connected networks (192.168.1.0/24 and 10.0.0.0/30). PC-B's network is two hops away; R1 has no automatic way to learn it, so we hand it the next hop.
R2 must reach 192.168.1.0/24 — the return path.
ip route 192.168.1.0 255.255.255.0 10.0.0.1
Why this step? The reply packet (PC-B → PC-A) is a separate journey . R2 needs its own instruction or the reply dies. Routing is per-direction .
Answer: 2 lines.
Verify: Trace both directions. Request: PC-A → R1 (uses line 1) → R2 → PC-B ✅. Reply: PC-B → R2 (uses line 2) → R1 → PC-A ✅. Both halves have a route ⇒ ping succeeds.
Worked example Ex 2 — A stub router toward the ISP
R1 connects to exactly one upstream router at 10.0.0.2 and to nothing else. It must reach the entire internet . Write one route.
Forecast: Which prefix length catches "everything"? /0, /8, or /24?
Use the default route 0.0.0.0/0.
ip route 0.0.0.0 0.0.0.0 10.0.0.2
Why this step? /0 means zero bits must match — every destination matches it. It is the broadest possible net.
Because Longest prefix match always prefers the longest (most specific) matching prefix, and /0 is the shortest, the default is used only when nothing more specific matches .
Why this step? This guarantees the catch-all never overrides a real, specific route — it's a safety net at the bottom of the priority ladder.
Answer: one line, prefix 0.0.0.0/0.
Verify: Prefix length = 0 bits ⇒ mask 0.0.0.0. Since 0 < any other prefix length, in any tie it loses to a specific route — exactly the "used only as last resort" behaviour we wanted.
Worked example Ex 3 — Two rows both match: which wins?
R1's Routing table contains:
192.168.0.0/16 → next hop 10.0.0.2
192.168.5.0/24 → next hop 10.0.0.6
A packet arrives for 192.168.5.130. Which next hop?
Forecast: The /16 or the /24?
Convert to binary and count matching leading bits. 192.168 is 11000000.10101000. Both rows' first 16 bits equal the packet's — both match .
Why this step? A packet can match many rows at once; we need a rule to break the tie.
Compare prefix lengths : /24 > /16. Look at the figure — the /24 (green) is a tighter box fully inside the /16 (blue) box, and the packet dot sits in the green box.
Why this step? Longest prefix = most specific = "closest tailored instruction". A more specific route reflects more precise knowledge, so it wins.
Winner: 192.168.5.0/24 , next hop 10.0.0.6.
Verify: 192.168.5.130 in binary third octet is 5 = 00000101; it lies in 192.168.5.0/24 (bits 17–24 fixed to 00000101) ✅, and also inside 192.168.0.0/16 ✅. Two matches, longest (24) chosen. Answer next hop 10.0.0.6 .
Worked example Ex 4 — When the cheaper link is NOT the best route
Node X reaches destination Z through two neighbours.
Link X→A costs 1 ; A advertises D A ( Z ) = 6 .
Link X→B costs 3 ; B advertises D B ( Z ) = 1 .
Which neighbour does the Bellman–Ford update pick as next hop for Z?
Forecast: The cheap link (A, cost 1) or the cheap-advertiser (B, cost 1)? Trap here.
Apply D x ( d ) = min v ( c ( x , v ) + D v ( d ) ) for each neighbour.
Why this step? The best whole path is "first hop cost + neighbour's best remaining cost", minimised over neighbours — the parent's Bellman–Ford core.
via A: 1 + 6 = 7 . via B: 3 + 1 = 4 .
Why this step? We must add link and advertised cost; neither number alone tells the truth.
D X ( Z ) = min ( 7 , 4 ) = 4 , next hop B .
Why this step? Even though the link to A is cheaper (1 vs 3), A's onward journey is long (6). The total is king.
Answer: cost 4 , next hop B .
Verify: min ( 1 + 6 , 3 + 1 ) = min ( 7 , 4 ) = 4 ✅. The trap (picking A because its link is cheapest) gives 7, worse — confirming path cost ≠ link cost.
Worked example Ex 5 — Do we need a static route to our own doorstep?
R1 has interface Gi0/0 with IP 192.168.1.1/24. A packet arrives for 192.168.1.50. Do we need an ip route line for 192.168.1.0/24?
Forecast: Yes / No?
192.168.1.0/24 is a directly connected network — it appears in the routing table automatically the moment the interface is up (marked C for connected).
Why this step? A router knows by wire the networks its own interfaces sit on; nobody has to teach it those.
So a manual static route for it is redundant — and worse, if you point it at a next hop it can loop.
Why this step? Degenerate inputs (destination = your own subnet) already have the best possible route (metric 0, directly attached).
Answer: No — directly connected networks are auto-installed.
Verify: Cost to a directly connected network = 0 hops; any static route (≥1 hop away) is strictly worse and unnecessary. Router keeps the connected route.
Worked example Ex 6 — R1↔R2 link dies. What happens under static vs dynamic?
Same topology as Ex 1. The 10.0.0.0/30 link between R1 and R2 goes down . Compare behaviour.
Forecast: Which style keeps trying to use the dead route, and for how long?
Static: R1's ip route 192.168.2.0 ... 10.0.0.2 line is still in the table (or drops only if the interface itself went down). It has no alternative and no way to learn one.
Why this step? Static routes are frozen — the admin must intervene. Fault tolerance = zero.
Dynamic: neighbouring routers stop hearing updates over the dead link; after the protocol's timers expire they mark that route unreachable (cost → ∞ ) and recompute over any surviving path. See the figure: the red X kills the direct link, green shows the recomputed detour.
Why this step? Setting a failed link's cost to ∞ in min v ( c ( x , v ) + D v ( d )) forces the min to pick a different neighbour automatically — self-healing.
The time for all routers to agree on the new table is the convergence time.
Answer: Static = broken until human fixes it. Dynamic = recovers automatically after convergence.
Verify: In Bellman–Ford, a dead link ⇒ c ( x , v ) = ∞ ⇒ that term = ∞ ⇒ excluded by min ⇒ next best neighbour chosen, provided one exists. Static has no min , so no recovery.
Worked example Ex 7 — Why distance-vector can loop after a failure
A—B—Z in a line. B reaches Z at cost 1. The B↔Z link fails. Trace A and B's beliefs over the next few update rounds (link A↔B cost 1).
Forecast: Does B instantly know Z is gone?
B loses its link to Z, so B looks for another route. It still hears A advertising "I can reach Z at cost 2" (A learned that through B moments ago — stale info).
Why this step? RIP neighbours don't know whose path an advertisement is built on; A's cost 2 secretly runs back through B.
B believes A: D B ( Z ) = c ( B , A ) + D A ( Z ) = 1 + 2 = 3 . Then A hears B's new 3 and updates to 1 + 3 = 4 . Then B → 5, A → 6 …
Why this step? Each round the cost creeps up by 1 — "counting to infinity" — until it hits RIP's ceiling (16 = unreachable).
This is the limiting behaviour that makes convergence slow. Fixes: split-horizon, poison reverse, max-hop cap.
Answer: B does not instantly know; the cost climbs 3 , 4 , 5 , … until 16.
Verify: Rounds give D B ( Z ) : 3 , 5 , 7 , … and D A ( Z ) : 2 , 4 , 6 , … (each side + 2 every two updates), reaching RIP's infinity = 16 after finitely many steps ⇒ eventually declared unreachable ✅.
Worked example Ex 8 — A dentist's office network
A small clinic has 1 router, 1 switch, 1 internet uplink , no redundant links, and an admin who visits monthly. Static or dynamic?
Forecast: Which and why — name at least two reasons.
Count the routing decisions: essentially one — "everything not local → the ISP". A single default route suffices.
Why this step? If the whole table is one line, a protocol's continuous chatter buys nothing.
Weigh the trade-off (parent's mnemonic): no redundant links ⇒ nothing to reroute to , so dynamic's self-healing is useless here. Static gives zero bandwidth/CPU overhead and a smaller attack surface.
Why this step? Match the tool to the scale — adaptivity you can't use is pure cost.
Answer: Static (one default route). Reasons: single exit, no redundancy to exploit, zero overhead, more secure.
Verify: Trade-off table logic: Static wins on simplicity/security/overhead; loses only on fault tolerance — which is irrelevant with no alternate path. Correct choice ✅.
Worked example Ex 9 — Debugging asymmetric routing
An admin configures only ip route 192.168.2.0 255.255.255.0 10.0.0.2 on R1 (Ex 1 topology) and forgets R2. ping from PC-A to PC-B times out . Where is the packet lost?
Forecast: Does the request even reach PC-B?
Request path PC-A → R1 → R2 → PC-B: R1 has the route ⇒ the ICMP echo arrives at PC-B. So far so good.
Why this step? Only the forward direction was configured, so only the forward direction works.
Reply path PC-B → R2 → ? : R2 has no route to 192.168.1.0/24. It drops the echo-reply.
Why this step? This is the classic asymmetry bug — half the round trip has no return route.
Fix: add ip route 192.168.1.0 255.255.255.0 10.0.0.1 on R2.
Answer: Lost at R2 on the way back — the reply has nowhere to go.
Verify: Forward has a route (reaches PC-B); return has none (dropped at R2). Symptom "request delivered, reply lost ⇒ timeout" matches exactly ✅. Adding the return route fixes it (see Ex 1).
Recall Quick self-test
Two routes 10.0.0.0/8 and 10.1.0.0/16 both match a packet — which wins? ::: The /16 (longest prefix).
Link cost 1 to A (A advertises 9) vs link cost 5 to B (B advertises 2) — best cost and next hop? ::: min ( 1 + 9 , 5 + 2 ) = min ( 10 , 7 ) = 7 , next hop B .
A directly connected subnet needs which static route? ::: None — it's auto-installed as connected.
After a link fails, static routing recovers how? ::: It doesn't — a human must reconfigure.
Mnemonic The one-line takeaway
"Match on the longest prefix, cost on the whole path, recover only if the protocol is dynamic."
Two matching routes /16 and /24 — which is used? The /24, by longest-prefix match.
Bellman–Ford with link 1 to A (adv 6) and link 3 to B (adv 1) — cost and next hop? min(7,4)=4, next hop B.
Do you need a static route for a directly connected subnet? No — it's installed automatically as a connected route.
Under static routing, what happens when a link fails? Nothing recovers automatically; admin must fix it manually.
What is counting-to-infinity? Distance-vector routers slowly increment a dead route's cost via stale advertisements until it hits the max (16 in RIP).
"Ping works one way, reply times out" — likely cause? Missing return route on the far router (asymmetric static config).
Why is a one-router clinic best served by static routing? Single exit, no redundancy to reroute to, zero overhead, more secure.