Cisco Support Community
cancel
Showing results for 
Search instead for 
Did you mean: 

Understanding OSPF Cost

     
    Introduction

     

    Load balancing is the ability of a router to share the workload across redundant links to achieve optimal resource utilization.

     

    Requirements

     

    The document assumes an understanding of OSPF routing protocol.

     

    Background

     

    In this network topology, two routers R1 & R2 are connected via Fast Ethernet (Fa 1/0) and Serial (Se 2/0) interfaces. OSPF is the routing protocol configured and networks advertised are the loopback addresses of the two routers (Prefix 1.1.1.1/32 and 2.2.2.2/32).

     

    The document describes three scenarios, i.e

    • Scenario A: Default Behavior
    • Scenario B: Routes learned via redundant link (Serial 2/0)
    • Scenario C: Load Balancing Over two links

     

    Note: All configurations are tested in a lab environment on Cisco 7200 series router with IOS C7200-ADVIPSERVICESK9-M), Version 15.0(1).

     

    Topology Diagram

     

    Topology_Diag.png

    Configuration: Scenario A (Default Behavior)

     

    By default, the advertsied prefixes (in this topology the Loopback Addresses) are learned through the Fast Ethernet interface as the metric compared to that of the serial interface is less.

     

     

    Router 1Router 2

    hostname R1

    !

    ip cef

    !

    interface Loopback0

    ip address 1.1.1.1 255.255.255.255

    !

    interface FastEthernet1/0

    ip address 10.1.1.1 255.255.255.0

    ip ospf 1 area 0

    duplex auto

    speed auto

    !

    interface Serial2/0

    ip address 172.12.12.1 255.255.255.0

    ip ospf 1 area 0

    serial restart-delay 0

    clock rate 72000

    !

    router ospf 1

    router-id 1.1.1.1

    network 1.1.1.1 0.0.0.0 area 0

    !

    end

    hostname R2

    !

    ip cef

    !

    interface Loopback0

    ip address 2.2.2.2 255.255.255.255

    !

    interface FastEthernet1/0

    ip address 10.1.1.2 255.255.255.0

    ip ospf 1 area 0

    duplex auto

    speed auto

    !

    interface Serial2/0

    ip address 172.12.12.2 255.255.255.0

    ip ospf 1 area 0

    serial restart-delay 0

    clock rate 72000

    !

    router ospf 1

    router-id 2.2.2.2

    network 2.2.2.2 0.0.0.0 area 0

    !

    end

     

     

    Verification

     

    R1-1.png

     

    The default cost of an Fast Ethernet interface is 1 by the formula 10(8)/Bandwidth (of an interface). The route 2.2.2.2 is known via the FastEthernet 1/0.

     

    Configuration: Scenario B (Giving preference to Serial Link)

     

    The cost of a link can be manipulated in order to learn routes from redundant link. In this scenario, we are changing the cost on Fast Ethernet to 100, so that the Serial Interface is prefered. The command is "ip ospf cost []".

     

    Router 1Router 2

    hostname R1

    !

    ip cef

    !

    interface Loopback0

    ip address 1.1.1.1 255.255.255.255

    !

    interface FastEthernet1/0

    ip address 10.1.1.1 255.255.255.0

    ip ospf 1 area 0

    ip ospf cost 100

    duplex auto

    speed auto

    !

    interface Serial2/0

    ip address 172.12.12.1 255.255.255.0

    ip ospf 1 area 0

    serial restart-delay 0

    clock rate 72000

    !

    router ospf 1

    router-id 1.1.1.1

    network 1.1.1.1 0.0.0.0 area 0

    !

    end

    hostname R2

    !

    ip cef

    !

    interface Loopback0

    ip address 2.2.2.2 255.255.255.255

    !

    interface FastEthernet1/0

    ip address 10.1.1.2 255.255.255.0

    ip ospf 1 area 0

    ip ospf cost 100

    duplex auto

    speed auto

    !

    interface Serial2/0

    ip address 172.12.12.2 255.255.255.0

    ip ospf 1 area 0

    serial restart-delay 0

    clock rate 72000

    !

    router ospf 1

    router-id 2.2.2.2

    network 2.2.2.2 0.0.0.0 area 0

    !

    end

     

    Verification

     

    R1-2.png

    Note: The prefix 2.2.2.2 is known via Serial 2/0 Interface with a metric of 65.

    Configuration: Scenarion C (Equal Cost Over Different Links)

     

    In this scenario, we are chaning the cost of an interface such that the two interface metrics are same.

     

    Router 1Router 2

    hostname R1

    !

    ip cef

    !

    interface Loopback0

    ip address 1.1.1.1 255.255.255.255

    !

    interface FastEthernet1/0

    ip address 10.1.1.1 255.255.255.0

    ip ospf 1 area 0

    ip ospf cost 64

    duplex auto

    speed auto

    !

    interface Serial2/0

    ip address 172.12.12.1 255.255.255.0

    ip ospf 1 area 0

    serial restart-delay 0

    clock rate 72000

    !

    router ospf 1

    router-id 1.1.1.1

    network 1.1.1.1 0.0.0.0 area 0

    !

    end

    hostname R2

    !

    ip cef

    !

    interface Loopback0

    ip address 2.2.2.2 255.255.255.255

    !

    interface FastEthernet1/0

    ip address 10.1.1.2 255.255.255.0

    ip ospf 1 area 0

    ip ospf cost 64

    duplex auto

    speed auto

    !

    interface Serial2/0

    ip address 172.12.12.2 255.255.255.0

    ip ospf 1 area 0

    serial restart-delay 0

    clock rate 72000

    !

    router ospf 1

    router-id 2.2.2.2

    network 2.2.2.2 0.0.0.0 area 0

    !

    end

     

    Verification

     

    R1-3.png

     

    R1-4.png

     

    Note: The prefix 2.2.2.2 is available via FastEthernet 1/0 and Serial 2/0 with equal metric of 65.

    References

     

    Cisco Support: OSPF

    IP Routing: OSPF Configuration Guide

    Cisco IOS IP Routing: OSPF Command Reference

     

    Comments
    New Member

    Hi Cisco Crew, your last two links under "References" are both dead. 

    18374
    Views
    0
    Helpful
    1
    Comments