Cisco device configuration tutorials and networking fundamentals

Cisco configuration tutorials

Archive

OSPF Cost and Metric Type Introduction with Configurations

«    2022 June 6    »

What is OSPF cost?

OSPF uses link cost as the metric for calculating the shortest path to a destination. More precisely, a router receives the sum of all costs assigned to each individual outgoing interface leading towards a destination. If there are multiple OSPF paths to a destination, a router decides the best path based on the lowest cost. This means, a lower interface cost is more preferred.

In OSPF, interfaces with higher bandwidths are automatically assigned a lower cost. But the OSPF cost can also be manually configured to serve a variety of purposes, such as path prioritisation, load balancing, and assigning a primary gateway in a redundant design. The following table shows how to configure the OSPF cost of an interface with IPv4 and IPv6.

OSPF cost configuration with IPv4 and IPv6
Description Configuration

OSPFv2 IPv4 interface

R2>enable
R2#configure terminal
Enter configuration commands, one per line.  End with CNTL/Z.
R2(config)#interface Gi0/1
R2(config-if)#ip ospf cost 100
R2(config-if)#exit
R2(config)#exit
R2#

OSPFv3 IPv6 interface (old-style)

R2>enable
R2#configure terminal
Enter configuration commands, one per line.  End with CNTL/Z.
R2(config)#interface Gi0/1
R2(config-if)#ipv6 ospf cost 100 
R2(config-if)#exit
R2(config)#exit
R2#

OSPFv3 IPv6 interface (new-style)

R2>enable
R2#configure terminal
Enter configuration commands, one per line.  End with CNTL/Z.
R2(config)#interface Gi0/1
R2(config-if)#ospfv3 10 ipv6 cost 100
R2(config-if)#exit
R2(config)#exit
R2#

Dual-stack IPv4/IPv6 interface (OSPFv3)

R2>enable
R2#configure terminal
Enter configuration commands, one per line.  End with CNTL/Z.
R2(config)#interface Gi0/1
R2(config-if)#ospfv3 10 ipv4 cost 100
R2(config-if)#exit
R2(config)#exit
R2#

Notice in the above table that OSPFv3 can carry IPv4 and IPv6 prefixes, and as a result it is also possible to assign a cost value for IPv4 prefixes using OSPFv3. This is especially useful for dual stack IPv4/IPv6 network deployments.

OSPF also assigns a cost to external prefixes that are redistributed from another routing protocol. By default the seed metric is used, which is a metric value inherited from the originating routing protocol. Additionally, OSPF can assign further metric values to redistributed prefixes and influence primary/secondary gateway selection. The following packet capture shows an OSPF external prefix and its metric (cost).

Wireshark packet capture of OSPF Link State Update packet advertising a Type-1 External prefix with a cost of 10

What is the difference between OSPF metric Type-1 and Type-2? (E1 vs E2 route)

The metric type is used with external prefixes redistributed into the OSPF routing process. This means, OSPF external LSAs carry either a type-1 or type-2 metric value. By default, OSPF assigns metric type-2 during redistribution and as a result an external prefix will not change its route cost within the OSPF domain. Any OSPF router that receives an external type-2 metric will see the same cost value, no matter its location in the OSPF domain.

The metric type-2 is useful for redundant active/standby Autonomos System Boundary Router (ASBR) designs because the configured metric difference (between active and standby devices) can be hardcoded. However, this is not the case with the metric type-1. A router receives a metric type-1 external LSA with the inherited external cost (seed metric) increased by the internal cost to reach the redistributing ASBR. So the internal metric to reach the ASBR is added to metric type-1 LSAs. This can be useful in an active/active ASBR design as shown below.

OSPF metric type-1 is configured on ASBR during redistribution from BGP

Configuration:

R1
    R1#show run int Gi0/0 | sec int
    interface GigabitEthernet0/0
     description ** to Host1 **
     ip address 172.16.1.2 255.255.255.0
     duplex auto
     speed auto
     media-type rj45
    
    R1#show run int Gi0/1 | sec int
    interface GigabitEthernet0/1
     description ** to R2 **
     ip address 10.2.0.1 255.255.255.252
     ip ospf network point-to-point
     duplex auto
     speed auto
     media-type rj45
    
    R1#show run int Gi0/2 | sec int
    interface GigabitEthernet0/2
     description ** to R3 **
     ip address 10.1.0.1 255.255.255.252
     ip ospf network point-to-point
     duplex auto
     speed auto
     media-type rj45
    
    R1#show run int Lo10 | sec int 
    interface Loopback10
     ip address 1.1.1.1 255.255.255.255
    
    R1#show run | sec ^router
    router ospf 10
     router-id 1.1.1.1
     passive-interface GigabitEthernet0/0
     network 1.1.1.1 0.0.0.0 area 0
     network 10.1.0.0 0.0.0.3 area 0
     network 10.2.0.0 0.0.0.3 area 0
     network 172.16.1.0 0.0.0.255 area 0
    
R3 (ASBR)
    R3#show run int Gi0/0 | sec int
    interface GigabitEthernet0/0
     description ** to R1 **
     ip address 10.1.0.2 255.255.255.252
     ip ospf network point-to-point
     duplex auto
     speed auto
     media-type rj45
    
    R3#show run int Gi0/1 | sec int
    interface GigabitEthernet0/1
     description ** to R5 **
     ip address 10.0.1.1 255.255.255.252
     duplex auto
     speed auto
     media-type rj45
    
    R3#show run int Lo10 | sec int 
    interface Loopback10
     ip address 3.3.3.3 255.255.255.255
    
    R3#show run | sec ^router
    router ospf 10
     router-id 3.3.3.3
     redistribute bgp 65001 subnets route-map RM-REDISTRIBUTE
     network 3.3.3.3 0.0.0.0 area 0
     network 10.1.0.0 0.0.0.3 area 0
    router bgp 65001
     bgp router-id 3.3.3.3
     bgp log-neighbor-changes
     network 172.16.1.0 mask 255.255.255.0
     network 172.16.2.0 mask 255.255.255.0
     neighbor 5.5.5.5 remote-as 65002
     neighbor 5.5.5.5 ebgp-multihop 255
     neighbor 5.5.5.5 update-source Loopback10
    
    R3#show run | sec ^route-map
    route-map RM-REDISTRIBUTE permit 10
     set metric-type type-1
    
    R3#show run | sec ^ip route
    ip route 5.5.5.5 255.255.255.255 GigabitEthernet0/1 10.0.1.2
    
R4 (ASBR)
    R4#show run int Gi0/0 | sec int
    interface GigabitEthernet0/0
     description ** to R2 **
     ip address 10.3.0.2 255.255.255.252
     ip ospf network point-to-point
     duplex auto
     speed auto
     media-type rj45
    
    R4#show run int Gi0/1 | sec int
    interface GigabitEthernet0/1
     description ** to R5 **
     ip address 10.0.2.1 255.255.255.252
     duplex auto
     speed auto
     media-type rj45
    
    R4#show run int Lo10 | sec int 
    interface Loopback10
     ip address 4.4.4.4 255.255.255.255
    
    R4#show run | sec ^router
    router ospf 10
     router-id 4.4.4.4
     redistribute bgp 65001 subnets route-map RM-REDISTRIBUTE
     network 4.4.4.4 0.0.0.0 area 0
     network 10.3.0.0 0.0.0.3 area 0
    router bgp 65001
     bgp router-id 4.4.4.4
     bgp log-neighbor-changes
     network 172.16.1.0 mask 255.255.255.0
     network 172.16.2.0 mask 255.255.255.0
     neighbor 5.5.5.5 remote-as 65002
     neighbor 5.5.5.5 ebgp-multihop 255
     neighbor 5.5.5.5 update-source Loopback10
    
    R4#show run | sec ^route-map
    route-map RM-REDISTRIBUTE permit 10
     set metric-type type-1
    
    R4#show run | sec ^ip route
    ip route 5.5.5.5 255.255.255.255 GigabitEthernet0/1 10.0.2.2
    
