By the end of this lesson you can
- Read every field of a routing table entry
- Pick the winning route using longest prefix match, then AD, then metric
- Configure IPv4 and IPv6 network, default, host and floating static routes
- Troubleshoot missing return routes with show ip route and traceroute
Reading a routing table
R1#show ip route
Codes: L - local, C - connected, S - static, O - OSPF
* - candidate default
Gateway of last resort is not set
C 10.0.12.0/30 is directly connected, GigabitEthernet0/0/1
L 10.0.12.1/32 is directly connected, GigabitEthernet0/0/1
S 192.168.3.0/24 [1/0] via 10.0.12.2
O 10.20.0.0/16 [110/20] via 10.0.12.2, 00:01:12, GigabitEthernet0/0/1- Code: C connected, L local (the router's own address as a /32), S static, O OSPF, and an asterisk marks a candidate default route.
- Prefix and length: the destination network.
- [AD/metric]: administrative distance (how much the router trusts the source) and the protocol's metric (how far).
- via: the next hop, then for dynamic routes the age and the exit interface.
- Gateway of last resort: the default route, used when nothing more specific matches.
How a router picks a route
- Longest prefix match first. Of all routes that contain the destination, the most specific wins. A /32 beats a /24, which beats a /16, which beats the /0 default. This happens no matter what the AD is.
- AD only for identical prefixes. When two sources offer the same prefix and length, only the lowest AD enters the table.
- Metric breaks ties within one routing protocol.
| Source | Default AD |
|---|---|
| Connected | 0 |
| Static | 1 |
| eBGP | 20 |
| EIGRP (internal) | 90 |
| OSPF | 110 |
| RIP | 120 |
| EIGRP (external) | 170 |
| iBGP | 200 |
| Unusable | 255 |
Practise with the game. This router has no default route, so a packet that matches nothing is dropped.
Static routes: network, default, host and floating
! network route via a next hop (recursive: the router then looks up how to reach 10.0.12.2)
R1(config)#ip route 192.168.3.0 255.255.255.0 10.0.12.2
! exit interface only: fine on point to point links, avoid on Ethernet
R1(config)#ip route 192.168.3.0 255.255.255.0 GigabitEthernet0/0/1
! fully specified: both
R1(config)#ip route 192.168.3.0 255.255.255.0 GigabitEthernet0/0/1 10.0.12.2
! default route
R2(config)#ip route 0.0.0.0 0.0.0.0 10.0.12.1
! host route
R1(config)#ip route 192.168.3.100 255.255.255.255 10.0.13.2
! floating static: AD 5, only used if the AD 1 route disappears
R1(config)#ip route 192.168.3.0 255.255.255.0 10.0.13.2 5
! IPv6 equivalents
R1(config)#ipv6 route 2001:db8:1:3::/64 2001:db8:12::2
R1(config)#ipv6 route ::/0 2001:db8:12::2- A floating static sits in the running config but stays out of the routing table while the primary route is installed.
- A static route via a next hop stays installed as long as the router can still reach that next hop through an up interface. If the far router dies but your local interface stays up, the route usually stays too, and traffic is black holed. That is why real networks pair statics with tracking or use a routing protocol.
- For IPv6, if the next hop is a link-local address (fe80::), you must also name the exit interface.
Troubleshooting: it is always the way back
A ping needs a route there and a route back. Most static routing tickets are a forgotten return route on the far router. Work hop by hop: show ip route on each router for the destination and for the source, then traceroute (on a PC: tracert) to see where packets stop.
R1#show ip route 192.168.3.100
Routing entry for 192.168.3.100/32
Known via "static", distance 1, metric 0
Routing Descriptor Blocks:
* 10.0.13.2
Route metric is 0, traffic share count is 1Practise on R1
Missions 0/9
Flashcards: do you remember?
Tap a card to flip it. Try to answer in your head first; recalling is what makes it stick.
Quick quiz
Instant feedback on every answer. Score 70% or more to pass this lesson's quiz.
Q1Routes: OSPF 10.1.0.0/16 and RIP 10.1.1.0/24. Destination 10.1.1.9 uses?
Longest prefix match comes before AD.
Q2Which line adds a floating backup default route?
A higher AD makes it float.
Q3Ping from LAN1 to LAN3 fails. R1 has a route to LAN3. What is the next thing to check?
Traffic needs a path back.
Q4Two static routes for 192.168.3.0/24 with AD 1 and AD 5. What is in the routing table?
Only the best AD for the same prefix is installed.
Q5Why avoid an exit interface only static on Ethernet?
It relies on proxy ARP and wastes resources.
Q6What does ip route 198.51.100.0 255.255.255.0 Null0 do?
A black hole route.
Hands-on lab
Packet Tracer lab 3.7: static, host and floating routes
You need: Cisco Packet Tracer (free with a Cisco Networking Academy account; version 9.0.1 was the current download on the NetAcad Resource Hub when this lesson was written). Devices: 3 x ISR4331, 2 x 2960, PC1, PC3, Server3. Enable ipv6 unicast-routing on every router.
Simulator lab, zero risk. This lab runs inside Cisco Packet Tracer, so it touches no real network. Packet Tracer is free with a Cisco Networking Academy account (netacad.com). It simulates a subset of Cisco IOS, so where support for a feature is uncertain we say so instead of promising it works.
Topology and addressing
| Device | Interface | IPv4 address / prefix | Default gateway or note |
|---|---|---|---|
| R1 | Gi0/0/0 | 192.168.1.1/24, 2001:db8:1:1::1/64 | LAN1 |
| R1 | Gi0/0/1 | 10.0.12.1/30, 2001:db8:12::1/64 | to R2 |
| R1 | Gi0/0/2 | 10.0.13.1/30, 2001:db8:13::1/64 | to R3 |
| R2 | Gi0/0/1 | 10.0.12.2/30, 2001:db8:12::2/64 | to R1 |
| R2 | Gi0/0/2 | 10.0.23.1/30, 2001:db8:23::2/64 | to R3 |
| R2 | Gi0/0/0 | 192.168.3.1/24, 2001:db8:1:3::1/64 | LAN3 |
| R3 | Gi0/0/1 | 10.0.13.2/30, 2001:db8:13::3/64 | to R1 |
| R3 | Gi0/0/0 | 10.0.23.2/30, 2001:db8:23::3/64 | to R2 |
| PC1 | Fa0 | 192.168.1.10/24 | gw 192.168.1.1 |
| PC3 | Fa0 | 192.168.3.10/24 | gw 192.168.3.1 |
| Server3 | Fa0 | 192.168.3.100/24 | gw 192.168.3.1 |
Address everything
Use the table. Check every router with
show ip interface briefbefore adding a single route: half of all routing problems are an interface that is still shut.R1: primary, floating and host routes
R1(config)#ip route 192.168.3.0 255.255.255.0 10.0.12.2 R1(config)#ipv6 route 2001:db8:1:3::/64 2001:db8:12::2 R1(config)#ip route 192.168.3.0 255.255.255.0 10.0.13.2 5 R1(config)#ipv6 route 2001:db8:1:3::/64 2001:db8:13::3 5 R1(config)#ip route 192.168.3.100 255.255.255.255 10.0.13.2R2: default route back, plus a floating default
R2(config)#ip route 0.0.0.0 0.0.0.0 10.0.12.1 R2(config)#ipv6 route ::/0 2001:db8:12::1 R2(config)#ip route 0.0.0.0 0.0.0.0 10.0.23.2 5R3: routes to both LANs
R3(config)#ip route 192.168.1.0 255.255.255.0 10.0.13.1 R3(config)#ip route 192.168.3.0 255.255.255.0 10.0.23.1 R3(config)#ipv6 route 2001:db8:1:1::/64 2001:db8:13::1 R3(config)#ipv6 route 2001:db8:1:3::/64 2001:db8:23::2Compare paths
From PC1:
tracert 192.168.3.10should go R1, R2.tracert 192.168.3.100should go R1, R3, R2, because the /32 host route wins over the /24.Fail the primary
Shut R1 Gi0/0/1 and run
show ip routeon R1: the floating route appears as [5/0] via 10.0.13.2. Ping PC3 again. Then bring Gi0/0/1 back.Verify
R1#show ip route R1#show ip route static R1#show ip route 192.168.3.100 R1#show ipv6 route static R1#show running-config | include ip route
You are done when: R1 shows S 192.168.3.0/24 [1/0] via 10.0.12.2 and S 192.168.3.100/32 [1/0] via 10.0.13.2; the AD 5 route appears only while Gi0/0/1 is shut; tracert to the server goes through R3.
Packet Tracer limits and notes
- This lab corrects one detail you may see in other guides: on a /30 only .1 and .2 are usable, so R3 uses 10.0.13.2 and R2 uses 10.0.23.1.
- As on real IOS, a static route via a next hop usually stays installed when the far router fails but your local interface stays up. That is why this lab shuts the local interface to test failover.
- Packet Tracer simulates a subset of IOS. If a command here is rejected in your version, note it, skip that step and carry on; the concept still applies to real Cisco gear.
Download the lab checklist (.txt) Print it or keep it open beside Packet Tracer.
Key takeaways
- Longest prefix first, then AD, then metric.
- Static routes: network, default, host, floating.
- Floating statics wait in the config until the primary disappears.
- Every path needs a return path.
- Log and review route changes like any security relevant change.
Finished the sections, quiz and lab? Mark the lesson complete. Progress is saved only in this browser.