OcNOS-SP : Layer 3 Guide : Layer 3 Unicast Configuration Guide : Static Routes
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.
For details about the commands used in these examples, see the Unicast Routing Information Base Command Reference.
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 secondary
Configure the IP address on this interface, and specify a 32-bit mask, making it a host address.
(config-if)#commit
Commit the candidate configuration to the running configuration
(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.
(config-if)#commit
Commit the candidate configuration to the running configuration
(config)#exit
Exit configure mode
R2
 
#configure terminal
Enter configure mode.
(config)#interface lo
Enter interface mode.
(config-if)#ip address 192.168.0.2/32 secondary
Configure the IP address on this interface, and specify a 32-bit mask, making it a host address.
(config-if)#commit
Commit the candidate configuration to the running configuration
(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.
(config-if)#commit
Commit the candidate configuration to the running configuration
(config)#exit
Exit configure mode
R3
 
#configure terminal
Enter configure mode.
(config)#interface lo
Enter interface mode.
(config-if)#ip address 192.168.0.3/32 secondary
Configure the IP address on this interface, and specify a 32-bit mask, making it a host address.
(config-if)#commit
Commit the candidate configuration to the running configuration
(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.
(config-if)#commit
Commit the candidate configuration to the running configuration
(config)#exit
Exit configure mode
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
IPv6 Static Routing
This example shows complete configuration to enable IPv6 static routing in a simple network topology.
Note: IPv6 static route with interface alone as gateway (without gateway IPv6 address) is not supported.
Topology
IPv6 static routing
Configuration
R1
 
R1#conf t
Enter Configure mode.
R1(config)#interface lo
Enter interface mode.
R1(config-if)#ipv6 address 1111::1/128
Configure IPv6 address
R1(config-if)#commit
Commit the candidate configuration to the running configuration
R1(config-if)#exit
Exit interface mode.
R1(config)#ipv6 route 6000::/64 5000::2
Configure IPv6 Static route to reach remote network with R2 as nexthop
R1(config)#ipv6 route 2222::2/128 5000::2
Configure IPv6 static route to reach R2 lo with R2 as nexthop
R1(config)#ipv6 route 3333::3/128 5000::2
Configure IPv6 static route to reach R3 lo with R2 as nexthop
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 lo
Enter interface mode.
R2(config-if)#ipv6 address 2222::2/128
Configure IPv6 address
R2(config)#commit
Commit the candidate configuration to the running configuration
R2(config)#exit
Exit configure mode
R2(config)#ipv6 route 1111::1/128 5000::1
Configure IPv6 static route to reach R1 lo with R1 as nexthop
R2(config)#ipv6 route 3333::3/128 6000::1
Configure IPv6 static route to reach R3 lo with R3 as nexthop
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 lo
Enter interface mode.
R3(config-if)#ipv6 add 3333::3/128
Configure IPv6 address
R3(config)#commit
Commit the candidate configuration to the running configuration
R3(config-if)#exit
Exit interface mode.
R3(config)#ipv6 route ::/0 6000::2
Configure Default IPv6 Static route with R2 as nexthop
R3(config)#commit
Commit the candidate configuration to the running configuration
R3(config)#exit
Exit configure mode
Validation
show ipv6 route, show ipv6 route summary, show ipv6 route database
R1
R1#show ipv6 route
IPv6 Routing Table
Codes: K - kernel route, C - connected, S - static, R - RIP, O - OSPF,
IA - OSPF inter area, E1 - OSPF external type 1,
E2 - OSPF external type 2, E - EVPN N1 - OSPF NSSA external type 1,
N2 - OSPF NSSA external type 2, i - IS-IS, B - BGP
Timers: Uptime
 
IP Route Table for VRF "default"
C ::1/128 via ::, lo, 20:51:02
C 1111::1/128 via ::, lo, 00:01:13
S 2222::2/128 [1/0] via 5000::2, xe3, 00:00:32
S 3333::3/128 [1/0] via 5000::2, xe3, 00:00:13
C 5000::/64 via ::, xe3, 00:01:42
S 6000::/64 [1/0] via 5000::2, xe3, 00:00:54
C fe80::/64 via ::, ce45, 01:45:19
R1#show ipv6 route summary
IPv6 routing table name is Default-IPv6-Routing-Table(0)
IPv6 routing table maximum-paths : 8
Total number of IPv6 routes : 7
Total number of IPv6 paths : 7
Pending routes (due to route max reached): 0
Route Source Networks
connected 4
static 3
Total 7
FIB 7
 
ECMP statistics (active in ASIC):
---------------------------------
Total number of IPv6 ECMP routes : 0
Total number of IPv6 ECMP paths : 0
R1#
R1#show ipv6 route database
IPv6 Routing Table
Codes: K - kernel route, C - connected, S - static, R - RIP, O - OSPF,
IA - OSPF inter area, E1 - OSPF external type 1,
E2 - OSPF external type 2, E - EVPN N1 - OSPF NSSA external type 1,
N2 - OSPF NSSA external type 2, i - IS-IS, B - BGP
> - selected route, * - FIB route,p - stale info
Timers: Uptime
 
IP Route Table for VRF "default"
C *> ::1/128 via ::, lo, 20:51:19
C *> 1111::1/128 via ::, lo, 00:01:30
S *> 2222::2/128 [1/0] via 5000::2, xe3, 00:00:49
S *> 3333::3/128 [1/0] via 5000::2, xe3, 00:00:30
C *> 5000::/64 via ::, xe3, 00:01:59
S *> 6000::/64 [1/0] via 5000::2, xe3, 00:01:11
C *> fe80::/64 via ::, ce45, 01:45:36
C fe80::/64 via ::, ce44, 01:45:36
C fe80::/64 via ::, xe39, 01:45:36
C fe80::/64 via ::, xe32, 01:45:36
C fe80::/64 via ::, xe29, 01:45:36
C fe80::/64 via ::, xe13, 01:45:36
C fe80::/64 via ::, ce46, 03:56:36
C fe80::/64 via ::, ce43, 03:56:36
C fe80::/64 via ::, xe25, 03:56:36
C fe80::/64 via ::, xe23, 03:56:36
C fe80::/64 via ::, xe3, 03:56:36
C fe80::/64 via ::, xe34, 20:41:33
C fe80::/64 via ::, xe33, 20:41:33
C fe80::/64 via ::, xe36, 20:50:48
C fe80::/64 via ::, xe22, 20:50:48
C fe80::/64 via ::, xe21, 20:50:48
C fe80::/64 via ::, xe10, 20:50:48
C fe80::/64 via ::, xe9, 20:50:48
R1#
 
R2
 
R2#show ipv6 route
IPv6 Routing Table
Codes: K - kernel route, C - connected, S - static, R - RIP, O - OSPF,
IA - OSPF inter area, E1 - OSPF external type 1,
E2 - OSPF external type 2, E - EVPN N1 - OSPF NSSA external type 1,
N2 - OSPF NSSA external type 2, i - IS-IS, B - BGP
Timers: Uptime
 
IP Route Table for VRF "default"
C ::1/128 via ::, lo, 03:59:56
S 1111::1/128 [1/0] via 5000::1, xe3, 00:00:46
C 2222::2/128 via ::, lo, 00:01:27
S 3333::3/128 [1/0] via 6000::1, xe5, 00:00:26
C 5000::/64 via ::, xe3, 00:01:52
C 6000::/64 via ::, xe5, 00:01:10
C fe80::/64 via ::, vlan1.2, 01:17:00
R2#
R2#show ipv6 route summary
IPv6 routing table name is Default-IPv6-Routing-Table(0)
IPv6 routing table maximum-paths : 8
Total number of IPv6 routes : 7
Total number of IPv6 paths : 7
Pending routes (due to route max reached): 0
Route Source Networks
connected 5
static 2
Total 7
FIB 7
 
ECMP statistics (active in ASIC):
---------------------------------
Total number of IPv6 ECMP routes : 0
Total number of IPv6 ECMP paths : 0
R2#show ipv6 route database
IPv6 Routing Table
Codes: K - kernel route, C - connected, S - static, R - RIP, O - OSPF,
IA - OSPF inter area, E1 - OSPF external type 1,
E2 - OSPF external type 2, E - EVPN N1 - OSPF NSSA external type 1,
N2 - OSPF NSSA external type 2, i - IS-IS, B - BGP
> - selected route, * - FIB route,p - stale info
Timers: Uptime
 
IP Route Table for VRF "default"
C *> ::1/128 via ::, lo, 04:00:02
S *> 1111::1/128 [1/0] via 5000::1, xe3, 00:00:52
C *> 2222::2/128 via ::, lo, 00:01:33
S *> 3333::3/128 [1/0] via 6000::1, xe5, 00:00:32
C *> 5000::/64 via ::, xe3, 00:01:58
C *> 6000::/64 via ::, xe5, 00:01:16
C *> fe80::/64 via ::, vlan1.2, 01:17:06
C fe80::/64 via ::, vlan1.1, 01:17:06
C fe80::/64 via ::, xe29, 01:48:22
C fe80::/64 via ::, xe27, 01:48:22
C fe80::/64 via ::, ce47, 03:59:22
C fe80::/64 via ::, ce46, 03:59:22
C fe80::/64 via ::, ce45, 03:59:22
C fe80::/64 via ::, ce43, 03:59:22
C fe80::/64 via ::, xe42, 03:59:22
C fe80::/64 via ::, xe41, 03:59:22
C fe80::/64 via ::, xe34, 03:59:22
C fe80::/64 via ::, xe33, 03:59:22
C fe80::/64 via ::, xe32, 03:59:22
C fe80::/64 via ::, xe31, 03:59:22
C fe80::/64 via ::, xe25, 03:59:22
C fe80::/64 via ::, xe23, 03:59:22
C fe80::/64 via ::, xe5, 03:59:22
C fe80::/64 via ::, xe3, 03:59:22
R2#
R3
 
R3#show ipv6 route
IPv6 Routing Table
Codes: K - kernel route, C - connected, S - static, R - RIP, O - OSPF,
IA - OSPF inter area, E1 - OSPF external type 1,
E2 - OSPF external type 2, E - EVPN N1 - OSPF NSSA external type 1,
N2 - OSPF NSSA external type 2, i - IS-IS, B - BGP
Timers: Uptime
 
IP Route Table for VRF "default"
S ::/0 [1/0] via 6000::2, xe5, 00:00:07
C ::1/128 via ::, lo, 20:46:35
C 3333::3/128 via ::, lo, 00:00:57
C 6000::/64 via ::, xe5, 00:00:46
C fe80::/64 via ::, ce43, 01:50:07
R3#show ipv6 route summary
IPv6 routing table name is Default-IPv6-Routing-Table(0)
IPv6 routing table maximum-paths : 8
Total number of IPv6 routes : 5
Total number of IPv6 paths : 5
Pending routes (due to route max reached): 0
Route Source Networks
connected 4
static 1
Total 5
FIB 5
 
ECMP statistics (active in ASIC):
---------------------------------
Total number of IPv6 ECMP routes : 0
Total number of IPv6 ECMP paths : 0
R3#
R3#show ipv6 route database
IPv6 Routing Table
Codes: K - kernel route, C - connected, S - static, R - RIP, O - OSPF,
IA - OSPF inter area, E1 - OSPF external type 1,
E2 - OSPF external type 2, E - EVPN N1 - OSPF NSSA external type 1,
N2 - OSPF NSSA external type 2, i - IS-IS, B - BGP
> - selected route, * - FIB route,p - stale info
Timers: Uptime
 
IP Route Table for VRF "default"
S *> ::/0 [1/0] via 6000::2, xe5, 00:00:18
C *> ::1/128 via ::, lo, 20:46:46
C *> 3333::3/128 via ::, lo, 00:01:08
C *> 6000::/64 via ::, xe5, 00:00:57
C *> fe80::/64 via ::, ce43, 01:50:18
C fe80::/64 via ::, xe32, 01:50:18
C fe80::/64 via ::, xe29, 01:50:18
C fe80::/64 via ::, xe15, 01:50:18
C fe80::/64 via ::, xe3, 01:50:18
C fe80::/64 via ::, ce47, 04:01:18
C fe80::/64 via ::, ce45, 04:01:18
C fe80::/64 via ::, xe42, 04:01:18
C fe80::/64 via ::, xe41, 04:01:18
C fe80::/64 via ::, xe5, 04:01:18
C fe80::/64 via ::, xe34, 20:46:15
C fe80::/64 via ::, xe33, 20:46:15
C fe80::/64 via ::, xe12, 20:46:15
C fe80::/64 via ::, xe11, 20:46:15