R5
    R5#show run int Gi0/0 | sec int
    interface GigabitEthernet0/0
     description ** to R3 **
     ip address 10.0.1.2 255.255.255.252
     duplex auto
     speed auto
     media-type rj45
    
    R5#show run int Gi0/1 | sec int
    interface GigabitEthernet0/1
     description ** to R4 **
     ip address 10.0.2.2 255.255.255.252
     duplex auto
     speed auto
     media-type rj45
    
    R5#show run int Lo10 | sec int 
    interface Loopback10
     ip address 5.5.5.5 255.255.255.255
    
    R5#show run int Lo20 | sec int
    interface Loopback20
     ip address 192.168.1.1 255.255.255.0
    
    R5#show run int Lo30 | sec int
    interface Loopback30
     ip address 192.168.2.1 255.255.255.0
    
    R5#show run | sec ^router     
    router bgp 65002
     bgp router-id 5.5.5.5
     bgp log-neighbor-changes
     network 192.168.1.0
     network 192.168.2.0
     neighbor 3.3.3.3 remote-as 65001
     neighbor 3.3.3.3 ebgp-multihop 255
     neighbor 3.3.3.3 update-source Loopback10
     neighbor 4.4.4.4 remote-as 65001
     neighbor 4.4.4.4 ebgp-multihop 255
     neighbor 4.4.4.4 update-source Loopback10
    
    R5#show run | sec ^ip route
    ip route 3.3.3.3 255.255.255.255 GigabitEthernet0/0 10.0.1.1
    ip route 4.4.4.4 255.255.255.255 GigabitEthernet0/1 10.0.2.1
    
R1#show ip route ospf | beg Ga
Gateway of last resort is not set

      2.0.0.0/32 is subnetted, 1 subnets
O        2.2.2.2 [110/2] via 10.2.0.2, 02:55:55, GigabitEthernet0/1
      3.0.0.0/32 is subnetted, 1 subnets
O        3.3.3.3 [110/2] via 10.1.0.2, 02:55:45, GigabitEthernet0/2
      4.0.0.0/32 is subnetted, 1 subnets
O        4.4.4.4 [110/3] via 10.2.0.2, 02:55:35, GigabitEthernet0/1
      10.0.0.0/8 is variably subnetted, 5 subnets, 2 masks
O        10.3.0.0/30 [110/2] via 10.2.0.2, 02:55:55, GigabitEthernet0/1
      172.16.0.0/16 is variably subnetted, 3 subnets, 2 masks
O        172.16.2.0/24 [110/2] via 10.2.0.2, 02:55:55, GigabitEthernet0/1
O E1  192.168.1.0/24 [110/2] via 10.1.0.2, 02:54:50, GigabitEthernet0/2      « Metric type-1 is used
O E1  192.168.2.0/24 [110/2] via 10.1.0.2, 02:54:50, GigabitEthernet0/2




R1#show ip route 192.168.1.0
Routing entry for 192.168.1.0/24
  Known via "ospf 10", distance 110, metric 2
  Tag 65002, type extern 1                                          « Metric type-1 is used
  Last update from 10.1.0.2 on GigabitEthernet0/2, 02:52:12 ago
  Routing Descriptor Blocks:
  * 10.1.0.2, from 3.3.3.3, 02:52:12 ago, via GigabitEthernet0/2    « ASBR R3 is preferred
      Route metric is 2, traffic share count is 1
      Route tag 65002
	  
	  
	  

R2#show ip route 192.168.1.0
Routing entry for 192.168.1.0/24
  Known via "ospf 10", distance 110, metric 2
  Tag 65002, type extern 1
  Last update from 10.3.0.2 on GigabitEthernet0/2, 02:50:36 ago
  Routing Descriptor Blocks:
  * 10.3.0.2, from 4.4.4.4, 02:50:36 ago, via GigabitEthernet0/2    « ASBR R4 is preferred
      Route metric is 2, traffic share count is 1
      Route tag 65002



Host1:~$ traceroute 192.168.1.1 -q 1 -n
traceroute to 192.168.1.1 (192.168.1.1), 30 hops max, 46 byte packets
 1  172.16.1.2  3.316 ms
 2  10.1.0.2  1.641 ms      « Host1 uses ASBR R3 to reach Site 2
 3  10.0.1.2  2.176 ms
 


Host2:~$ traceroute 192.168.1.1 -q 1 -n
traceroute to 192.168.1.1 (192.168.1.1), 30 hops max, 46 byte packets
 1  172.16.2.2  2.798 ms
 2  10.3.0.2  2.688 ms      « Host2 uses ASBR R4 to reach Site 2
 3  10.0.2.2  2.543 ms

Using the same topology but configuring R3 as the active router and R4 as the standby can be easily achieved by assigning metric type-2 on both ASBRs. The following configurations would need to be applied. As a result, prefixes redistributed by R4 always have a metric 10 assigned. Meanwhile, R3 uses the default seed metric of 1. This is because BGP routes redistributed into OSPF receive the metric 1 (also shown in below output). Thus, R3 could use the default seed metric to make it the more preferred (primary) ASBR.

R4>enable
R4#configure terminal
Enter configuration commands, one per line.  End with CNTL/Z.
R4(config)#route-map RM-REDISTRIBUTE
R4(config-route-map)#set metric-type type-2
R4(config-route-map)#set metric 10
R4(config-route-map)#exit
R4(config)#
R4(config)#router ospf 10
R4(config-router)#redistribute bgp 65001 subnets route-map RM-REDISTRIBUTE
R4(config-router)#exit
R4(config)#exit
R4#
R4#show ip ospf database external 192.168.1.0

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

                Type-5 AS External Link States

  LS age: 6
  Options: (No TOS-capability, DC, Upward)
  LS Type: AS External Link
  Link State ID: 192.168.1.0 (External Network Number )
  Advertising Router: 4.4.4.4
  LS Seq Number: 80000001
  Checksum: 0xB096
  Length: 36
  Network Mask: /24
        Metric Type: 2 (Larger than any link state path)
        MTID: 0 
        Metric: 10                                          « R4 assigns metric 10 to E2 route
        Forward Address: 0.0.0.0
        External Route Tag: 65002


-------------------------------------------------------------------------------


R3>enable
R3#configure terminal
Enter configuration commands, one per line.  End with CNTL/Z.
R3(config)#route-map RM-REDISTRIBUTE
R3(config-route-map)#set metric-type type-2
R3(config-route-map)#exit
R3(config)#
R3(config)#router ospf 10
R3(config-router)#redistribute bgp 65001 subnets route-map RM-REDISTRIBUTE
R3(config-router)#exit
R3(config)#exit
R3#
R3#show ip ospf database external 192.168.1.0

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

                Type-5 AS External Link States

  LS age: 27
  Options: (No TOS-capability, DC, Upward)
  LS Type: AS External Link
  Link State ID: 192.168.1.0 (External Network Number )
  Advertising Router: 3.3.3.3
  LS Seq Number: 80000001
  Checksum: 0x74DF
  Length: 36
  Network Mask: /24
        Metric Type: 2 (Larger than any link state path)
        MTID: 0 
        Metric: 1                                           « R3 uses default seed metric
        Forward Address: 0.0.0.0
        External Route Tag: 65002

