Static Routes
This chapter contains basic static routing configuration examples.
This example shows the complete configuration to enable static routing in a simple network topology. A static route is composed of a network prefix (host address) and a nexthop (gateway). Static routes are useful in small networks. They are simple solutions for making a few destinations reachable. Large networks use dynamic routing protocols.
Topology
Router R1 is configured with these static routes:
• The remote network 10.10.12.0/24
• The loopback address (host addresses) of router R2
• The loopback address of router R3
Basic Static Route
In all three routes, interface eth0 of router R2 is the gateway. Router R3 is configured with a default static route that is equivalent to configuring separate static routes with the same gateway or nexthop address. Router R2 has two routes, one for each of the remote routers' loopback address.
Configuration
R1
#configure terminal | Enter configure mode. |
(config)#interface lo | Enter interface mode. |
(config-if)#ip address 192.168.0.1/32 | Configure the IP address on this interface, and specify a 32-bit mask, making it a host address. |
(config-if)#exit | Exit interface mode. |
(config)#ip route 10.10.12.0/24 10.10.10.2 (config)#ip route 192.168.0.2/32 10.10.10.2 (config)#ip route 192.168.0.3/32 10.10.10.2 | Specify the destination prefix and mask for the network and a gateway. Because R2 is the only next hop available, you can configure a default route instead of configuring the same static route for individual addresses. See the configuration of R3. |
R2
#configure terminal | Enter configure mode. |
(config)#interface lo | Enter interface mode. |
(config-if)#ip address 192.168.0.2/32 | Configure the IP address on this interface, and specify a 32-bit mask, making it a host address. |
(config-if)#exit | Exit interface mode. |
(config)#ip route 192.168.0.1/32 10.10.10.1 (config)#ip route 192.168.0.3/32 10.10.12.3 | Specify the destination and mask for the network and a gateway. |
R3
#configure terminal | Enter configure mode. |
(config)#interface lo | Enter interface mode. |
(config-if)#ip address 192.168.0.3/32 | Configure the IP address on this interface, and specify a 32-bit mask, making it a host address. |
(config-if)#exit | Exit interface mode. |
(config)#ip route 0.0.0.0/0 10.10.12.2 | Specify 10.10.12.2 as a default gateway to reach any network. Because 10.10.12.2 is the only available route, you can specify it as the default gateway instead of specifying it as the gateway for an individual network or host address. |
Validation
show ip route, show ip route summary, show ip route database
R1
#sh ip route
Codes: K - kernel, C - connected, S - static, R - RIP, B - BGP
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
i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
* - candidate default
IP Route Table for VRF "default"
Gateway of last resort is 10.12.4.1 to network 0.0.0.0
K* 0.0.0.0/0 [0/0] via 10.12.4.1, eth0
C 10.10.10.0/24 is directly connected, eth1
S 10.10.12.0/24 [1/0] via 10.10.10.2, eth1
C 10.12.4.0/24 is directly connected, eth0
C 127.0.0.0/8 is directly connected, lo
C 192.168.0.1/32 is directly connected, lo
S 192.168.0.2/32 [1/0] via 10.10.10.2, eth1
S 192.168.0.3/32 [1/0] via 10.10.10.2, eth1
#show ip route summary
IP routing table name is Default-IP-Routing-Table(0)
IP routing table maximum-paths : 8
Total number of IPv4 routes : 8
Total number of IPv4 paths : 8
Route Source Networks
kernel 1
connected 4
static 3
Total 8
FIB 0
ECMP statistics (active in ASIC):
---------------------------------
Total number of IPv4 ECMP routes : 0
Total number of IPv4 ECMP paths : 0
---------------------------------
#show ip route database
Codes: K - kernel, C - connected, S - static, R - RIP, B - BGP
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
i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
> - selected route, * - FIB route, p - stale info
IP Route Table for VRF "default"
K *> 0.0.0.0/0 [0/0] via 10.12.4.1, eth0
C *> 10.10.10.0/24 is directly connected, eth1
S *> 10.10.12.0/24 [1/0] via 10.10.10.2, eth1
C *> 10.12.4.0/24 is directly connected, eth0
C *> 127.0.0.0/8 is directly connected, lo
C *> 192.168.0.1/32 is directly connected, lo
S *> 192.168.0.2/32 [1/0] via 10.10.10.2, eth1
S *> 192.168.0.3/32 [1/0] via 10.10.10.2, eth1
Gateway of last resort is not set
R2
#sh ip route
Codes: K - kernel, C - connected, S - static, R - RIP, B - BGP
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
i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
* - candidate default
IP Route Table for VRF "default"
Gateway of last resort is 10.12.4.1 to network 0.0.0.0
K* 0.0.0.0/0 [0/0] via 10.12.4.1, eth0
C 10.10.10.0/24 is directly connected, eth1
C 10.10.12.0/24 is directly connected, eth2
C 10.12.4.0/24 is directly connected, eth0
C 127.0.0.0/8 is directly connected, lo
S 192.168.0.1/32 [1/0] via 10.10.10.1, eth1
C 192.168.0.2/32 is directly connected, lo
S 192.168.0.3/32 [1/0] via 10.10.12.3, eth2
#sh ip route summary
IP routing table name is Default-IP-Routing-Table(0)
IP routing table maximum-paths : 8
Total number of IPv4 routes : 9
Total number of IPv4 paths : 9
Route Source Networks
kernel 1
connected 5
static 3
Total 9
FIB 0
ECMP statistics (active in ASIC):
---------------------------------
Total number of IPv4 ECMP routes : 0
Total number of IPv4 ECMP paths : 0
--------------------------------
#sh ip route database
Codes: K - kernel, C - connected, S - static, R - RIP, B - BGP
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
i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
> - selected route, * - FIB route, p - stale info
IP Route Table for VRF "default"
K *> 0.0.0.0/0 [0/0] via 10.12.4.1, eth0
C *> 10.10.10.0/24 is directly connected, eth1
C *> 10.10.12.0/24 is directly connected, eth2
C *> 10.12.4.0/24 is directly connected, eth0
C *> 127.0.0.0/8 is directly connected, lo
S *> 192.168.0.1/32 [1/0] via 10.10.10.1, eth1
C *> 192.168.0.2/32 is directly connected, lo
S *> 192.168.0.3/32 [1/0] via 10.10.12.3, eth2
Gateway of last resort is not set
R3
#sh ip route
Codes: K - kernel, C - connected, S - static, R - RIP, B - BGP
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
i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
* - candidate default
IP Route Table for VRF "default"
Gateway of last resort is 10.12.4.1 to network 0.0.0.0
K* 0.0.0.0/0 [0/0] via 10.12.4.1, eth0
C 10.10.12.0/24 is directly connected, eth2
C 10.12.4.0/24 is directly connected, eth0
C 127.0.0.0/8 is directly connected, lo
C 192.168.0.3/32 is directly connected, lo
#sh ip route summary
IP routing table name is Default-IP-Routing-Table(0)
IP routing table maximum-paths : 8
Total number of IPv4 routes : 6
Total number of IPv4 paths : 6
Route Source Networks
kernel 2
connected 4
Total 6
FIB 0
ECMP statistics (active in ASIC):
---------------------------------
Total number of IPv4 ECMP routes : 0
Total number of IPv4 ECMP paths : 0
--------------------------------
#sh ip route database
Codes: K - kernel, C - connected, S - static, R - RIP, B - BGP
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
i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
> - selected route, * - FIB route, p - stale info
IP Route Table for VRF "default"
K *> 0.0.0.0/0 [0/0] via 10.12.4.1, eth0
S 0.0.0.0/0 [1/0] via 10.10.12.2 inactive
C *> 10.10.12.0/24 is directly connected, eth2
C *> 10.12.4.0/24 is directly connected, eth0
C *> 127.0.0.0/8 is directly connected, lo
C *> 192.168.0.3/32 is directly connected, lo
Gateway of last resort is not set
Static Route Object Tracking Using IP SLA
This feature is used to track the state of an object for reachability using IP SLA. A client process such as Virtual Router Redundancy Protocol (VRRP), or RIB, can register its interest in tracking objects and then be notified when a state change occurs.
IP SLA (Service-Level Assurance Protocol) is a Performance Measurement protocol. The protocol is used to Analyze IP Service Levels for IP applications and services. IP SLA's uses active traffic-monitoring technology to monitor continuous traffic on the network.
IP SLA uses Internet Control Message Protocol (ICMP) pings to identify a link failure and notifies to the clients that are registered for tracking. IP SLA is supported from OcNOS 5.0.
The Object Tracking feature provides complete separation between the objects to be tracked and the action to be taken by a client when a tracked object state changes. Thus, several clients such as VRRP, or RIB can register their interest with the tracking process, track the same object, and each take different action when the object changes. The Tracking feature will be present in OAMD.
Each tracked object is identified by a unique number that is specified on the tracking CLI. Client processes use this number to track a specific object.
The tracking process processes events from the tracked objects and notes any change of value. The changes in the tracked object are communicated to interested client processes, either immediately or after a specified delay. The object values are reported as either up or down.
Topology
Static Route Object Tracking
Configuration
R1
R1#conf t | Enter Configure mode. |
R1(config)#interface ce52 | Enter interface mode. |
R1(config-if)#ip address 2.2.2.1/24 | Configure IPv4 address |
R1(config-if)# interface ce0 | Enter interface mode. |
R1(config-if)#ip address 4.4.4.1/24 | Configure IPv4 address |
R1(config)#ip sla 1 | Configure IP SLA with a unique no |
R1(config)#icmp-echo ipv4 2.2.2.2 source-interface ce52 | Configure the icmp-echo using destination Ip Address and source interface name |
R1(config-ip-sla-echo)#threshold 1000 | Configure the threshold value |
R1(config-ip-sla-echo)#timeout 1000 | Configure the Timeout value |
R1(config-ip-sla-echo)#frequency 5 | Configure the frequency value |
R1(config)#time-range tr1 | Configure a time-range |
R1(config-tr)#start-time 11:22 3 july 2021 | Configure a start-time |
R1(config-tr)#end-time after 200 | Configure end-time |
R1(config)#ip sla schedule 1 time-range tr1 | Schedule a IP SLA measurement |
R1(config)# track 1 ip sla 1 reachability | Configure the Track for IP SLA |
R1(config)#ip route 3.3.3.0/24 2.2.2.2 track 1 | Configure the static route with the nexthop address. |
R1(config)#ip route 5.5.5.0/24 4.4.4.2 | Configure the static route with the nexthop address. |
R1(config)#ip route 6.6.6.0/24 2.2.2.2 track 1 | Configure the static route with the nexthop address. |
R1(config)#ip route 6.6.6.0/24 4.4.4.2 10 | Configure the static route with the nexthop address with some delay |
R1(config)#commit | Commit the candidate configuration to the running configuration |
R1(config)#exit | Exit configure mode |
R2
R2#conf t | Enter Configure mode. |
R2(config)#int ce50 | Enter interface mode. |
R2(config-if)#ip address 3.3.3.1/24 | Configure IPv4 address |
R2(config)#int ce52 | Enter interface mode. |
R2(config-if)#ip address 2.2.2.2/24 | Configure IPv4 address |
R2(config)#ip route 6.6.6.0/24 3.3.3.2 | Configure the static route with the nexthop address. |
R2(config)#commit | Commit the candidate configuration to the running configuration |
R2(config)#exit | Exit configure mode |
R3
R3#conf t | Enter Configure mode. |
R3(config)#int xe7 | Enter interface mode. |
R3(config-if)#ip address 5.5.5.1/24 | Configure IPv4 address |
R3(config)#int xe14 | Enter interface mode. |
R3(config-if)#ip address 4.4.4.2/24 | Configure IPv4 address |
R3(config)#commit | Commit the candidate configuration to the running configuration |
R3(config-if)#exit | Exit interface mode. |
R3(config)#ip route 6.6.6.0/24 5.5.5.2 | Configure the static route with the nexthop address. |
R3(config)#commit | Commit the candidate configuration to the running configuration |
R3(config)#exit | Exit configure mode |
R4
R4#conf t | Enter Configure mode. |
R4(config)#interface ce0 | Enter interface mode. |
R4(config-if)#ip address 3.3.3.2/24 | Configure IPv4 address |
R4(config)#interface xe1 | Enter interface mode. |
R4(config-if)#ip address 6.6.6.6/24 | Configure IPv4 address |
R4(config)#interface xe7 | Enter interface mode. |
R4(config-if)#ip address 5.5.5.2/24 | Configure IPv4 address |
R4(config-if)#commit | Commit the candidate configuration to the running configuration |
R4(config-if)#exit | Exit interface mode. |
R4(config)#ip route 2.2.2.0/24 3.3.3.1 | Configure the static route with the nexthop address. |
R4(config)#ip route 4.4.4.0/24 5.5.5.1 | Configure the static route with the nexthop address. |
R4(config)#commit | Commit the candidate configuration to the running configuration |
R1(config)#exit | Exit configure mode |
Validation
R1#sh track
TRACK Id: 1
IP SLA 1 reachability
Reachability is UP
4 changes, last change : 2019 Mar 14 14:53:47
R1#sh ip route track-table
ip route 3.3.3.0 255.255.255.0 2.2.2.2 track 1 state is [up]
ip route 6.6.6.0 255.255.255.0 2.2.2.2 track 1 state is [up]
R1#sh ip route
Codes: K - kernel, C - connected, S - static, R - RIP, B - BGP
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
i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2,
ia - IS-IS inter area, E - EVPN,
v - vrf leaked
* - candidate default
IP Route Table for VRF "default"
C 1.1.1.0/24 is directly connected, xe1, 00:55:39
C 2.2.2.0/24 is directly connected, ce52, 00:55:38
S 3.3.3.0/24 [1/0] via 2.2.2.2, ce52, 00:00:03
C 4.4.4.0/24 is directly connected, xe45, 00:49:50
S 5.5.5.0/24 [1/0] via 4.4.4.2, xe45, 00:08:12
S 6.6.6.0/24 [1/0] via 2.2.2.2, ce52, 00:00:03
C 127.0.0.0/8 is directly connected, lo, 6d23h24m
Gateway of last resort is not set
RTR2
=========================
R2#sh running-config interface ce52
!
interface ce52
ip address 2.2.2.2/24
!
R2#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R2(config)#int ce52
R2(config-if)#no ip address
R2(config-if)#commit
R1#sh ip route track-table 2019 Mar 14 14:55:14.350 : R1 : OAM : CRITI : [IPSLA_ICMP_ECHO_THRESHOLD_CROSSED_2]: IP SLA 1, response packet 15 exceeds the threshold 10000 ms
2019 Mar 14 14:55:14.351 : R1 : OAM : CRITI : [IPSLA_ICMP_ECHO_TIMEOUT_2]: IP SLA 1, response packet 15 exceeds the timeout 10000 ms
2019 Mar 14 14:55:14.351 : R1 : OAM : CRITI : [IPSLA_ICMP_ECHO_DISCONNECT_2]: Stopping IP SLA measurement for sla(1) as timeout(10000) observed for packet(15)
ip route 3.3.3.0 255.255.255.0 2.2.2.2 track 1 state is [down]
ip route 6.6.6.0 255.255.255.0 2.2.2.2 track 1 state is [down]
R1#sh track
TRACK Id: 1
IP SLA 1 reachability
Reachability is DOWN
5 changes, last change : 2019 Mar 14 14:55:14
R1#2019 Mar 14 14:55:19.352 : R1 : OAM : CRITI : [IPSLA_ICMP_ECHO_THRESHOLD_CROSSED_2]: IP SLA 1, response packet 16 exceeds the threshold 10000 ms
2019 Mar 14 14:55:19.353 : R1 : OAM : CRITI : [IPSLA_ICMP_ECHO_TIMEOUT_2]: IP SLA 1, response packet 16 exceeds the timeout 10000 ms
2019 Mar 14 14:55:19.353 : R1 : OAM : CRITI : [IPSLA_ICMP_ECHO_DISCONNECT_2]: Stopping IP SLA measurement for sla(1) as timeout(10000) observed for packet(16)
sh ip route
Codes: K - kernel, C - connected, S - static, R - RIP, B - BGP
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
i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2,
ia - IS-IS inter area, E - EVPN,
v - vrf leaked
* - candidate default
IP Route Table for VRF "default"
C 1.1.1.0/24 is directly connected, xe1, 00:56:16
C 2.2.2.0/24 is directly connected, ce52, 00:56:15
C 4.4.4.0/24 is directly connected, xe45, 00:50:27
S 5.5.5.0/24 [1/0] via 4.4.4.2, xe45, 00:08:49
S 6.6.6.0/24 [10/0] via 4.4.4.2, xe45, 00:00:07
C 127.0.0.0/8 is directly connected, lo, 6d23h24m
Gateway of last resort is not set
R1#ping 6.6.6.6
Press CTRL+C to exit
PING 6.6.6.6 (6.6.6.6) 56(84) bytes of data.
64 bytes from 6.6.6.6: icmp_seq=1 ttl=63 time=0.713 ms
64 bytes from 6.6.6.6: icmp_seq=2 ttl=63 time=0.658 ms
64 bytes from 6.6.6.6: icmp_seq=3 ttl=63 time=0.531 ms
64 bytes from 6.6.6.6: icmp_seq=4 ttl=63 time=0.505 ms
sh ip route database
Codes: K - kernel, C - connected, S - static, R - RIP, B - BGP
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
i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2,
ia - IS-IS inter area, E - EVPN,
v - vrf leaked
> - selected route, * - FIB route, p - stale info
IP Route Table for VRF "default"
C *> 1.1.1.0/24 is directly connected, xe1, 00:56:58
C *> 2.2.2.0/24 is directly connected, ce52, 00:56:57
S 3.3.3.0/24 [1/0] via 2.2.2.2, ce52, 00:01:22
C *> 4.4.4.0/24 is directly connected, xe45, 00:51:09
S *> 5.5.5.0/24 [1/0] via 4.4.4.2, xe45, 00:09:31
S *> 6.6.6.0/24 [10/0] via 4.4.4.2, xe45, 00:00:49
S 6.6.6.0/24 [1/0] via 2.2.2.2, ce52, 00:01:22
C *> 127.0.0.0/8 is directly connected, lo, 6d23h25m
R1#sh ip sla summary
IP SLA Operation Summary
Codes: * active, ^ inactive
ID Type Destination Stats Return Last
(usec) Code Run
-------------------------------------------------------------------
*1 icmp-echo 2.2.2.2 14000 OK 2019 Mar 14 14:56:26
RTR2(5014)
===========================================
R2#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R2(config)#int ce52
R2(config-if)#ip address 2.2.2.2/24
R2(config-if)#commit
R1#sh track
TRACK Id: 1
IP SLA 1 reachability
Reachability is UP
10 changes, last change : 2019 Mar 14 14:56:32
R1#sh ip route track-table
ip route 3.3.3.0 255.255.255.0 2.2.2.2 track 1 state is [up]
ip route 6.6.6.0 255.255.255.0 2.2.2.2 track 1 state is [up]
R1#sh ip route
Codes: K - kernel, C - connected, S - static, R - RIP, B - BGP
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
i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2,
ia - IS-IS inter area, E - EVPN,
v - vrf leaked
* - candidate default
IP Route Table for VRF "default"
C 1.1.1.0/24 is directly connected, xe1, 00:57:39
C 2.2.2.0/24 is directly connected, ce52, 00:57:38
S 3.3.3.0/24 [1/0] via 2.2.2.2, ce52, 00:00:11
C 4.4.4.0/24 is directly connected, xe45, 00:51:50
S 5.5.5.0/24 [1/0] via 4.4.4.2, xe45, 00:10:12
S 6.6.6.0/24 [1/0] via 2.2.2.2, ce52, 00:00:11
C 127.0.0.0/8 is directly connected, lo, 6d23h26m
R1#sh ip route database
Codes: K - kernel, C - connected, S - static, R - RIP, B - BGP
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
i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2,
ia - IS-IS inter area, E - EVPN,
v - vrf leaked
> - selected route, * - FIB route, p - stale info
IP Route Table for VRF "default"
C *> 1.1.1.0/24 is directly connected, xe1, 01:14:49
C *> 2.2.2.0/24 is directly connected, ce52, 01:14:48
S *> 3.3.3.0/24 [1/0] via 2.2.2.2, ce52, 00:17:21
C *> 4.4.4.0/24 is directly connected, xe45, 01:09:00
S *> 5.5.5.0/24 [1/0] via 4.4.4.2, xe45, 00:27:22
S *> 6.6.6.0/24 [1/0] via 2.2.2.2, ce52, 00:17:21
S 6.6.6.0/24 [10/0] via 4.4.4.2, xe45, 00:17:25
C *> 127.0.0.0/8 is directly connected, lo, 6d23h43m