Module 3.1 60 minBeginner

How a router forwards a packet

A router receives a frame, strips the L2 header, looks up the IP destination in its routing table, picks the longest-prefix match, re-encapsulates in a new L2 frame for the outgoing interface, and sends it on. This chapter walks through that path step by step.

Course plan — preview

What you'll learn

  • Describe the per-packet process inside a router.
  • Explain longest-prefix match and why it overrides administrative distance.
  • Read 'show ip route' output cleanly.

Packet through a router — the seven steps

Every router on a path runs the same seven steps on its own, using only its own routing table. No router knows the whole path: each one only chooses the next hop and hands the packet on.

  • Receive frame on incoming interface.
  • Verify Ethernet FCS — drop if corrupted.
  • Strip the L2 header; the payload is now a raw IP packet.
  • Decrement TTL; if TTL = 0, drop and send ICMP Time Exceeded.
  • Look up destination IP in the routing table — pick the most specific (longest-prefix) match.
  • Re-encapsulate in a new frame for the outgoing interface (ARP for the next-hop MAC if not already cached).
  • Transmit. Update interface counters.

Longest-prefix match

When two routes both match a destination — say a /24 and a /16 — the router uses the more specific one (the /24). This is why a default route 0.0.0.0/0 coexists with specific internal routes: internal traffic prefers the specifics, and only unmatched traffic falls through to the default.

The rule in one line: of all the entries that contain the destination, the one with the most network bits wins. Later in this chapter you do a lookup by hand against a real table, and see why this rule always runs before administrative distance gets a say.

11 more sections in this chapter, plus a 4-question quiz and a hands-on lab.

Course plan

Modules 2–8 are part of the Course & Lab Pass and All-Access Max — start with a free account

You can see the title, summary, learning objectives and the opening sections. The rest of this chapter, like all of modules 2–8, comes with the Course & Lab Pass and All-Access Max. A free account opens Module 1: How Networks Work end-to-end and saves your labs — start there, no card required.

  • Read every chapter in Module 1 — How Networks Work
  • Save labs of up to 5 devices
  • Save up to 3 topologies
  • See the full course syllabus + chapter titles

Free account · no card required · compare plans any time

Build it step by step