Note that the default OSPF behavior is to redistribute prefixes as E2 (external type-2) routes, so the set metric-type type-2 command in the route-map is not necessary. For example, applying the following configuration on R3 would already make it redistribute BGP routes into OSPF as E2 prefixes with the default seed metric 1.

R3>
R3>enable
R3#configure terminal
Enter configuration commands, one per line.  End with CNTL/Z.
R3(config)#
R3(config)#router ospf 10
R3(config-router)#router-id 3.3.3.3
R3(config-router)#network 10.1.0.0 0.0.0.3 area 0
R3(config-router)#redistribute bgp 65001 subnets
R3(config-router)#
R3(config-router)#exit
R3(config)#
R3(config)#exit
R3#

Does OSPF prefer external route metric Type-1 or Type-2?

OSPF always prefers an external type-1 (E1) route over an external type-2 (E2) route. This is true even if the E2 route has a lower cost (better metric) than the E1 route. The following topology displays such a scenario. R2 and R3 are ASBRs and receive prefixes 192.168.1.0/24 and 192.168.2.0/24 via eBGP from R4. Next, R2 redistributes the prefixes into OSPF as E1 routes with a cost of 100, and R3 redistributes them as E2 routes with a cost of 50.

R1, upon receiving the external type-5 LSAs from the ASBRs chooses R2 as the next-hop, even though the external routes from R3 have a lower (more preferred) cost.

OSPF prefers external type-1 route over an E2 route

Configuration:

R1
    R1#show run int Gi0/0 | sec int
    interface GigabitEthernet0/0
     description ** to ASBR R2 **
     ip address 10.1.0.1 255.255.255.252
     duplex auto
     speed auto
     media-type rj45
    
    R1#show run int Gi0/1 | sec int
    interface GigabitEthernet0/1
     description ** to ASBR R3 **
     ip address 10.2.0.1 255.255.255.252
     duplex auto
     speed auto
     media-type rj45
    
    R1#show run | sec ^router
    router ospf 10
     router-id 1.1.1.1
     network 10.1.0.0 0.0.0.3 area 0
     network 10.2.0.0 0.0.0.3 area 0
    
R2
    R2#show run int Gi0/0 | sec int
    interface GigabitEthernet0/0
     description ** to R1 **
     ip address 10.1.0.2 255.255.255.252
     duplex auto
     speed auto
     media-type rj45
    
    R2#show run int Gi0/1 | sec int
    interface GigabitEthernet0/1
     description ** to R4 **
     ip address 10.10.0.1 255.255.255.252
     duplex auto
     speed auto
     media-type rj45
    
    R2#show run | sec ^router
    router ospf 10
     router-id 2.2.2.2
     redistribute bgp 65001 metric 100 metric-type 1 subnets
     network 10.1.0.0 0.0.0.3 area 0
    router bgp 65001
     bgp router-id 2.2.2.2
     bgp log-neighbor-changes
     neighbor 10.10.0.2 remote-as 65002
    
R3
    R3#show run int Gi0/0 | sec int
    interface GigabitEthernet0/0
     description ** to R1 **
     ip address 10.2.0.2 255.255.255.252
     duplex auto
     speed auto
     media-type rj45
    
    R3#show run int Gi0/1 | sec int
    interface GigabitEthernet0/1
     description ** to R4 **
     ip address 10.20.0.1 255.255.255.252
     duplex auto
     speed auto
     media-type rj45
    
    R3#show run | sec ^router
    router ospf 10
     router-id 3.3.3.3
     redistribute bgp 65001 metric 50 subnets
     network 10.2.0.0 0.0.0.3 area 0
    router bgp 65001
     bgp router-id 3.3.3.3
     bgp log-neighbor-changes
     neighbor 10.20.0.2 remote-as 65002
    
R4
    R4#show run int Gi0/0 | sec int
    interface GigabitEthernet0/0
     description ** to ASBR R2 **
     ip address 10.10.0.2 255.255.255.252
     duplex auto
     speed auto
     media-type rj45
    
    R4#show run int Gi0/1 | sec int
    interface GigabitEthernet0/1
     description ** to ASBR R3 **
     ip address 10.20.0.2 255.255.255.252
     duplex auto
     speed auto
     media-type rj45
    
    R4#show run int Lo10 | sec int
    interface Loopback10
     ip address 192.168.1.1 255.255.255.0
    
    R4#show run int Lo20 | sec int
    interface Loopback20
     ip address 192.168.2.1 255.255.255.0
    
    R4#show run | sec ^router
    router bgp 65002
     template peer-session EXAMPLE-EBGP
      remote-as 65001
     exit-peer-session
     !
     bgp router-id 4.4.4.4
     bgp log-neighbor-changes
     network 192.168.1.0
     network 192.168.2.0
     neighbor 10.10.0.1 inherit peer-session EXAMPLE-EBGP
     neighbor 10.20.0.1 inherit peer-session EXAMPLE-EBGP
    
R1#show ip ospf database external 192.168.1.0

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

                Type-5 AS External Link States

  LS age: 6
  Options: (No TOS-capability, DC, Upward)
  LS Type: AS External Link
  Link State ID: 192.168.1.0 (External Network Number )
  Advertising Router: 2.2.2.2
  LS Seq Number: 80000001
  Checksum: 0xF084
  Length: 36
  Network Mask: /24
        Metric Type: 1 (Comparable directly to link state metric)
        MTID: 0 
        Metric: 100 
        Forward Address: 0.0.0.0
        External Route Tag: 65002

  LS age: 644
  Options: (No TOS-capability, DC, Upward)
  LS Type: AS External Link
  Link State ID: 192.168.1.0 (External Network Number )
  Advertising Router: 3.3.3.3
  LS Seq Number: 80000001
  Checksum: 0x60C2
  Length: 36
  Network Mask: /24
        Metric Type: 2 (Larger than any link state path)
        MTID: 0 
        Metric: 50 
        Forward Address: 0.0.0.0
        External Route Tag: 65002




R1#show ip ospf rib 192.168.1.0

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


                Base Topology (MTID 0)

OSPF local RIB
Codes: * - Best, > - Installed in global RIB
LSA: type/LSID/originator

*>  192.168.1.0/24, Ext1, cost 101, fwd cost 1, tag 65002
     SPF Instance 4, age 00:00:40
      contributing LSA: 5/192.168.1.0/3.3.3.3
      contributing LSA: 5/192.168.1.0/2.2.2.2
     Flags: RIB
      via 10.1.0.2, GigabitEthernet0/0 label 1048578
       Flags: RIB
       LSA: 5/192.168.1.0/2.2.2.2                  « The route through R2 is installed in the RIB




R1#show ip route 192.168.1.0     
Routing entry for 192.168.1.0/24
  Known via "ospf 10", distance 110, metric 101   « E1 route through R2 is chosen as next-hop even though it has a higher (worse) metric than the E2 route
  Tag 65002, type extern 1
  Last update from 10.1.0.2 on GigabitEthernet0/0, 00:01:09 ago
  Routing Descriptor Blocks:
  * 10.1.0.2, from 2.2.2.2, 00:01:09 ago, via GigabitEthernet0/0
      Route metric is 101, traffic share count is 1
      Route tag 65002

How is OSPF cost calculated using the reference bandwidth?

OSPF automatically calculates a cost for each interface on a local router that participates in the routing process. The cost calculation is carried out using a formula. The formula includes a reference bandwidth of 100 Mbps (default for OSPFv2 and OSPFv3) which is divided by the bandwidth of an interface. So, a Fast Ethernet interface which has a bandwidth of 100 Mbps receives a cost of 1.

