Understanding the routing table is a fundamental skill for anyone studying computer networking or working as a network administrator. A routing table acts as a network map that routers use to determine where to send packets across a network. It contains important details such as destination networks, next hops, metrics, and more.
In this article, we’ll interpret the components of a routing table including routing protocol code, prefix, network mask, next hop, administrative distance, metric, and gateway of last resort.
What Is a Routing Table?
A routing table is a data file stored in a router or a networked computer that lists routes to particular network destinations. Each entry in the routing table provides instructions on how to reach a specific network, ensuring that packets are forwarded efficiently.
Each entry in the table contains information such as:
- The routing protocol code used to learn the route
- The destination network (or prefix)
- The subnet mask
- The next hop (where the packet should go next)
- The administrative distance
- The metric (cost of using that route)
- The gateway of last resort (default route)
Routing Protocol Code
The routing protocol code identifies which routing protocol learned the route. In Cisco IOS, for example, the routing table lists entries with short codes when show ip route command is executed.
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, E - EGP
i - IS-IS, L1 - IS-IS level 1, L2 - IS-IS level-2, ia - IS-IS inter area
* - candidate default, U - per-user static route, o - ODR
P - periodic downloaded static route
Gateway of last resort is 192.168.1.1 to network 0.0.0.0
C 192.168.1.0/24 is directly connected, GigabitEthernet0/0
S 10.0.0.0/8 [1/0] via 192.168.1.1
O 172.16.0.0/16 [110/20] via 10.0.0.2, 00:00:20, GigabitEthernet0/1
D 192.168.2.0/24 [90/156160] via 10.0.0.5, 00:00:15, GigabitEthernet0/2
- L – Local
- C – Connected
- S – Static
- R – RIP (Routing Information Protocol)
- O – OSPF (Open Shortest Path First)
- D – EIGRP (Enhanced Interior Gateway Routing Protocol)
- B – BGP (Border Gateway Protocol)
In this example:
- C → Connected route
- S → Static route
- O → Learned via OSPF
- D → Learned via EIGRP
Each letter (code) instantly tells you which routing source provided that entry. These codes help network engineers quickly determine the source of a route — whether it was manually configured (static) or learned dynamically from a routing protocol.
Prefix
The prefix represents the destination network address. It tells the router which network a particular routing entry applies to.
A prefix tells the router:
- Which network a route is for.
- How many bits of the address represent the network (via the subnet mask or prefix length).
If you check routing table by using show ip route command, the prefix is shown as :
Router# show ip route
S* 0.0.0.0/0 [1/0] via 10.1.1.1
C 10.1.1.0/24 is directly connected, GigabitEthernet0/0
L 10.1.1.1/32 is directly connected, GigabitEthernet0/0
Here, the prefixes are:
0.0.0.0/0is the default route. It tells the router where to send packets when no other specific route matches the destination IP address.192.168.1.0/24→ all addresses from 192.168.1.0 to 192.168.1.25510.0.0.0/8→ all addresses from 10.0.0.0 to 10.255.255.255
The router uses these prefixes to decide which interface or next hop to forward packets to.
Network Mask
A subnet mask is a 32-bit number that separates an IP address into two parts:
- Network portion – identifies the network.
- Host portion – identifies individual devices within that network.
In routing, the subnet mask tells the router which part of the IP address to match against its routing table to determine where the packet should go.
When a packet arrives at a router, the router examines the destination IP address. It then compares this address against each entry in the routing table using the subnet mask:
- The router performs a bitwise AND operation between the destination IP and the subnet mask.
- It compares the result to the network address listed in the table.
- If it matches, the router knows the packet belongs to that network and forwards it accordingly.
The subnet masks are often called the “network filters” in routing tables — they help the router determine the correct network for the packet.
Next Hop
The Next Hop is the IP address of the next router that should receive the packet on its journey toward the final destination.
The router doesn’t always know the entire path to the destination, but it knows which neighbouring router to send the packet to next. That neighbour then makes its own decision, and so on, until the packet reaches the destination network. Every time, it approaches its next neighbouring router, one hop will be counted.
The following routing table output shows the next hop details:
Gateway of last resort is 192.168.1.1 to network 0.0.0.0
C 192.168.1.0/24 is directly connected, GigabitEthernet0/0
S 10.0.0.0/8 [1/0] via 192.168.1.1
O 172.16.0.0/16 [110/20] via 10.0.0.2, 00:00:20, GigabitEthernet0/1
D 192.168.2.0/24 [90/156160] via 10.0.0.5, 00:00:15, GigabitEthernet0/2
Administrative Distance (AD)
Administrative Distance (AD) is a value that represents how trustworthy or reliable, a route source is.
It tells a router which routing information to believe when two or more sources provide routes to the same destination. The router always chooses the lowest AD value for trustworthiness or reliability of a route.
Routers can learn routes from multiple sources at the same time:
- Directly connected networks
- Static routes
- Dynamic routing protocols (OSPF, EIGRP, RIP, BGP, etc.)
Different routing sources may advertise the same destination network. Without AD, a router wouldn’t know which one to prefer, which could cause routing loops, inconsistent paths, or suboptimal traffic flow.
AD solves this by giving every routing source a ranking based on reliability.
Here are the most widely used AD values you’ll encounter:
| Route Source | AD Value | Meaning |
|---|---|---|
| Connected network | 0 | Most reliable; router is directly connected |
| Static route | 1 | Very trustworthy |
| eBGP | 20 | Trusted external routing info |
| EIGRP (internal) | 90 | Highly reliable |
| IGRP | 100 | Legacy but still known |
| OSPF | 110 | Widely used link-state protocol |
| IS-IS | 115 | Another link-state protocol |
| RIP | 120 | Oldest, less reliable |
| EIGRP (external) | 170 | Learned outside autonomous system |
| iBGP | 200 | Less trusted between internal peers |
| Unknown/Unusable routes | 255 | Never used for forwarding |
These values allow the router to quickly compare route sources during conflict.
Metric
A metric is a value assigned by a routing protocol to evaluate the desirability of a route.
Metrics quantify how “good” or “bad” a path is, allowing routers to compare multiple potential routes and select the best one.
Metrics measure characteristics such as:
- Hop count
- Bandwidth
- Delay
- Reliability
- Load
- Path cost
- Composite factors (depending on the protocol)
A route with a lower metric is preferred because it indicates a faster or more efficient path.
Each dynamic routing protocol uses its own type of metric.
- RIP (Routing Information Protocol) uses hop count as the mterics. each next hop is eaual to 1. Maximum 15 hops are countable by the RIP, beyond that it unreachable.
- OSPF (Open Shortest Path First) use cost as the metric. OSPF cost is calculated by Reference Bandwidth divided by Interface Bandwidth. Higher the bandwidth lower will be the cost. For example- Gigabit Ethernet (1 Gbps) will have lower cost than Fast Ethernet (100 Mbps)
- EIGRP (Enhanced Interior Gateway Routing Protocol) implements Composite metric using
- Bandwidth
- Delay
- Reliability (optional)
- Load (optional)
- EIGRP’s formula is complex but allows fine-tuned, highly accurate path selection.
- BGP (Border Gateway Protocol) relies on Path Attributes, not a single numeric metric. Important attributes include:
- Local Preference
- AS Path
- MED (Multi-Exit Discriminator)
- Origin Type
- BGP chooses paths using a step-by-step decision process rather than a simple numeric score.
Gateway of Last Resort
The gateway of last resort is the router’s default route. It is used when there’s no specific route to a destination in the routing table. It’s typically represented as 0.0.0.0/0, meaning “any destination.”
For example:
Gateway of last resort is 192.168.1.1 to network 0.0.0.0
This tells the router to send all unknown traffic to 192.168.1.1, which is usually the connection to the internet or a higher-level router.
Conclusion
Interpreting the components of a routing table is essential for network troubleshooting and configuration. Each element of a routing table from the routing protocol code to the gateway of last resort, plays a crucial role in ensuring that data reaches its destination efficiently.








