Sub topic 14
Verifying and Troubleshooting Routes
This chapter assumes you know IPv4 addressing and CIDR prefixes, the difference between a router, a switch and a host, and basic command-line use on a Linux host or a Cisco IOS router. It also assumes you have read the earlier chapters on longest-prefix match, static routes, administrative distance and floating static routes.
Configuring a route is only half the job. You also have to prove that the router uses the route you intended, and find the cause when it does not. This chapter gives a repeatable method and the commands for both Linux and Cisco IOS.
The working model: what you are checking
A forwarding decision on a router follows a fixed sequence:
- The router finds every route whose prefix contains the destination address.
- It keeps the one with the longest prefix (the most specific match).
- If two sources offer the same prefix, the lowest administrative distance wins.
- If one protocol offers several paths to that prefix, the lowest metric wins.
- The route names a next hop or an exit interface, and the router must then resolve the next hop's layer 2 address (ARP on Ethernet) to send the frame.
Every troubleshooting step below tests one of these stages. If you know which stage failed, you know where to look.
Step 1: ask the router which route it would use
Reading the whole table is useful, but the fastest check is a lookup for one destination. It applies longest-prefix match for you.
On Linux:
# Full table
ip route show
# The route the kernel would use for one destination
ip route get 10.2.5.7A typical answer from ip route get looks like this:
10.2.5.7 via 192.168.1.2 dev eth0 src 192.168.1.10 uid 1000
cacheRead it left to right. via 192.168.1.2 is the next hop, dev eth0 is the exit interface, and src 192.168.1.10 is the source address the host will use. If the output says RTNETLINK answers: Network is unreachable, no route matched, and the host has no default route either.
On Cisco IOS:
show ip route 10.2.5.7The output names the matching prefix, the route source (a code such as S, O or C), the administrative distance and metric in brackets, and the next hop. For example, [110/20] means administrative distance 110 and metric 20. A static route shows [1/0] by default.
Step 2: read the route source codes
On IOS the first column of show ip route tells you how the router learned each route. The common codes are:
| Code | Source | Default administrative distance |
|---|---|---|
| C | Directly connected network | 0 |
| L | Local address of an interface | 0 |
| S | Static route | 1 |
| S* | Static default route (candidate default) | 1 |
| O | OSPF | 110 |
| R | RIP | 120 |
| B | BGP (external) | 20 |
Use the filtered views to narrow down a large table:
show ip route static
show ip route ospf
show ip route connectedOn Linux, ip route show includes a proto field that plays the same role. Routes added by hand with ip route add show proto static, kernel-created routes for connected networks show proto kernel, and routes from a routing daemon show names such as proto bird or proto ospf.
# Show only routes that were added manually
ip route show proto static
# Show routes for one prefix and everything more specific
ip route show root 10.2.0.0/16Step 3: confirm that the right route won
When a destination takes an unexpected path, compare the candidates. Three things can explain it.
A more specific prefix exists
Longest-prefix match beats everything else. A forgotten /24 static route overrides a /16 learned from OSPF, no matter what the administrative distances are. Look for stray specific routes, including the ones an old test left behind.
A lower administrative distance won
A static route with the default distance of 1 beats an OSPF route for the same prefix, because 1 is lower than 110. If you wanted the static route to act as a backup, you forgot the distance value. The floating static route from the earlier chapter fixes this:
! Backup only: distance 200 loses to OSPF (110) while OSPF has the route
ip route 10.2.0.0 255.255.0.0 192.168.2.2 200To check that the floating route is correctly hidden, use show running-config | include ip route to see that it is configured, and show ip route 10.2.0.0 to see that the OSPF route is the one installed. A floating route that is configured but absent from show ip route static is normal while the primary path is up. It is not an error.
A better metric won inside one protocol
If two OSPF paths reach the same prefix, the router installs the lower-cost one, or both if the costs are equal. Check the cost with show ip route 10.2.0.0 and the interface cost with show ip ospf interface brief.
Step 4: check that the next hop is reachable
A route can be installed and still fail. The usual reasons are an interface that is down, a wrong next-hop address, or a next hop that does not answer ARP.
On Linux:
# Link state and addresses
ip -br link
ip -br addr
# Is the next hop in the neighbor (ARP) table, and in which state?
ip neigh show 192.168.1.2A neighbor entry in REACHABLE or STALE state is fine. FAILED or INCOMPLETE means ARP got no reply, so the next hop is down, on the wrong VLAN, or has a different address than you typed.
On IOS:
show ip interface brief
show ip arp 192.168.2.2A static route that names only an exit interface on a multi-access Ethernet link makes the router send an ARP request for every destination. Prefer a next-hop address (or both the interface and the next hop) on Ethernet.
A static route is also removed from the table when its exit interface goes down. A route that names only a next-hop address stays installed as long as the router can still reach that next hop through some other route. This is a common cause of "black holes", where traffic keeps going toward a dead path. Tracking features such as IP SLA or BFD address this, and they are outside this chapter.
Step 5: test the path and the return path
ping and traceroute test the forward route, but a reply needs a route back. Many "the route is broken" reports are really a missing route on the far side.
# Linux
ping -c 3 10.2.5.7
traceroute -n 10.2.5.7
# Use a specific source address to test the return path from a particular network
ping -c 3 -I 192.168.1.10 10.2.5.7On IOS, ping 10.2.5.7 source 10.1.0.1 sets the source address. This matters because a router normally uses the address of the exit interface as the source, and the far router may have no route to that address even though it has a route to your LAN.
Read a traceroute as a map of where the packet stopped:
- Hops answer up to a point, then show
* * *. The last answering router either has no route onward or the next router drops the probe. - The same two routers repeat on alternating lines. This is a routing loop, often caused by two static routes that point at each other.
- The path leaves through an unexpected router. Return to step 3.
Step 6: verify dynamic routing adjacencies
When a route that should be learned is missing, the cause is usually a protocol neighbor that never formed. Check the neighbors first.
show ip protocols
show ip ospf neighbor
show ip ospf interface brief
show ip route ospfFor OSPF, a neighbor should be in the FULL state (on point-to-point links, and with the DR and BDR on broadcast networks). Neighbors stuck in INIT or 2WAY (when not between DROTHER routers) point to mismatched settings. The usual mismatches are:
- Different area IDs on the two ends of a link.
- Different hello and dead timers.
- Different subnet masks on the shared link.
- A network statement that does not cover the interface address, so OSPF never runs on that interface.
- A passive interface where an adjacency is needed.
Check the last two with show ip ospf interface brief. If the interface is missing from the list, the network command did not match it.
Common failure patterns
| Symptom | Likely cause | First check |
|---|---|---|
| `Network is unreachable` on Linux | No matching route and no default route | `ip route show` |
| Ping works one way only | Missing return route on the far router | `ping ... source` from the far side |
| Traffic uses the wrong path | A more specific route, or a lower administrative distance | `show ip route <destination>` |
| Backup route never installs | Primary route still present, which is correct | Remove the primary route in a lab and watch |
| Backup route used while primary is up | Distance on the floating route is not higher than the primary's | `show ip route <destination>`, then the configured distance |
| Route in the table, traffic still fails | Next hop does not answer ARP, or interface is down | `ip neigh` or `show ip arp` |
| Two routers bounce a packet back and forth | Routing loop from mismatched static routes | `traceroute` |
| Dynamic route missing | Neighbor not formed | `show ip ospf neighbor` |
A worked example
Router R1 has an OSPF route to 10.2.0.0/16 and a floating static backup with distance 200. Users in 10.2.5.0/24 report that they cannot reach a server at 10.1.0.20, which is behind R1.
- On R1, run
show ip route 10.1.0.20. The route isC, connected. Forwarding on R1 is fine. - From R1, run
ping 10.2.5.7 source 10.1.0.1. It fails. - Run
show ip route 10.2.5.7. R1 usesO 10.2.0.0/16 [110/20] via 192.168.1.2. The route is what you expected. - Run
show ip arp 192.168.1.2. The entry is incomplete. The next hop does not answer. - Run
show ip interface brief. The interface toward 192.168.1.2 is up/up, so the cable is fine. The neighbor is on a different VLAN, and fixing the VLAN restores ARP, ping and the OSPF adjacency.
The route table was correct the whole time. The fault was one layer below it, which is why the method ends with the next hop and not with the table.
Exercise
A Linux host runs ip route get 10.2.5.7 and receives RTNETLINK answers: Network is unreachable. The host's table has a route to 10.1.0.0/16 and nothing else. Name the cause and give a command that fixes it, assuming the next hop is 192.168.1.1 on eth0.
Show answer
No route matches 10.2.5.7, and the host has no default route to catch it. Add one with sudo ip route add default via 192.168.1.1 dev eth0 (or add a specific route such as sudo ip route add 10.2.0.0/16 via 192.168.1.1 dev eth0). Then run ip route get 10.2.5.7 again to confirm the lookup now returns a next hop.
Exercise
A router has OSPF routing 10.2.0.0/16 (distance 110) and a floating static route for the same prefix configured with ip route 10.2.0.0 255.255.0.0 192.168.2.2 200. show ip route static shows nothing. Is this a fault? What would you check to be sure the backup works?
Show answer
It is not a fault. The static route has a higher distance than OSPF, so the router keeps it out of the table while the OSPF route exists. Confirm the configuration with show running-config | include ip route, then test the failover in a maintenance window or lab by shutting the OSPF-facing interface. After OSPF loses the route, show ip route 10.2.0.0 should show the static route with [200/0].
Exercise
Pings from R1 to 10.2.5.7 succeed when sourced from the exit interface but fail with source 10.1.0.1 (a LAN address). Which stage of the forwarding model most likely failed, and where?
Show answer
The return path failed. The far router has a route to R1's exit-interface network but no route to 10.1.0.0/24, so replies to the LAN source address are dropped or sent elsewhere. Check show ip route 10.1.0.1 on the far router and add or advertise the missing route.