However, using the default formula a Gigabit Ethernet interface also receives a cost of 1 which is not desirable in many OSPF topologies. As a solution, the reference bandwidth can be changed, for example the following configuration creates a reference bandwidth of 10000. Consequently, a Gigabit Ethernet interface will have a cost of 10, and a Fast Ethernet interface a cost of 100.

R1>
R1>enable
R1#
R1#show ip ospf interface GigabitEthernet 0/0 | include Process
  Process ID 10, Router ID 1.1.1.1, Network Type POINT_TO_POINT, Cost: 1
R1#
R1#configure terminal
Enter configuration commands, one per line.  End with CNTL/Z.
R1(config)#
R1(config)#router ospf 10
R1(config-router)#auto-cost reference-bandwidth 10000
% OSPF: Reference bandwidth is changed. 
        Please ensure reference bandwidth is consistent across all routers.
R1(config-router)#
R1(config-router)#exit
R1(config)#exit
R1#
R1#show ip ospf interface GigabitEthernet 0/0 | include Process
  Process ID 10, Router ID 1.1.1.1, Network Type POINT_TO_POINT, Cost: 10
R1#
R1#show ip ospf | sec Reference
 Reference bandwidth unit is 10000 mbps
    Area BACKBONE(0)
        Number of interfaces in this area is 1

Configuring the cost of an OSPF stub area default route

In this sample topology, area 1 is configured as a totally stubby area. R3 and R4 are Area Border Routers (ABR), both of the ABRs advertise a Type-3 LSA default route into area 1. The area default-cost command configures the metric of the default route originated on the ABRs. As a result, R3 can be configured as the primary ABR for traffic egressing (exiting) area 1 and destined to the Server.

Configuring the cost of an OSPF default summary LSA

Configuration:

R3
    R3#show run | sec router ospf
    router ospf 1
     area 1 stub no-summary
     area 1 default-cost 10
     network 10.0.0.0 0.0.0.15 area 0
     network 10.1.0.0 0.0.0.15 area 1
    
R4
    R4#show run | sec router ospf
    router ospf 1
     area 1 stub no-summary
     area 1 default-cost 20
     network 10.0.0.0 0.0.0.15 area 0
     network 10.1.0.0 0.0.0.15 area 1
    
R2#show ip route ospf | beg Ga
Gateway of last resort is 10.1.0.10 to network 0.0.0.0

O*IA  0.0.0.0/0 [110/11] via 10.1.0.10, 00:11:45, GigabitEthernet0/1        « Default route cost 10. Plus Gigabit link cost 1.




R2#show ip ospf rib 0.0.0.0

            OSPF Router with ID (10.1.0.13) (Process ID 1)


                Base Topology (MTID 0)

OSPF local RIB
Codes: * - Best, > - Installed in global RIB
LSA: type/LSID/originator

*>  0.0.0.0/0, Inter, cost 11, area 1
     SPF Instance 14, age 00:11:41
      contributing LSA: 3/0.0.0.0/10.1.0.10 (area 1)
      contributing LSA: 3/0.0.0.0/10.1.0.14 (area 1)
     Flags: RIB, PartialSPF
      via 10.1.0.10, GigabitEthernet0/1 label 1048578
       Flags: RIB
       LSA: 3/0.0.0.0/10.1.0.10        « R3 is advertising lower Type-3 LSA default route cost



  
Host#trace 10.0.0.10 pr 1
Type escape sequence to abort.
Tracing the route to 10.0.0.10
VRF info: (vrf in name/id, vrf out name/id)
  1 10.1.0.1 2 msec
  2 10.1.0.10 2 msec                   « R3 is used to exit area 1
  3 10.0.0.3 5 msec
  4 10.0.0.10 5 msec
  
  
  
  
R1#show ip route ospf | beg Ga                                         « View from R1
Gateway of last resort is 10.1.0.1 to network 0.0.0.0

O*IA  0.0.0.0/0 [110/12] via 10.1.0.1, 00:14:30, GigabitEthernet0/0    « Default route cost 10. Plus two Gigabit links, each link cost 1. 10+1+1 = 12
      10.0.0.0/8 is variably subnetted, 4 subnets, 3 masks
O        10.1.0.8/30 [110/2] via 10.1.0.1, 00:36:54, GigabitEthernet0/0
O        10.1.0.12/30 [110/2] via 10.1.0.1, 00:36:54, GigabitEthernet0/0

Propagating cost of outgoing interface

In this example, area 1 is a totally stubby area. R3 and R4 advertise different default route costs into area 1, making R3 the primary ABR for traffic exiting area 1.

To influence the opposite direction — for traffic entering area 1 from area 0 — the OSPF interface cost on R3 Gi0/0 and R4 Gi0/0 are adjusted. The observation shows the OSPF behavior to propagate the cost of outgoing interfaces. In other words, to influence the cost of an OSPF route towards a destination, the outgoing interface needs to be configured.

Assigning the cost to an OSPF default route for a Totally Stubby Area and configuring the interface cost

Configuration:

R3
    R3#show run | sec router ospf  
    router ospf 1
     area 1 stub no-summary
     area 1 default-cost 10
     network 10.0.0.0 0.0.0.15 area 0
     network 10.1.0.0 0.0.0.15 area 1
    
    R3#show run int Gi0/0 | sec interface
    interface GigabitEthernet0/0
     description ** to R2 **
     ip address 10.1.0.10 255.255.255.252
     ip ospf cost 10
     duplex auto
     speed auto
     media-type rj45
    
R4
    R4#show run | sec router ospf
    router ospf 1
     area 1 stub no-summary
     area 1 default-cost 20
     network 10.0.0.0 0.0.0.15 area 0
     network 10.1.0.0 0.0.0.15 area 1
    
    R4#show run int Gi0/0 | sec interface
    interface GigabitEthernet0/0
     description ** to R2 **
     ip address 10.1.0.14 255.255.255.252
     ip ospf cost 20
     duplex auto
     speed auto
     media-type rj45
    

As a result, now R3 is configured as the primary router for traffic in both directions. The following outputs verify bidirectional traffic flow.

Host#trace 10.0.0.10 pr 1
Type escape sequence to abort.
Tracing the route to 10.0.0.10
VRF info: (vrf in name/id, vrf out name/id)
  1 10.1.0.1 2 msec
  2 10.1.0.10 3 msec « R3 is primary ABR for traffic exiting area 1
  3 10.0.0.3 5 msec
  4 10.0.0.10 6 msec
  
Server#trace 10.1.0.3 pr 1
Type escape sequence to abort.
Tracing the route to 10.1.0.3
VRF info: (vrf in name/id, vrf out name/id)
  1 10.0.0.9 1 msec
  2 10.0.0.1 3 msec « R3 is primary ABR for traffic entering area 1
  3 10.1.0.9 4 msec
  4 10.1.0.3 6 msec

Configuring the cost of an OSPF injected default route

In the following scenario, R2 and R3 originate an OSPF default route with the default-information originate command. What this means, is that the OSPF default route is only advertised if there is a BGP default route received from R4. Also, the OSPF default route is injected as an external type-2 (E2) route.

Additionally, R3 injects the OSPF default route with a cost of 10, and as a result the ASBR R2 becomes the primary egress router for traffic destined to the Server.

OSPF injected default route cost configuration

Configuration:

