OcNOS-SP : Layer 3 Guide : Layer 3 Unicast Configuration Guide : OSPFv2 : Cost
Cost
A route can be made the preferred route by changing its cost. In this example, cost has been configured to make R2 the next hop for R1.
The default cost for each interface is 1. Interface eth2 on R2 has a cost of 100, and Interface eth2 on R3 has a cost of 150. The total cost to reach 10.10.14.0/24 (R4) through R2 and R3 is computed as follows:
R2: 1+100 = 101
R3: 1+150 = 151
Therefore, R1 chooses R2 as its next hop to destination 10.10.14.0/24 because it has the lower cost.
Topology
Figure 8-68: Configure Cost Topology
Configuration
R1
 
#configure terminal
Enter configure mode.
(config)#router ospf 100
Configure the routing process, and specify the Process ID (100). The Process ID should be a unique positive integer identifying the routing process.
(config-router)#network 10.10.9.0/24 area 0
Define interfaces on which OSPF runs, and associate the area ID (0) with the interface (area ID 0 specifies the backbone area).
(config-router)#network 10.10.10.0/24 area 0
Define interfaces on which OSPF runs, and associate the area ID (0) with the interface (area ID 0 specifies the backbone area).
(config-router)#network 10.10.12.0/24 area 0
Define interfaces on which OSPF runs, and associate the area ID (0) with the interface (area ID 0 specifies the backbone area).
(config-router)#commit
Commit the candidate configuration to the running configuration.
R2
 
(config)#interface eth2
Enter interface mode.
(config-if)#ip ospf cost 100
Set the OSPF cost of this link to 100.
(config-if)#exit
Exit interface mode.
(config)#router ospf 100
Configure the routing process, and specify the Process ID (100). The Process ID should be a unique positive integer identifying the routing process.
(config-router)#network 10.10.10.0/24 area 0
Define the interfaces on which OSPF runs, and associate the area ID (0) with the interface.
(config-router)#network 10.10.11.0/24 area 0
Define the interfaces on which OSPF runs, and associate the area ID (0) with the interface.
(config-router)#commit
Commit the candidate configuration to the running configuration.
R3
 
(config)#interface eth2
Enter interface mode.
(config-if)#ip ospf cost 150
Set the OSPF cost of this link to 100.
(config-if)#exit
Exit interface mode.
(config)#router ospf 100
Configure the routing process, and specify the Process ID (100). The Process ID should be a unique positive integer identifying the routing process.
(config-router)#network 10.10.12.0/24 area 0
Define interfaces on which OSPF runs, and associate the area ID (0) with the interface.
(config-router)#network 10.10.13.0/24 area 0
Define interfaces on which OSPF runs, and associate the area ID (0) with the interface.
(config-router)#commit
Commit the candidate configuration to the running configuration.
R4
 
(config)#router ospf 100
Configure the routing process, and specify the Process ID (100). The Process ID should be a unique positive integer identifying the routing process.
(config-router)#network 10.10.11.0/24 area 0
Define interfaces on which OSPF runs, and associate the area ID 0) with the interface.
(config-router)#network 10.10.13.0/24 area 0
Define interfaces on which OSPF runs, and associate the area ID (0) with the interface.
(config-router)#network 10.10.14.0/24 area 0
Define interfaces on which OSPF runs, and associate the area ID (0) with the interface.
(config-router)#commit
Commit the candidate configuration to the running configuration.
Validation
R1
#show ip ospf route
 
OSPF process 100:
Codes: C - connected, D - Discard, 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
 
C 10.10.9.0/24 [1] is directly connected, eth2, Area 0.0.0.0
C 10.10.10.0/24 [1] is directly connected, eth3, Area 0.0.0.0
O 10.10.11.0/24 [101] via 10.10.10.11, eth3, Area 0.0.0.0
C 10.10.12.0/24 [1] is directly connected, eth1, Area 0.0.0.0
O 10.10.13.0/24 [102] via 10.10.10.11, eth3, Area 0.0.0.0
O 10.10.14.0/24 [102] via 10.10.10.11, eth3, Area 0.0.0.0
 
