OcNOS-DC 6.4.2 : Layer 3 Guide : 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.
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