R1
    R1#show run | sec ^router
    router ospf 10
     router-id 1.1.1.1
     passive-interface GigabitEthernet0/0
     network 10.1.0.0 0.0.255.255 area 0
    
    R1#show run int Gi0/0 | sec int
    interface GigabitEthernet0/0
     description ** to Host **
     ip address 10.1.0.2 255.255.255.252
     duplex auto
     speed auto
     media-type rj45
    
    R1#show run int Gi0/1 | sec int
    interface GigabitEthernet0/1
     description ** to R2 **
     ip address 10.1.1.2 255.255.255.252
     ip ospf network point-to-point
     duplex auto
     speed auto
     media-type rj45
    
    R1#show run int Gi0/2 | sec int
    interface GigabitEthernet0/2
     description ** to R3 **
     ip address 10.1.2.2 255.255.255.252
     ip ospf network point-to-point
     duplex auto
     speed auto
     media-type rj45
    
R2 (ASBR)
    R2#show run | sec ^router
    router ospf 10
     router-id 2.2.2.2
     network 10.1.0.0 0.0.255.255 area 0
     default-information originate
    router bgp 65001
     bgp router-id 2.2.2.2
     bgp log-neighbor-changes
     network 10.1.0.0 mask 255.255.255.252
     neighbor 10.0.1.2 remote-as 65002
    
    R2#show run int Gi0/0 | sec int
    interface GigabitEthernet0/0
     description ** to R1 **
     ip address 10.1.1.1 255.255.255.252
     ip ospf network point-to-point
     duplex auto
     speed auto
     media-type rj45
    
    R2#show run int Gi0/1 | sec int
    interface GigabitEthernet0/1
     description ** to R4 **
     ip address 10.0.1.1 255.255.255.252
     duplex auto
     speed auto
     media-type rj45
    
R3 (ASBR)
    R3#show run | sec ^router
    router ospf 10
     router-id 3.3.3.3
     network 10.1.0.0 0.0.255.255 area 0
     default-information originate metric 10
    router bgp 65001
     bgp router-id 3.3.3.3
     bgp log-neighbor-changes
     network 10.1.0.0 mask 255.255.255.252
     neighbor 10.0.2.2 remote-as 65002
    
    R3#show run int Gi0/0 | sec int
    interface GigabitEthernet0/0
     description ** to R1 **
     ip address 10.1.2.1 255.255.255.252
     ip ospf network point-to-point
     duplex auto
     speed auto
     media-type rj45
    
    R3#show run int Gi0/1 | sec int
    interface GigabitEthernet0/1
     description ** to R4 **
     ip address 10.0.2.1 255.255.255.252
     duplex auto
     speed auto
     media-type rj45
    
R4
    R4#show run | sec ^router
    router bgp 65002
     bgp router-id 4.4.4.4
     bgp log-neighbor-changes
     neighbor 10.0.1.1 remote-as 65001
     neighbor 10.0.1.1 default-originate
     neighbor 10.0.2.1 remote-as 65001
     neighbor 10.0.2.1 default-originate
    
    R4#show run int Gi0/0 | sec int
    interface GigabitEthernet0/0
     description ** to R2 **
     ip address 10.0.1.2 255.255.255.252
     duplex auto
     speed auto
     media-type rj45
    
    R4#show run int Gi0/1 | sec int
    interface GigabitEthernet0/1
     description ** to R3 **
     ip address 10.0.2.2 255.255.255.252
     duplex auto
     speed auto
     media-type rj45
    
    R4#show run int Gi0/2 | sec int
    interface GigabitEthernet0/2
     description ** to Server **
     ip address 10.2.0.2 255.255.255.0
     duplex auto
     speed auto
     media-type rj45
    
R1#show ip ospf rib 0.0.0.0

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


                Base Topology (MTID 0)

OSPF local RIB
Codes: * - Best, > - Installed in global RIB
LSA: type/LSID/originator

*>  0.0.0.0/0, Ext2, cost 1, fwd cost 1, tag 10           « Default route is external type 2
     SPF Instance 9, age 00:19:32
      contributing LSA: 5/0.0.0.0/3.3.3.3
      contributing LSA: 5/0.0.0.0/2.2.2.2
     Flags: RIB, PartialSPF
      via 10.1.1.1, GigabitEthernet0/1 label 1048578
       Flags: RIB
       LSA: 5/0.0.0.0/2.2.2.2                             « Type 5 External LSA advertises the default route




R1#show ip route ospf | beg Ga
Gateway of last resort is 10.1.1.1 to network 0.0.0.0

*E2  0.0.0.0/0 [110/1] via 10.1.1.1, 00:21:07, GigabitEthernet0/1      « E2 default route received from ASBR




R2#show ip route | beg Ga
Gateway of last resort is 10.0.1.2 to network 0.0.0.0

B*    0.0.0.0/0 [20/0] via 10.0.1.2, 00:20:34                          « OSPF ASBR R2 receives eBGP default route
      10.0.0.0/8 is variably subnetted, 6 subnets, 2 masks
C        10.0.1.0/30 is directly connected, GigabitEthernet0/1
L        10.0.1.1/32 is directly connected, GigabitEthernet0/1
O        10.1.0.0/30 [110/2] via 10.1.1.2, 00:25:59, GigabitEthernet0/0
C        10.1.1.0/30 is directly connected, GigabitEthernet0/0
L        10.1.1.1/32 is directly connected, GigabitEthernet0/0
O        10.1.2.0/30 [110/2] via 10.1.1.2, 00:25:59, GigabitEthernet0/0




Host#trace 10.2.0.1 probe 1
Type escape sequence to abort.
Tracing the route to 10.2.0.1
VRF info: (vrf in name/id, vrf out name/id)
  1 10.1.0.2 1 msec
  2 10.1.1.1 2 msec                                           « ASBR R2 is primary gateway router
  3 10.0.1.2 1 msec
  4 10.2.0.1 2 msec

Selecting primary ASBR during route redistribution from BGP

In the following example scenario, ASBR R2 and R3 redistribute the eBGP route 10.2.0.0/24 into OSPF. By default, OSPF external routes are advertised with the Metric Type-2 (E2 route). Additionally, R3 assigns the metric 10 to the redistributed prefix, and this makes R2 the primary ASBR for traffic destined to the Server.

Note that the seed metric of BGP routes redistributed into OSPF is 1. This means, the metric 1 is assigned to the external route redistributed into OSPF on ASBR R2. The previous section provides a more detailed comparison of OSPF E1 vs E2 routes.

BGP route redistribution into OSPF on ASBR and assinging E2 route metric

Configuration:

R1
    R1#show run | sec ^router
    router ospf 10
     router-id 1.1.1.1
     passive-interface GigabitEthernet0/0
     network 10.1.0.0 0.0.255.255 area 0
    
    R1#show run int Gi0/0 | sec int
    interface GigabitEthernet0/0
     description ** to Host **
     ip address 10.1.0.2 255.255.255.252
     duplex auto
     speed auto
     media-type rj45
    
    R1#show run int Gi0/1 | sec int
    interface GigabitEthernet0/1
     description ** to R2 **
     ip address 10.1.1.2 255.255.255.252
     ip ospf network point-to-point
     duplex auto
     speed auto
     media-type rj45
    
    R1#show run int Gi0/2 | sec int
    interface GigabitEthernet0/2
     description ** to R3 **
     ip address 10.1.2.2 255.255.255.252
     ip ospf network point-to-point
     duplex auto
     speed auto
     media-type rj45
    
