Categories R&S

OSPF – Implement and troubleshoot path preference – Cost

Let’s now take a look at how to influence path preference using the cost command.

 

Requirements:

 

Ensure that the traffic from R4 to R3 loopback goes via R2.

 

Diagram:

OSPF - Implement and troubleshoot path preference – Cost

 

Configuration and verification:

At the moment, if we want to reach R3 loopback from R4, the traffic will go through R1.

R4#sh ip route 3.3.3.3
Routing entry for 3.3.3.3/32
  Known via "ospf 10", distance 110, metric 3, type inter area
  Last update from 10.10.14.1 on Ethernet0/0, 00:04:21 ago
  Routing Descriptor Blocks:
  * 10.10.14.1, from 11.11.11.11, 00:04:21 ago, via Ethernet0/0
      Route metric is 3, traffic share count is 1
R4#traceroute 3.3.3.3
Type escape sequence to abort.
Tracing the route to 3.3.3.3
VRF info: (vrf in name/id, vrf out name/id)
  1 10.10.14.1 1 msec 1 msec 0 msec
  2 10.10.1.3 2 msec 0 msec *

 

In R4 OSPF database, the metric is the same:

R4#sh ip ospf database summary 3.3.3.3
            OSPF Router with ID (44.44.44.44) (Process ID 10)
                Summary Net Link States (Area 2)
  Routing Bit Set on this LSA in topology Base with MTID 0
  LS age: 335
  Options: (No TOS-capability, DC, Upward)
  LS Type: Summary Links(Network)
  Link State ID: 3.3.3.3 (summary Network Number)
  Advertising Router: 11.11.11.11
  LS Seq Number: 80000001
  Checksum: 0xC73B
  Length: 28
  Network Mask: /32
        MTID: 0         Metric: 2

  LS age: 330
  Options: (No TOS-capability, DC, Upward)
  LS Type: Summary Links(Network)
  Link State ID: 3.3.3.3 (summary Network Number)
  Advertising Router: 22.22.22.22
  LS Seq Number: 80000001
  Checksum: 0x7C5A
  Length: 28
  Network Mask: /32
        MTID: 0         Metric: 2

 

The cost for the link to R2 and R1 is different:

R4#sh ip ospf int Eth 0/0
Ethernet0/0 is up, line protocol is up
  Internet Address 10.10.14.2/30, Area 2, Attached via Interface Enable
  Process ID 10, Router ID 44.44.44.44, Network Type POINT_TO_POINT, Cost: 1
  Topology-MTID    Cost    Disabled    Shutdown      Topology Name

R4#sh ip ospf int Eth 0/1
Ethernet0/1 is up, line protocol is up
  Internet Address 10.10.24.2/30, Area 2, Attached via Interface Enable
  Process ID 10, Router ID 44.44.44.44, Network Type POINT_TO_POINT, Cost: 10

 

We can influence the path by modifying the cost of the local link on R4.

R4(config)#int Eth 0/0
R4(config-if)#ip ospf cost 11

R4#sh ip ospf int Eth 0/0
Ethernet0/0 is up, line protocol is up
  Internet Address 10.10.14.2/30, Area 2, Attached via Interface Enable
  Process ID 10, Router ID 44.44.44.44, Network Type POINT_TO_POINT, Cost: 11

 

The route to R3 loopback is now preferred via R2:

R4#sh ip route 3.3.3.3
Routing entry for 3.3.3.3/32
  Known via "ospf 10", distance 110, metric 12, type inter area
  Last update from 10.10.24.1 on Ethernet0/1, 00:00:37 ago
  Routing Descriptor Blocks:
  * 10.10.24.1, from 22.22.22.22, 00:00:37 ago, via Ethernet0/1
      Route metric is 12, traffic share count is 1

 

We can also change the cost on R1 interface.

R1(config-if)#int Eth 0/0
R1(config-if)#ip ospf cost 11

 

In this case the traffic is forced via R2 but the metric difference is seen in the OSPF database:

R4#sh ip route 3.3.3.3
Routing entry for 3.3.3.3/32
  Known via "ospf 10", distance 110, metric 12, type inter area
  Last update from 10.10.24.1 on Ethernet0/1, 00:00:47 ago
  Routing Descriptor Blocks:
  * 10.10.24.1, from 22.22.22.22, 00:00:47 ago, via Ethernet0/1
      Route metric is 12, traffic share count is 1

R4#sh ip ospf data sum 3.3.3.3

            OSPF Router with ID (44.44.44.44) (Process ID 10)

                Summary Net Link States (Area 2)

  LS age: 2
  Options: (No TOS-capability, DC, Upward)
  LS Type: Summary Links(Network)
  Link State ID: 3.3.3.3 (summary Network Number)
  Advertising Router: 11.11.11.11
  LS Seq Number: 80000002
  Checksum: 0x2ACD
  Length: 28
  Network Mask: /32
        MTID: 0         Metric: 12

  Routing Bit Set on this LSA in topology Base with MTID 0
  LS age: 908
  Options: (No TOS-capability, DC, Upward)
  LS Type: Summary Links(Network)
  Link State ID: 3.3.3.3 (summary Network Number)
  Advertising Router: 22.22.22.22
  LS Seq Number: 80000001
  Checksum: 0x7C5A
  Length: 28
  Network Mask: /32
        MTID: 0         Metric: 2

 

Cost is one way to influence the traffic path, we will know have a look on some other command that can be used.

 

Thank you for reading.

 

 

OSPF – Implement and troubleshoot path preference – cost