On the previous article I’ve discuss about OSPF Cost Concept. and in this article I’ve discuss about OSPF Cost Manipulation config on Cisco. Here’s the topology :
First, make sure the ospf already running on your lab. in this article I’m use the EVE-NG and all of routers use 10Mb/s interface speed.
Configure IP Address on R1 :
R1(config)#int fa0/0 R1(config-if)#ip add 12.12.12.1 255.255.255.0 R1(config-if)#no shut R1(config-if)#exit R1(config)#int fa0/1 R1(config-if)#ip add 13.13.13.1 255.255.255.0 R1(config-if)#no shut R1(config-if)#exit R1(config)#int lo1 R1(config-if)#ip add 192.168.10.1 255.255.255.0 R1(config-if)#exit R1(config)#
Configure IP Address on R2:
R2(config)#int fa0/0 R2(config-if)#ip add 12.12.12.2 255.255.255.0 R2(config-if)#no shut R2(config-if)#exit R2(config)#int fa0/1 R2(config-if)#ip add 23.23.23.1 255.255.255.0 R2(config-if)#no shut R2(config-if)#exit R2(config)#
Configure IP Address on R3 :
R3(config)#int fa0/0 R3(config-if)#ip add 13.13.13.2 255.255.255.0 R3(config-if)#no shut R3(config-if)#exit R3(config)#int fa0/1 R3(config-if)#ip add 23.2.23.2 255.255.255.0 R3(config-if)#no shut R3(config-if)#exit R3(config)#int fa1/0 R3(config-if)#ip add 192.168.100.1 255.255.255.0 R3(config-if)#no shut R3(config-if)#exit R3(config)#
Configure PC that connect to R3 :
VPCS> show ip NAME : VPCS[1] IP/MASK : 192.168.100.2/24 GATEWAY : 192.168.100.1 DNS : MAC : 00:50:79:66:68:04 LPORT : 20000 RHOST:PORT : 127.0.0.1:30000 MTU : 1500 VPCS>
Now configure OSPF on all routers.
Configure OSPF on R1 :
R1(config)#router ospf 1 R1(config-router)#router R1(config-router)#router-id 1.1.1.1 R1(config-router)#network 12.12.12.0 0.0.0.255 area 0 R1(config-router)#network 13.13.13.0 0.0.0.255 area 0 R1(config-router)#network 192.168.10.0 0.0.0.255 area 0 R1(config-router)#exit
Configure OSPF on R2 :
R2(config)#router ospf 1 R2(config-router)#router R2(config-router)#router-id 2.2.2.2 R2(config-router)#network 12.12.12.0 0.0.0.255 area 0 R2(config-router)#network 23.23.23.0 0.0.0.255 area 0 R2(config-router)#exit
Configure OSPF on R3 :
R3(config)#router ospf 1 R3(config-router)#router-id 3.3.3.3 R3(config-router)#network 23.23.23.0 0.0.0.255 area 0 R3(config-router)#network 13.13.13.0 0.0.0.255 area 0 R3(config-router)#network 192.168.100.0 0.0.0.255 area 0 R3(config-router)#exit R3(config)#
After that, show ospf routing table on R1 :
R1#show ip route ospf 23.0.0.0/24 is subnetted, 1 subnets O 23.23.23.0 [110/20] via 13.13.13.2, 00:14:29, FastEthernet0/1 [110/20] via 12.12.12.2, 00:15:51, FastEthernet0/0 O 192.168.100.0/24 [110/11] via 13.13.13.2, 00:14:11, FastEthernet0/1 R1#
Look at the routing table R1, route through 192.168.100.0 use 13.13.13.2 (R3) as gateway.
Because the interface router is 10Mb/s, definitely the cost value is 10.
- R1 -> R3 : costvalue + metric (10+1) = 11
- R1 -> R2 -> R3 : 10+10+1 = 21
Based on ospf cost calculation, router will select the R3 as a best path through 192.168.100.0 network.
Now, how if we need to change the best path or do a loadbalance routing so both path will be used by R1 ? based on cost calculation above, we need to increase the cost value through R2 as the following example we need to equal the cost value so route will be loadbalance.
Increate cost value on interface fa0/1 :
R1(config)#int fa0/1 R1(config-if)#ip osp R1(config-if)#ip ospf co R1(config-if)#ip ospf cost 20 R1(config-if)#end
See the routing table on R1 :
R1#show ip route ospf 23.0.0.0/24 is subnetted, 1 subnets O 23.23.23.0 [110/20] via 12.12.12.2, 00:26:30, FastEthernet0/0 O 192.168.100.0/24 [110/21] via 13.13.13.2, 00:00:01, FastEthernet0/1 [110/21] via 12.12.12.2, 00:00:01, FastEthernet0/0 R1#
Look at the routing table above, routing through 192.168.100.0 network already loadbalance with the cost calculation bellow :
- R1 -> R3 : 20+1 = 21
- R1 -> R2 -> R3 : 10+10+1 = 21