R2 (ASBR)
    R2#show run | sec ^router
    router ospf 10
     router-id 2.2.2.2
     redistribute bgp 65001 subnets
     network 10.1.0.0 0.0.255.255 area 0
    router bgp 65001
     bgp router-id 2.2.2.2
     bgp log-neighbor-changes
     network 10.1.0.0 mask 255.255.255.252
     neighbor 10.0.1.2 remote-as 65002
    
    R2#show run int Gi0/0 | sec int
    interface GigabitEthernet0/0
     description ** to R1 **
     ip address 10.1.1.1 255.255.255.252
     ip ospf network point-to-point
     duplex auto
     speed auto
     media-type rj45
    
    R2#show run int Gi0/1 | sec int
    interface GigabitEthernet0/1
     description ** to R4 **
     ip address 10.0.1.1 255.255.255.252
     duplex auto
     speed auto
     media-type rj45
    
R3 (ASBR)
    R3#show run | sec ^router
    router ospf 10
     router-id 3.3.3.3
     redistribute bgp 65001 metric 10 subnets
     network 10.1.0.0 0.0.255.255 area 0
    router bgp 65001
     bgp router-id 3.3.3.3
     bgp log-neighbor-changes
     network 10.1.0.0 mask 255.255.255.252
     neighbor 10.0.2.2 remote-as 65002
    
    R3#show run int Gi0/0 | sec int
    interface GigabitEthernet0/0
     description ** to R1 **
     ip address 10.1.2.1 255.255.255.252
     ip ospf network point-to-point
     duplex auto
     speed auto
     media-type rj45
    
    R3#show run int Gi0/1 | sec int
    interface GigabitEthernet0/1
     description ** to R4 **
     ip address 10.0.2.1 255.255.255.252
     duplex auto
     speed auto
     media-type rj45
    
R4
    R4#show run | sec ^router
    router bgp 65002
     bgp router-id 4.4.4.4
     bgp log-neighbor-changes
     network 10.2.0.0 mask 255.255.255.0
     neighbor 10.0.1.1 remote-as 65001
     neighbor 10.0.2.1 remote-as 65001
    
    R4#show run int Gi0/0 | sec int
    interface GigabitEthernet0/0
     description ** to R2 **
     ip address 10.0.1.2 255.255.255.252
     duplex auto
     speed auto
     media-type rj45
    
    R4#show run int Gi0/1 | sec int
    interface GigabitEthernet0/1
     description ** to R3 **
     ip address 10.0.2.2 255.255.255.252
     duplex auto
     speed auto
     media-type rj45
    
    R4#show run int Gi0/2 | sec int
    interface GigabitEthernet0/2
     description ** to Server **
     ip address 10.2.0.2 255.255.255.0
     duplex auto
     speed auto
     media-type rj45
    
R1#show ip ospf rib 10.2.0.0

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


                Base Topology (MTID 0)

OSPF local RIB
Codes: * - Best, > - Installed in global RIB
LSA: type/LSID/originator

*>  10.2.0.0/24, Ext2, cost 1, fwd cost 1, tag 65002
     SPF Instance 27, age 00:19:05
      contributing LSA: 5/10.2.0.0/2.2.2.2        « Type-5 LSA received from ASBR R2
      contributing LSA: 5/10.2.0.0/3.3.3.3
     Flags: RIB, PartialSPF
      via 10.1.1.1, GigabitEthernet0/1 label 1048578
       Flags: RIB
       LSA: 5/10.2.0.0/2.2.2.2




R1#show ip ospf database external 10.2.0.0

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

                Type-5 AS External Link States

  LS age: 1175
  Options: (No TOS-capability, DC, Upward)
  LS Type: AS External Link
  Link State ID: 10.2.0.0 (External Network Number )
  Advertising Router: 2.2.2.2
  LS Seq Number: 80000001
  Checksum: 0xB402
  Length: 36
  Network Mask: /24
        Metric Type: 2 (Larger than any link state path)
        MTID: 0 
        Metric: 1                                 « ASBR R2 assigns metric 1
        Forward Address: 0.0.0.0
        External Route Tag: 65002

  LS age: 1175
  Options: (No TOS-capability, DC, Upward)
  LS Type: AS External Link
  Link State ID: 10.2.0.0 (External Network Number )
  Advertising Router: 3.3.3.3
  LS Seq Number: 80000001
  Checksum: 0xF0B8
  Length: 36
  Network Mask: /24
        Metric Type: 2 (Larger than any link state path)
        MTID: 0 
        Metric: 10                                « ASBR R3 assigns metric 10
        Forward Address: 0.0.0.0
        External Route Tag: 65002



Host#trace 10.2.0.1 probe 1
Type escape sequence to abort.
Tracing the route to 10.2.0.1
VRF info: (vrf in name/id, vrf out name/id)
  1 10.1.0.2 1 msec
  2 10.1.1.1 1 msec                               « ASBR R2 is primary gateway for egress traffic
  3 10.0.1.2 2 msec
  4 10.2.0.1 7 msec

OSPF Forward Metric and LSA Type-4 (cost to reach ASBR)

In the following example scenario, ASBR R6 and ASBR R7 redistribute EIGRP routes into OSPF. These routes are flooded in the OSPF domain as Type-5 external LSAs. At the same time, ABR R3 and ABR R4 automatically generate Type-4 ASBR Summary LSAs that inform routers in area 0 about the ABR's distance to the ASBR.

In other words, the OSPF Type-4 LSA is a Summary LSA that informs about an inter-area route from the originating ABR to the ASBR. The metric in a Type-4 LSA is the cost to reach the ASBR from the ABR.

Type-4 LSA OSPF ASBR Summary Link State Advertisement

Configuration:

R1
    R1#show run | sec ^router
    router ospf 10
     router-id 1.1.1.1
     network 10.0.1.0 0.0.0.3 area 0
    
    R1#show run int Gi0/0 | sec int
    interface GigabitEthernet0/0
     description ** to R2 **
     ip address 10.0.1.1 255.255.255.252
     ip ospf network point-to-point
     duplex auto
     speed auto
     media-type rj45
    
R2
    R2#show run | sec ^router
    router ospf 10
     router-id 2.2.2.2
     network 10.0.1.0 0.0.0.3 area 0
     network 10.0.2.0 0.0.0.3 area 0
     network 10.0.3.0 0.0.0.3 area 0
    
    R2#show run int Gi0/0 | sec int
    interface GigabitEthernet0/0
     description ** to R1 **
     ip address 10.0.1.2 255.255.255.252
     ip ospf network point-to-point
     duplex auto
     speed auto
     media-type rj45
    
    R2#show run int Gi0/1 | sec int 
    interface GigabitEthernet0/1
     description ** to ABR R3 **
     ip address 10.0.2.1 255.255.255.252
     ip ospf network point-to-point
     duplex auto
     speed auto
     media-type rj45
    
    R2#show run int Gi0/2 | sec int
    interface GigabitEthernet0/2
     description ** to ABR R4 **
     ip address 10.0.3.1 255.255.255.252
     ip ospf network point-to-point
     duplex auto
     speed auto
     media-type rj45
    
R3 (ABR)
    R3#show run | sec ^router
    router ospf 10
     router-id 3.3.3.3
     network 10.0.2.0 0.0.0.3 area 0
     network 10.1.1.0 0.0.0.3 area 1
    
    R3#show run int Gi0/0 | sec int
    interface GigabitEthernet0/0
     description ** to R2 **
     ip address 10.0.2.2 255.255.255.252
     ip ospf network point-to-point
     duplex auto
     speed auto
     media-type rj45
    
    R3#show run int Gi0/1 | sec int
    interface GigabitEthernet0/1
     description ** to R5 **
     ip address 10.1.1.1 255.255.255.252
     ip ospf network point-to-point
     duplex auto
     speed auto
     media-type rj45
    
