Course overviewTopic 12 / 31
Computer Networks • Deep Lesson 12 min Network Layer: IP & Routing

Routing Tables, Default Gateways & Longest-Prefix Match

Routers do not ask 'which route seems generally closest?' They compare the destination IP against candidate prefixes and choose the most specific matching route, called longest-prefix match. The selected route then determines the next hop or outgoing interface.

LEARNING LOOPWatch→Read→Inspect→Retrieve→Teach back
Routing Tables, Default Gateways & Longest-Prefix Match
Week 2–3 · Topic 12 / 31
Visual model

Watch the structure first. Then read the technical details.

0.0.0.0/0 → ISP
10.0.0.0/8 → R1
10.20.0.0/16 → R2
10.20.30.0/24 → R3 ✓
Article companion· Week 2–3

Routers do not ask 'which route seems generally closest?' They compare the destination IP against candidate prefixes and choose the most specific matching route, called longest-prefix match. The selected route then determines the next hop or outgoing interface.

01

Route anatomy

A route commonly contains a destination prefix and mask, a next hop or directly connected interface, and metadata such as administrative distance or metric depending on the routing system.

02

Default route

The default route 0.0.0.0/0 matches everything, but it is less specific than any non-default prefix. It is used only when no more-specific route matches.

03

Longest prefix first

A /24 beats a /16 because the /24 carries more matching bits. Only after the best prefix is identified do protocol-specific metrics or next-hop rules resolve ties within the relevant routing table.

DUAL CODING

See the mechanism before you memorize it

One diagram, one causal story, one reconstruction task.

VISUAL RECONSTRUCTION

Routing tables, default gateway, longest-prefix match — causal map

4 stages
01

Receive

Router reads the destination IP from the packet.

02

Match

Test the destination against candidate prefixes.

03

Select

Choose the most specific matching prefix.

04

Next hop

Resolve or use the next-hop forwarding information.

Trace the mechanism from left to right. On smaller screens, follow the numbered sequence. Then redraw the same flow without looking.
ACTIVE RECONSTRUCTION

Draw the idea yourself

Rebuild the core flow on a real canvas before moving to the worked walkthrough.

SKETCHFLOW

Routing tables, default gateway, longest-prefix match — practice canvas

Sketch the Routing tables, default gateway, longest-prefix match mechanism from memory. Label the input, transformation, observation, and transfer.

Practice canvas ready

The canvas loads when you reach this section.

Draw first. Compare second.Touch + mouse friendly
STEP BY STEP

Walk the system

01

Receive

Router reads the destination IP from the packet.

02

Match

Test the destination against candidate prefixes.

03

Select

Choose the most specific matching prefix.

04

Next hop

Resolve or use the next-hop forwarding information.

05

Forward

Build the next link-layer frame and send it out the selected interface.

CONCRETE ARTIFACT

Longest-prefix example

All three routes match 10.20.30.44, but /24 is the most specific and therefore wins.

textcopy → rebuild → modify
10.0.0.0/8      → R1
10.20.0.0/16    → R2
10.20.30.0/24   → R3
10.20.30.44 → R3
MISCONCEPTIONS

What usually goes wrong

Choose the numerically smallest prefix.

Think a default route wins because it is a default.

Ignore that a route can point to a directly connected interface rather than another router.

RETRIEVAL PRACTICE

Close the tab. Rebuild it from memory.

Read the question, answer aloud, then reveal.

Why is /24 more specific than /16?Reveal answer

It requires 24 destination bits to match instead of 16, so it describes a smaller set of addresses.

What does a default route do?Reveal answer

It provides a catch-all path when no more-specific route exists.

What happens after route selection?Reveal answer

The router performs forwarding actions such as resolving the next-hop link-layer address and emitting a new frame.

FEYNMAN

Teach it back in plain English

Take a destination like 10.20.30.44 and mark every matching route. Circle the longest prefix without looking at the answer.

EXAM / INTERVIEW

What a strong answer sounds like

Expect routing-table exercises, default route questions and longest-prefix matching problems.

NEXT CONNECTION

Make this idea travel.

Connect it next to: routing-protocols • nat-ipv6 • subnet-design-lab.

COURSE CONTENTS

Routing tables, default gateway, longest-prefix match

01How the Internet Works + OSI ModelWeek 1 · 4 topics0/4
02Physical & Data Link LayersWeek 1–2 · 5 topics0/5
03Network Layer: IP & RoutingWeek 2–3 · 6 topics0/6
04Transport Layer: TCP & UDPWeek 3–4 · 5 topics0/5
05Application Layer: HTTP, DNS & FriendsWeek 4–5 · 6 topics0/6
06Security & Troubleshooting ToolkitWeek 5 · 5 topics0/5