IP Routing · Topic 1 of 4
Reading the Routing Table
Interpret a Cisco routing table: route codes, prefix and mask, administrative distance, metric, default route, and how longest prefix match picks the next hop.
- 6 min
- Each route shows a code, a prefix and mask,
[AD/metric], a next hop and an exit interface. - The first bracket number is AD and the second is the metric.
- Defaults: connected 0, static 1, eBGP 20, EIGRP 90, OSPF 110, RIP 120.
What it is
The routing table is the list of networks a router knows how to reach, and where to send packets for each one.
Every forwarding decision starts here. Read a table line by line and you can tell how a router learned a route, how much it trusts it and where a packet will go.
Display it with show ip route (IPv4) or show ipv6 route (IPv6). The exam asks you to identify the next hop for a packet.
How it works
Each line is one route. When several match a destination, three rules decide the winner.
Reading a route entry
Here is a trimmed IPv4 table:
Codes: L - local, C - connected, S - static, O - OSPF, D - EIGRP, * - candidate default
Gateway of last resort is 203.0.113.2 to network 0.0.0.0
S* 0.0.0.0/0 [1/0] via 203.0.113.2
10.0.0.0/8 is variably subnetted, 3 subnets, 2 masks
C 10.1.1.0/24 is directly connected, GigabitEthernet0/0
L 10.1.1.1/32 is directly connected, GigabitEthernet0/0
O 10.2.2.0/24 [110/20] via 10.1.1.2, 00:05:12, GigabitEthernet0/0
Take the OSPF line apart.
- Route code (
O): how the router learned the route. - Prefix and mask (
10.2.2.0/24): the destination range. - Administrative distance (
110): the first number in the brackets, the trust in the source. - Metric (
20): the second number, how good the route is within its own protocol. - Next hop (
via 10.1.1.2): the next router on the path. - Age and interface: how long the route has been known, and the exit interface.
In [110/20] the first number is the administrative distance and the second is the metric. Swapping them is the classic reading error.
Route codes
| Code | Meaning |
|---|---|
| C | Directly connected network, from an up interface with an address |
| L | The router's own interface address, shown as a /32 host route |
| S | Static route configured by an administrator |
| O | Learned through OSPF (O IA inter-area, O E2 external) |
| D | Learned through EIGRP (R is RIP, B is BGP) |
* | Candidate default route, as in S* |
Administrative distance and metric
For the same prefix from different sources, administrative distance (AD) decides. Lower is more trusted.
| Source | Default AD |
|---|---|
| Directly connected | 0 |
| Static route | 1 |
| eBGP | 20 |
| EIGRP (internal) | 90 |
| OSPF | 110 |
| RIP | 120 |
The metric only compares routes from the same protocol. RIP counts hops. OSPF uses cost, which is the reference bandwidth (100 Mbps by default) divided by the interface bandwidth, with a lowest value of 1. A metric means nothing to another protocol, which is why AD exists.
The default route
The line Gateway of last resort is 203.0.113.2 to network 0.0.0.0 names the default route. It is the route used when nothing more specific matches, and it appears with a * next to the code.
If none exists, the line says the gateway of last resort is not set, and unknown destinations are dropped.
Choosing the next hop: three rules in order
When several routes match a destination, the router applies these rules, each one only when the one before leaves a tie.
| Step | Rule | The winner is |
|---|---|---|
| 1 | Longest prefix match | The most specific route (the longest mask) |
| 2 | Administrative distance | The lowest AD, for the same prefix and mask |
| 3 | Metric | The lowest metric, within one protocol |
Look at this table and find the next hop for a packet to 10.1.1.5.
O 10.0.0.0/8 [110/30] via 10.9.9.2, 00:10:01, GigabitEthernet0/1
O 10.1.0.0/16 [110/25] via 10.9.9.3, 00:10:01, GigabitEthernet0/1
S 10.1.1.0/24 [1/0] via 10.8.8.2
S* 0.0.0.0/0 [1/0] via 203.0.113.2
All four routes match. The /24 has the longest prefix, so the next hop is 10.8.8.2. AD and metric are never consulted.
For 10.1.2.7 the /16 is the longest match, so the next hop is 10.9.9.3. For 172.16.0.1 only the default route matches, so the next hop is 203.0.113.2.
If two routes tie on prefix, AD and metric, the router installs both and shares traffic (equal cost load balancing).
Ask the router
One command shows which route a destination would use:
R1# show ip route 10.2.2.5
Routing entry for 10.2.2.0/24
Known via "ospf 1", distance 110, metric 20, type intra area
* 10.1.1.2, from 2.2.2.2, 00:05:12 ago, via GigabitEthernet0/0
It names the protocol, distance, metric and next hop. Filter the table with show ip route ospf, static or connected.
The IPv6 table
Read it the same way. The next hop sits on the line below.
R1# show ipv6 route
S ::/0 [1/0]
via 2001:DB8:12::2
C 2001:DB8:12::/64 [0/0]
via GigabitEthernet0/1, directly connected
O 2001:DB8:20::/64 [110/2]
via FE80::2, GigabitEthernet0/1
The default route is ::/0. The OSPF next hop is a link-local address, which is normal.
Common mistakes
These three errors come up again and again.
Choosing by AD first. Prefix length is checked before AD. A longer prefix wins even when it comes from a less trusted source.
Comparing metrics across protocols. An OSPF cost cannot be compared with a RIP hop count.
Assuming there is a default route. If the gateway of last resort is not set, traffic for unknown networks is dropped.
What to remember for the exam
Seven facts cover most routing table questions.
- Each route shows a code, a prefix and mask,
[AD/metric], a next hop and an exit interface. - The first bracket number is AD and the second is the metric.
- Defaults: connected 0, static 1, eBGP 20, EIGRP 90, OSPF 110, RIP 120.
- Longest prefix match comes first, then AD, then metric.
- A metric is only compared within one protocol.
- The default route is 0.0.0.0/0 in IPv4 and
::/0in IPv6, and it is always the least specific match. - With no match and no default route, the packet is dropped.
To find the next hop, list the routes that contain the destination, pick the longest mask, and only then look at AD and metric.
Check yourself
Work through these three prompts.
In
O 10.2.2.0/24 [110/20] via 10.1.1.2, what are 110, 20 and 10.1.1.2?110 is the administrative distance, 20 is the OSPF metric and 10.1.1.2 is the next hop.
A table holds 10.0.0.0/8 (OSPF), 10.1.1.0/24 (OSPF) and 0.0.0.0/0 (static). Which route does a packet to 10.1.1.9 use?
The 10.1.1.0/24 route, because it is the longest prefix match. AD is never compared between different prefix lengths.
What happens to a packet when no route matches and no default route exists?
The router drops the packet and sends an ICMP destination unreachable message.
Topic 1 of 4 in IP Routing
Test yourself on IP Routing
The full Cisco CCNA 200-301 v2.0 question bank has 1,242 questions, with timed practice exams and an explanation for every answer.
This study guide is independent and is not affiliated with, endorsed by, or sponsored by Cisco. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.