R4 (ABR)
    R4#show run | sec ^router
    router ospf 10
     router-id 4.4.4.4
     network 10.0.3.0 0.0.0.3 area 0
     network 10.1.3.0 0.0.0.3 area 1
    
    R4#show run int Gi0/0 | sec ^int   
    interface GigabitEthernet0/0
     description ** to R2 **
     ip address 10.0.3.2 255.255.255.252
     ip ospf network point-to-point
     duplex auto
     speed auto
     media-type rj45
    
    R4#show run int Gi0/1 | sec ^int
    interface GigabitEthernet0/1
     description ** to ASBR R7 **
     ip address 10.1.3.1 255.255.255.252
     ip ospf network point-to-point
     duplex auto
     speed auto
     media-type rj45
    
R5
    R5#show run | sec ^router
    router ospf 10
     router-id 5.5.5.5
     network 10.1.1.0 0.0.0.3 area 1
     network 10.1.2.0 0.0.0.3 area 1
    
    R5#show run int Gi0/0 | sec int
    interface GigabitEthernet0/0
     description ** to ABR R3 **
     ip address 10.1.1.2 255.255.255.252
     ip ospf network point-to-point
     duplex auto
     speed auto
     media-type rj45
    
    R5#show run int Gi0/1 | sec int
    interface GigabitEthernet0/1
     description ** to ASBR R6 **
     ip address 10.1.2.1 255.255.255.252
     ip ospf network point-to-point
     ip ospf cost 15
     duplex auto
     speed auto
     media-type rj45
    
R6 (ASBR)
    R6#show run | sec ^router
    router eigrp EXAMPLE-EIGRP
     !
     address-family ipv4 unicast autonomous-system 10
      !
      topology base
       default-metric 1000 1 1 1 1500
       redistribute ospf 10
      exit-af-topology
      network 10.2.1.0 0.0.0.3
      eigrp router-id 6.6.6.6
     exit-address-family
    router ospf 10
     router-id 6.6.6.6
     redistribute eigrp 10 subnets route-map RM-REDIST
     network 10.1.2.0 0.0.0.3 area 1
    
    R6#show run | sec ^route-map
    route-map RM-REDIST permit 10
     match ip address prefix-list PL-REDIST
    
    R6#show run | sec ^ip prefix
    ip prefix-list PL-REDIST seq 5 permit 192.168.1.0/24
    ip prefix-list PL-REDIST seq 10 permit 192.168.2.0/24
    
    R6#show run int Gi0/0 | sec int
    interface GigabitEthernet0/0
     description ** to R5 **
     ip address 10.1.2.2 255.255.255.252
     ip ospf network point-to-point
     duplex auto
     speed auto
     media-type rj45
    
    R6#show run int Gi0/1 | sec int
    interface GigabitEthernet0/1
     description ** to R8 **
     ip address 10.2.1.1 255.255.255.252
     duplex auto
     speed auto
     media-type rj45
    
R7 (ASBR)
    R7#show run | sec ^router
    router eigrp EXAMPLE-EIGRP
     !
     address-family ipv4 unicast autonomous-system 10
      !
      topology base
       default-metric 1000 1 1 1 1500
       redistribute ospf 10
      exit-af-topology
      network 10.2.2.0 0.0.0.3
      eigrp router-id 7.7.7.7
     exit-address-family
    router ospf 10
     router-id 7.7.7.7
     redistribute eigrp 10 subnets route-map RM-REDIST
     network 10.1.3.0 0.0.0.3 area 1
    
    R7#show run | sec ^route-map
    route-map RM-REDIST permit 10
     match ip address prefix-list PL-REDIST
    
    R7#show run | sec ^ip prefix
    ip prefix-list PL-REDIST seq 5 permit 192.168.1.0/24
    ip prefix-list PL-REDIST seq 10 permit 192.168.2.0/24
    
    R7#show run int Gi0/0 | sec int
    interface GigabitEthernet0/0
     description ** to ABR R4 **
     ip address 10.1.3.2 255.255.255.252
     ip ospf network point-to-point
     duplex auto
     speed auto
     media-type rj45
    
    R7#show run int Gi0/1 | sec int
    interface GigabitEthernet0/1
     description ** to R8 **
     ip address 10.2.2.1 255.255.255.252
     duplex auto
     speed auto
     media-type rj45
    
R8
    R8#show run | sec ^router
    router eigrp EXAMPLE-EIGRP
     !
     address-family ipv4 unicast autonomous-system 10
      !
      topology base
      exit-af-topology
      network 10.2.1.0 0.0.0.3
      network 10.2.2.0 0.0.0.3
      network 192.168.1.0
      network 192.168.2.0
      eigrp router-id 8.8.8.8
     exit-address-family
    
    R8#show run int Gi0/0 | sec int
    interface GigabitEthernet0/0
     description ** to ASBR R6 **
     ip address 10.2.1.2 255.255.255.252
     duplex auto
     speed auto
     media-type rj45
    
    R8#show run int Gi0/1 | sec int
    interface GigabitEthernet0/1
     description ** to ASBR R7 **
     ip address 10.2.2.2 255.255.255.252
     duplex auto
     speed auto
     media-type rj45
    
    R8#show run int Lo10 | sec int 
    interface Loopback10
     ip address 192.168.1.1 255.255.255.0
    
    R8#show run int Lo20 | sec int
    interface Loopback20
     ip address 192.168.2.1 255.255.255.0
    
R2#show ip ospf database 

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

                Router Link States (Area 0)

Link ID         ADV Router      Age         Seq#       Checksum Link count
1.1.1.1         1.1.1.1         233         0x80000002 0x006F8E 2
2.2.2.2         2.2.2.2         232         0x80000004 0x00B1BA 6
3.3.3.3         3.3.3.3         308         0x80000002 0x000ADF 2
4.4.4.4         4.4.4.4         299         0x80000002 0x00DFFF 2

                Summary Net Link States (Area 0)

Link ID         ADV Router      Age         Seq#       Checksum
10.1.1.0        3.3.3.3         313         0x80000001 0x008D99
10.1.2.0        3.3.3.3         285         0x80000001 0x0019FD
10.1.3.0        4.4.4.4         306         0x80000001 0x0059C7

                Summary ASB Link States (Area 0)                  « These are the Type-4 LSAs flooded by the ABRs into area 0

Link ID         ADV Router      Age         Seq#       Checksum
6.6.6.6         3.3.3.3         245         0x80000001 0x00AC5B   « "Link ID" is Router ID of ASBR, "ADV Router" is ABR
7.7.7.7         4.4.4.4         281         0x80000001 0x00C945
          
                Type-5 AS External Link States

Link ID         ADV Router      Age         Seq#       Checksum Tag
192.168.1.0     6.6.6.6         244         0x80000001 0x0076A7 0
192.168.1.0     7.7.7.7         239         0x80000001 0x0058C1 0
192.168.2.0     6.6.6.6         244         0x80000001 0x006BB1 0
192.168.2.0     7.7.7.7         239         0x80000001 0x004DCB 0





R2#show ip ospf database asbr-summary 

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

                Summary ASB Link States (Area 0)

  LS age: 300
  Options: (No TOS-capability, DC, Upward)
  LS Type: Summary Links(AS Boundary Router)
  Link State ID: 6.6.6.6 (AS Boundary Router address)     « Router ID of the ASBR
  Advertising Router: 3.3.3.3                             « Router ID of the ABR advertising this LSA
  LS Seq Number: 80000001
  Checksum: 0xAC5B
  Length: 28
  Network Mask: /0
        MTID: 0         Metric: 16                        « OSPF cost from the ABR to the ASBR

  LS age: 337
  Options: (No TOS-capability, DC, Upward)
  LS Type: Summary Links(AS Boundary Router)
  Link State ID: 7.7.7.7 (AS Boundary Router address)
  Advertising Router: 4.4.4.4
  LS Seq Number: 80000001
  Checksum: 0xC945
  Length: 28
  Network Mask: /0
        MTID: 0         Metric: 1 





