The Routing Table
When a router receives a packet, it does not think. It looks up the destination in its routing table and follows the most specific match. Reading that table — and its codes, distances, and metrics — is a core CCNA skill.
- List what a route entry contains.
- Decode the show ip route legend: C, S, L, D, O, R.
- Apply the router’s lookup rule: longest-prefix match wins.
- Explain the default route 0.0.0.0/0 and the gateway of last resort.
- Interpret the [administrative distance / metric] value in each line.
What the routing table is
Every Layer 3 device keeps a routing table (also called the routing information base). It is a map of known destination networks and, for each one, the best way to reach it: an outgoing interface and/or a next-hop address. When a packet arrives, the router reads the destination IP address, finds the matching entry, and forwards the packet accordingly. If two entries could match, the router applies the longest-prefix rule; if none match and no default route exists, the packet is dropped and an ICMP “destination unreachable” message is returned.
A router populates its table from three sources: networks it is directly connected to (added automatically), static routes entered by an administrator, and dynamic routes learned from routing protocols. Lesson 12 covers those sources.
What a route entry holds
| Part of the entry | Example | Meaning |
|---|---|---|
| Destination network / prefix | 192.168.20.0/24 | The network this route can reach. |
| Next-hop address or exit interface | via 192.168.10.2 · or · Gi0/1 | Where to send packets for that network. Directly connected routes show an interface. |
| Administrative distance | 110 | Trustworthiness of the route source; lower is more trusted. |
| Metric | 2 | Cost as measured by the originating protocol (hop count, cost, composite). |
| Source code | O | How the route was learned (OSPF here). |
In show ip route output the distance and metric appear together in brackets, as
[110/2]. Timers (the route’s age) appear for dynamic routes.
Route types and the legend
The first column of each line is a one-letter (or two-letter) code. These are the codes the exam expects:
| Code | Route type | How it is learned |
|---|---|---|
| C | Connected | Automatically, for a network on one of the router’s own interfaces. |
| L | Local | The router’s own interface address; a host route (/32). |
| S | Static | Entered manually by an administrator. |
| D | EIGRP | Learned dynamically from EIGRP. |
| O | OSPF | Learned dynamically from OSPF. |
| R | RIP | Learned dynamically from RIP. |
* to mark a candidate default route (for example S*).
Reading show ip route
Here is an illustrative output block. The exact addresses are chosen for teaching; the format is what a real Cisco IOS router prints.
Router# show ip route
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
Gateway of last resort is 192.168.10.2 to network 0.0.0.0
S* 0.0.0.0/0 [1/0] via 192.168.10.2
10.1.0.0/16 is variably subnetted, 2 subnets, 2 masks
C 10.1.0.0/16 is directly connected, GigabitEthernet0/0
L 10.1.1.1/32 is directly connected, GigabitEthernet0/0
192.168.10.0/24 is variably subnetted, 2 subnets, 2 masks
C 192.168.10.0/24 is directly connected, GigabitEthernet0/1
L 192.168.10.1/32 is directly connected, GigabitEthernet0/1
O 192.168.20.0/24 [110/2] via 192.168.10.2, 00:05:31, GigabitEthernet0/1
D 192.168.30.0/24 [90/3072] via 192.168.10.2, 00:12:04, GigabitEthernet0/1
R 192.168.40.0/24 [120/1] via 192.168.10.2, 00:00:18, GigabitEthernet0/1
10.1.0.0/16 is variably subnetted, 2 subnets, 2 masks” is a
parent line; the indented C and L lines beneath it are its children, so classes of the same
major network with different mask lengths are grouped.
Longest-prefix match
When more than one entry could match a destination address, the router chooses the entry with the longest prefix — the one with the most matching bits, also called the most specific match. This rule is applied before any consideration of administrative distance or metric. Distance and metric only break ties between routes for the same prefix length.
Example: a packet for 10.1.1.55. Two routes match, 10.1.0.0/16 and
10.1.1.0/24. The /24 is longer (24 bits versus 16), so it is selected even if
the /16 had a lower administrative distance. Only if no longer match existed would the
router fall back to the /16.
The default route and gateway of last resort
A default route is a route for 0.0.0.0/0 — a prefix of length zero, meaning “everything”. Because it matches every address but has the shortest possible prefix, it is only used when no more specific route matches. Routers commonly point it at an upstream provider. In the output, the * next to S* marks it as the candidate default, and the line “Gateway of last resort is 192.168.10.2 to network 0.0.0.0” names the next hop the router uses for otherwise-unknown destinations.
0.0.0.0/0) is present.
Connected and local routes
When you configure an IP address on an interface and bring it up, IOS adds two routes automatically. The connected route (C) covers the whole subnet; the local route (L) is a host route (/32) for the router’s own interface address, used to process traffic addressed to the router itself. For example, an interface configured with 10.1.1.1/16 produces a C 10.1.0.0/16 line and an L 10.1.1.1/32 line. Both carry an administrative distance of 0, the most trusted value.
Worked lookup examples
| Destination packet | Matching routes | Chosen route | Why |
|---|---|---|---|
| 10.1.1.55 | 10.1.0.0/16 · 10.1.1.0/24 | 10.1.1.0/24 | Longest prefix (24 > 16). |
| 10.1.9.8 | 10.1.0.0/16 only | 10.1.0.0/16 | The only match. |
| 8.8.8.8 | 0.0.0.0/0 only | 0.0.0.0/0 | No specific route; default route used. |
| 172.16.5.4 | none (no default) | — dropped | No match and no gateway of last resort. |
Common pitfalls
- Choosing by AD before prefix. Prefix length decides first; AD breaks ties only for equal prefixes.
- Confusing C and L.
Cis the whole subnet;Lis the router’s own /32 host address. - Thinking a default route is a specific network.
0.0.0.0/0matches everything and is used only as a last resort. - Reading the bracket backwards.
[110/2]is AD 110, metric 2 — distance first. - Assuming the gateway of last resort always exists. Many routers show “not set”.
The vocabulary you need
Every term below appears in the lesson text above. Select one to read its definition, then use the quiz at the end to check what stuck.
Review
Check what you have learned with these review questions.
Sources & references
- Cisco. CCNA (200-301) Exam Topics. cisco.com.
- IETF. Request for Comments (RFCs). rfc-editor.org.
- IANA. Internet Assigned Numbers Authority registries. iana.org.
Target exams: CCNA 200-301 v1.1 · CyberOps Associate 200-201. Last content verification: 2026-10-11.