IP routes are a must if packets are to be successfully sent from one LAN network to another. In normal circumstances we will rely on routing protocols (mostly OSPF but sometimes also EIGRP or RIP). However, in specific situations we might need to use static routes to overrule those suggested by routing protocols. Or we might want to specify floating routes as fallback options if the routes suggested by OSPF/EIGRP/RIP become unavailable.
To show current routes:
R1# show ip route
Codes: L – local, C – connected, S – static, R – RIP, M – mobile, B – BGP
D – EIGRP, EX – EIGRP external, O – OPSF, 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
o – ODR, P – periodic downloaded static route, H – NHRP, 1 – LISP
a – application route
+ – replicated route, % – next hop override, p – overrides from PfR
Gateway of last resort is not set.
192.160.1.0/24 is variably subnetted, 2 subnets, 2 masks
C 192.168.1.0/24 is directly connected, GigabitEthernet0/0
L 192.168.1.1/32 is directly connected, GigabitEthernet0/0
Important codes:
• C: locally connected network
• L: locally connected IP
• S: static route
• R: RIP route
• B: BGP route
• D: EIGRP route
• O: OSPF route
• *: candidate default route
We can filter routes by their source/type:
R1# show ip route bgp
R1# show ip route connected
R1# show ip route eigrp
R1# show ip route ospf
R1# show ip route rip
R1# show ip route static
R1# show ip route summary
To configure default route:
R1(config)# ip route 0.0.0.0 0.0.0.0 192.168.1.1 /* using IP */
R1(config)# ip route 0.0.0.0 0.0.0.0 g0/0 /* using interface */
R1(config)# ip route 0.0.0.0 0.0.0.0 g0/0 192.168.1.1 /* using both */
Routes are lost if the device is rebooted. The persist them, add the “permanent” keyword at the end:
R1(config)# ip route 0.0.0.0 0.0.0.0 g0/0 192.168.1.1 permanent
Static routes by default have an Administrative Distance of 1. AD of 0 is for those routes directly connected to the device. 255 is for those routes that are impossible, unbelievable or to be ignored. Summary of Administrative Distances:
Route type Administrative Distance:
• 0 Connected
• 1 Static
• 5 EIGRP summary
• 20 eBGP
• 90 EIGRP
• 110 OSPF
• 115 IS-IS
• 120 RIP
• 170 EIGRP external
• 200 iBGP
• 255 Ignored
At times it might make sense to add a route that should only be used if routing protocols stop serving it. For instance…
R1(config)# ip route 10.5.0.0 255.255.0.0 g0/0 192.168.1.1 111
… would only be used if no other source with a lower AD can point a way to the destination. This is what we call floating route.