#sh ip ospf interface
eth3 is up, line protocol is up
Internet Address 10.10.10.10/24, Area 0.0.0.0, MTU 1500
Process ID 100, VRF (default), Router ID 10.12.26.88, Network Type BROADCAST, Cost: 1
Transmit Delay is 1 sec, State DR, Priority 1, TE Metric 1
Designated Router (ID) 10.12.26.88, Interface Address 10.10.10.10
Backup Designated Router (ID) 10.12.26.89, Interface Address 10.10.10.11
Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
Hello due in 00:00:03
Neighbor Count is 1, Adjacent neighbor count is 1
Suppress hello for 0 neighbor(s)
Hello received 43 sent 69, DD received 3 sent 4
LS-Req received 1 sent 1, LS-Upd received 16 sent 18
LS-Ack received 10 sent 11, Discarded 0
No authentication
eth2 is up, line protocol is up
Internet Address 10.10.9.10/24, Area 0.0.0.0, MTU 1500
Process ID 100, VRF (default), Router ID 10.12.26.88, Network Type BROADCAST, Cost: 1
Transmit Delay is 1 sec, State DR, Priority 1, TE Metric 1
Designated Router (ID) 10.12.26.88, Interface Address 10.10.9.10
No backup designated router on this network
Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
Hello due in 00:00:02
Neighbor Count is 0, Adjacent neighbor count is 0
Suppress hello for 0 neighbor(s)
Hello received 0 sent 68, DD received 0 sent 0
LS-Req received 0 sent 0, LS-Upd received 0 sent 0
LS-Ack received 0 sent 0, Discarded 0
No authentication
eth1 is up, line protocol is up
Internet Address 10.10.12.10/24, Area 0.0.0.0, MTU 1500
Process ID 100, VRF (default), Router ID 10.12.26.88, Network Type BROADCAST, Cost: 1
Transmit Delay is 1 sec, State DR, Priority 1, TE Metric 1
Designated Router (ID) 10.12.26.88, Interface Address 10.10.12.10
Backup Designated Router (ID) 10.12.26.90, Interface Address 10.10.12.11
Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
Hello due in 00:00:01
Neighbor Count is 1, Adjacent neighbor count is 1
Suppress hello for 0 neighbor(s)
Hello received 29 sent 66, DD received 3 sent 4
LS-Req received 1 sent 1, LS-Upd received 10 sent 12
LS-Ack received 10 sent 9, Discarded 0
No authentication
R2
#sh ip ospf route
 
OSPF process 100:
Codes: C - connected, D - Discard, 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
 
O 10.10.9.0/24 [2] via 10.10.10.10, eth1, Area 0.0.0.0
C 10.10.10.0/24 [1] is directly connected, eth1, Area 0.0.0.0
C 10.10.11.0/24 [100] is directly connected, eth2, Area 0.0.0.0
O 10.10.12.0/24 [2] via 10.10.10.10, eth1, Area 0.0.0.0
O 10.10.13.0/24 [101] via 10.10.11.11, eth2, Area 0.0.0.0
O 10.10.14.0/24 [101] via 10.10.11.11, eth2, Area 0.0.0.0
 
#sh ip ospf interface
eth2 is up, line protocol is up
Internet Address 10.10.11.10/24, Area 0.0.0.0, MTU 1500
Process ID 100, VRF (default), Router ID 10.12.26.89, Network Type BROADCAST, Cost: 100
Transmit Delay is 1 sec, State DR, Priority 1, TE Metric 100
Designated Router (ID) 10.12.26.89, Interface Address 10.10.11.10
Backup Designated Router (ID) 10.12.26.92, Interface Address 10.10.11.11
Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
Hello due in 00:00:01
Neighbor Count is 1, Adjacent neighbor count is 1
Suppress hello for 0 neighbor(s)
Hello received 56 sent 77, DD received 3 sent 4
LS-Req received 1 sent 1, LS-Upd received 11 sent 7
LS-Ack received 4 sent 8, Discarded 0
No authentication
eth1 is up, line protocol is up
Internet Address 10.10.10.11/24, Area 0.0.0.0, MTU 1500
Process ID 100, VRF (default), Router ID 10.12.26.89, Network Type BROADCAST, Cost: 1
Transmit Delay is 1 sec, State Backup, Priority 1, TE Metric 1
Designated Router (ID) 10.12.26.88, Interface Address 10.10.10.10
Backup Designated Router (ID) 10.12.26.89, Interface Address 10.10.10.11
Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
Hello due in 00:00:07
Neighbor Count is 1, Adjacent neighbor count is 1
Suppress hello for 0 neighbor(s)
Hello received 74 sent 75, DD received 4 sent 3
LS-Req received 1 sent 1, LS-Upd received 18 sent 16
LS-Ack received 10 sent 12, Discarded 0
No authentication
 
R3
#sh ip ospf route
 
OSPF process 100:
Codes: C - connected, D - Discard, 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
 
O 10.10.9.0/24 [2] via 10.10.12.10, eth1, Area 0.0.0.0
O 10.10.10.0/24 [2] via 10.10.12.10, eth1, Area 0.0.0.0
O 10.10.11.0/24 [102] via 10.10.12.10, eth1, Area 0.0.0.0
C 10.10.12.0/24 [1] is directly connected, eth1, Area 0.0.0.0
O 10.10.13.0/24 [103] via 10.10.12.10, eth1, Area 0.0.0.0
O 10.10.14.0/24 [103] via 10.10.12.10, eth1, Area 0.0.0.0
 