R2#show ip ospf database asbr-summary 6.6.6.6                « This command queries the ASBR

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

                Summary ASB Link States (Area 0)

  LS age: 337
  Options: (No TOS-capability, DC, Upward)
  LS Type: Summary Links(AS Boundary Router)
  Link State ID: 6.6.6.6 (AS Boundary Router address)
  Advertising Router: 3.3.3.3
  LS Seq Number: 80000001
  Checksum: 0xAC5B
  Length: 28
  Network Mask: /0
        MTID: 0         Metric: 16





R2#show ip ospf database asbr-summary adv-router 3.3.3.3     « This command queries the ABR that creates the Type-4 summary LSA

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

                Summary ASB Link States (Area 0)

  LS age: 351
  Options: (No TOS-capability, DC, Upward)
  LS Type: Summary Links(AS Boundary Router)
  Link State ID: 6.6.6.6 (AS Boundary Router address)
  Advertising Router: 3.3.3.3
  LS Seq Number: 80000001
  Checksum: 0xAC5B
  Length: 28
  Network Mask: /0
        MTID: 0         Metric: 16 

An important metric is derived from the Type-4 LSA. The Forwarding Cost (or Forward Metric) is used on R2 to decide which external Type-5 LSA to install in its routing table. The Forwarding Cost of an OSPF external route is the metric to reach the ASBR, and it is used to select the shortest path to the external route.

In other words, the ASBRs redistribute EIGRP prefixes as OSPF E2 routes. OSPF E2 routes do not change their metric while they are flooded in the OSPF domain. Thus, looking at the E2 route metric alone, R2 can not know if the path through ASBR R6 or ASBR R7 is shorter. This is why R2 examines the Forwarding Cost to reach the ASBRs, and finds that ASBR R7 is the best path based on the lower Forwarding Cost. As a result, R2 installs the Type-5 LSA originated by ASBR R7.

R2#show ip ospf database external 192.168.1.0

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

                Type-5 AS External Link States

  LS age: 1247
  Options: (No TOS-capability, DC, Upward)
  LS Type: AS External Link
  Link State ID: 192.168.1.0 (External Network Number )
  Advertising Router: 6.6.6.6              « Type-5 LSA originated on ASBR R6
  LS Seq Number: 80000001
  Checksum: 0x76A7
  Length: 36
  Network Mask: /24
        Metric Type: 2 (Larger than any link state path)
        MTID: 0 
        Metric: 20                         « Has E2 metric 20
        Forward Address: 0.0.0.0           « Forward address set to 0.0.0.0 because ASBR R6 is not in NSSA, but in normal area
        External Route Tag: 0

  LS age: 1241
  Options: (No TOS-capability, DC, Upward)
  LS Type: AS External Link
  Link State ID: 192.168.1.0 (External Network Number )
  Advertising Router: 7.7.7.7
  LS Seq Number: 80000001
  Checksum: 0x58C1
  Length: 36
  Network Mask: /24
        Metric Type: 2 (Larger than any link state path)
        MTID: 0 
        Metric: 20                         « Type-5 LSA from ASBR R7 also has same E2 metric 20
        Forward Address: 0.0.0.0
        External Route Tag: 0





R2#show ip ospf database asbr-summary 

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

                Summary ASB Link States (Area 0)

  LS age: 1557
  Options: (No TOS-capability, DC, Upward)
  LS Type: Summary Links(AS Boundary Router)
  Link State ID: 6.6.6.6 (AS Boundary Router address)     
  Advertising Router: 3.3.3.3
  LS Seq Number: 80000001
  Checksum: 0xAC5B
  Length: 28
  Network Mask: /0
        MTID: 0         Metric: 16                     « However, the Type-4 LSA informs about the distance to reach the ASBR

  LS age: 1594
  Options: (No TOS-capability, DC, Upward)
  LS Type: Summary Links(AS Boundary Router)
  Link State ID: 7.7.7.7 (AS Boundary Router address)
  Advertising Router: 4.4.4.4
  LS Seq Number: 80000001
  Checksum: 0xC945
  Length: 28
  Network Mask: /0
        MTID: 0         Metric: 1                      « ASBR R7 has a lower metric from the ABR





R2#show ip ospf rib 192.168.1.0

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


                Base Topology (MTID 0)

OSPF local RIB
Codes: * - Best, > - Installed in global RIB
LSA: type/LSID/originator

*>  192.168.1.0/24, Ext2, cost 20, fwd cost 2, tag 0   « As a result, R2 prefers the Type-5 LSA to ASBR R7
     SPF Instance 10, age 00:26:09
      contributing LSA: 5/192.168.1.0/7.7.7.7
      contributing LSA: 5/192.168.1.0/6.6.6.6
     Flags: RIB
      via 10.0.3.2, GigabitEthernet0/2 label 1048578
       Flags: RIB
       LSA: 5/192.168.1.0/7.7.7.7





R2#show ip ospf rib 192.168.1.0

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


                Base Topology (MTID 0)

OSPF local RIB
Codes: * - Best, > - Installed in global RIB
LSA: type/LSID/originator

*>  192.168.1.0/24, Ext2, cost 20, fwd cost 17, tag 0  « If ABR R4 fails, the forwarding cost reflects the cost to reach ASBR R6
     SPF Instance 11, age 00:03:01
      contributing LSA: 5/192.168.1.0/6.6.6.6
     Flags: RIB
      via 10.0.2.2, GigabitEthernet0/1 label 1048578
       Flags: RIB
       LSA: 5/192.168.1.0/6.6.6.6

Download section

Disclaimer: You download and use files from networkstudysite.com at your own risk.

Lab YAML files:

  • OSPF Redistribution, configured on R2 and on R3, note that R2 redistributes routes as OSPF External Type-1, and R3 redistributes as External Type-2, this can be verified and compared on R1 with the command show ip ospf database external 192.168.1.0, E1 is always preferred over E2 — ospf-redistribution-e1-vs-e2-route.yaml
  • OSPF default route metric, configured on R3, the cost 10 is assigned to the default route originated by R3, as a result R2 is chosen as the next hop because it has a more preferred (lower) cost default route — ospf-default-route-metric.yaml
  • OSPF ASBR Summary Type-4 LSA, R3 and R4 send Type-4 ASBR Summary LSA to R2, this can be verified on R2 with the command show ip ospf database asbr-summaryospf-summary-lsa-type-4.yaml

Packet captures:

How to use these files:

With YAML files you can easily recreate the example labs on networkstudysite.com. Learn more in this short guide.

Explore 313 packet captures

You can find more information at the following external links:

By clicking on the links below, you are leaving the networkstudysite.com website.

Cisco Press - Understanding the OSPF Link-State Routing Protocol

Cisco - Understand Open Shortest Path First (OSPF) - Design Guide

Cisco Community - How to configure OSPF cost

Cisco Community - OSPF Forward Metric

RFC 2328 - OSPF Version 2

Disclaimer:

Use at your own risk: networkstudysite.com makes no representations as to accuracy, completeness, currentness, suitability, or validity of any information found on this website. Full disclaimer on the About page.

Privacy Policy:

networkstudysite.com does not install browser cookies to collect or store your data.

Thank you for your interest in this blog post!

Looking for something else? View infographics, explore the archives or read the recommended posts below: