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.
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.
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
- Two LANs, one routerPut a PC on each of two different subnets and make them talk through a router. · 7 steps · ~12 min · 3 devices
- A stub branch and one default routeSend everything a branch can't place to HQ with a single default route, and see why HQ still needs a specific route back for every branch network. · 7 steps · ~22 min · 4 devices
- Traceroute across three routersChain three routers with static routes and follow a packet hop by hop — then watch a trace stop at a missing route and circle in a routing loop. · 7 steps · ~25 min · 5 devices
- Static routes across a WANJoin three sites with point-to-point WAN links and route between them by hand, one line at a time. · 9 steps · ~22 min · 6 devices
- RIP: routing by counting hopsChain three routers over two serial links and let RIP version 2 teach every router the way to every network, counting the hops as it goes. · 6 steps · ~18 min · 5 devices
- EIGRP across three routersJoin two sites through a hub with EIGRP, find why one router learns nothing, then add a direct link and watch EIGRP choose speed over hop count. · 7 steps · ~25 min · 5 devices
- Fix it: Fix the broken officeNobody in a two-desk office can reach the intranet server. Find the two faults and fix them, one layer at a time. · 6 steps · ~12 min · 5 devices
- Fix it: Fix the OSPF adjacenciesThree routers run OSPF and nothing converges. Find the area mismatch and the network statement that matches nothing. · 6 steps · ~20 min · 5 devices