#sh ip ospf interface
eth2 is up, line protocol is up
Internet Address 10.10.13.10/24, Area 0.0.0.0, MTU 1500
Process ID 100, VRF (default), Router ID 10.12.26.90, Network Type BROADCAST, Cost: 150
Transmit Delay is 1 sec, State DR, Priority 1, TE Metric 150
Designated Router (ID) 10.12.26.90, Interface Address 10.10.13.10
Backup Designated Router (ID) 10.12.26.92, Interface Address 10.10.13.11
Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
Hello due in 00:00:02
Neighbor Count is 1, Adjacent neighbor count is 1
Suppress hello for 0 neighbor(s)
Hello received 85 sent 94, DD received 3 sent 4
LS-Req received 0 sent 0, LS-Upd received 3 sent 4
LS-Ack received 3 sent 3, Discarded 0
No authentication
eth1 is up, line protocol is up
Internet Address 10.10.12.11/24, Area 0.0.0.0, MTU 1500
Process ID 100, VRF (default), Router ID 10.12.26.90, Network Type BROADCAST, Cost: 1
Transmit Delay is 1 sec, State Backup, Priority 1, TE Metric 1
Designated Router (ID) 10.12.26.88, Interface Address 10.10.12.10
Backup Designated Router (ID) 10.12.26.90, Interface Address 10.10.12.11
Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
Hello due in 00:00:01
Neighbor Count is 1, Adjacent neighbor count is 1
Suppress hello for 0 neighbor(s)
Hello received 92 sent 92, DD received 4 sent 3
LS-Req received 1 sent 1, LS-Upd received 12 sent 10
LS-Ack received 8 sent 10, Discarded 0
No authentication
 
R4
#sh ip ospf route
 
OSPF process 100:
Codes: C - connected, D - Discard, 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
 
O 10.10.9.0/24 [3] via 10.10.11.10, eth3, Area 0.0.0.0
via 10.10.13.10, eth1, Area 0.0.0.0
O 10.10.10.0/24 [2] via 10.10.11.10, eth3, Area 0.0.0.0
C 10.10.11.0/24 [1] is directly connected, eth3, Area 0.0.0.0
O 10.10.12.0/24 [2] via 10.10.13.10, eth1, Area 0.0.0.0
C 10.10.13.0/24 [1] is directly connected, eth1, Area 0.0.0.0
C 10.10.14.0/24 [1] is directly connected, eth2, Area 0.0.0.0
 
#sh ip ospf interface
eth3 is up, line protocol is up
Internet Address 10.10.11.11/24, Area 0.0.0.0, MTU 1500
Process ID 100, VRF (default), Router ID 10.12.26.92, Network Type BROADCAST, Cost: 1
Transmit Delay is 1 sec, State Backup, Priority 1, TE Metric 1
Designated Router (ID) 10.12.26.89, Interface Address 10.10.11.10
Backup Designated Router (ID) 10.12.26.92, Interface Address 10.10.11.11
Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
Hello due in 00:00:04
Neighbor Count is 1, Adjacent neighbor count is 1
Suppress hello for 0 neighbor(s)
Hello received 95 sent 96, DD received 4 sent 3
LS-Req received 1 sent 1, LS-Upd received 7 sent 11
LS-Ack received 7 sent 5, Discarded 0
No authentication
eth2 is up, line protocol is up
Internet Address 10.10.14.10/24, Area 0.0.0.0, MTU 1500
Process ID 100, VRF (default), Router ID 10.12.26.92, Network Type BROADCAST, Cost: 1
Transmit Delay is 1 sec, State DR, Priority 1, TE Metric 1
Designated Router (ID) 10.12.26.92, Interface Address 10.10.14.10
No backup designated router on this network
Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
Hello due in 00:00:10
Neighbor Count is 0, Adjacent neighbor count is 0
Suppress hello for 0 neighbor(s)
Hello received 0 sent 95, DD received 0 sent 0
LS-Req received 0 sent 0, LS-Upd received 0 sent 0
LS-Ack received 0 sent 0, Discarded 0
No authentication
eth1 is up, line protocol is up
Internet Address 10.10.13.11/24, Area 0.0.0.0, MTU 1500
Process ID 100, VRF (default), Router ID 10.12.26.92, Network Type BROADCAST, Cost: 1
Transmit Delay is 1 sec, State Backup, Priority 1, TE Metric 1
Designated Router (ID) 10.12.26.90, Interface Address 10.10.13.10
Backup Designated Router (ID) 10.12.26.92, Interface Address 10.10.13.11
Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
Hello due in 00:00:00
Neighbor Count is 1, Adjacent neighbor count is 1
Suppress hello for 0 neighbor(s)
Hello received 92 sent 93, DD received 4 sent 3
LS-Req received 0 sent 0, LS-Upd received 4 sent 3
LS-Ack received 3 sent 3, Discarded 0
No authentication
Last modified date: 10/16/2023