Pages

Tuesday, November 11, 2014

Understanding OSPF - Forward Metric in E2 Routes

In this blogtorial we are going to look into a minor detail regarding OSPF E2 routes that most literature happen to leave out and that is the Forward Metric of E2 routes. Cisco NX-OS and Arista EOS don't even show this Forward Metric in their output of show commands. As you are probably studying for your CCNA or CCNP you are told that the main difference between OSPF E2 vs E1 routes is that E1 takes into consideration the costs of each hop to reach the ASBR while E2 metric is by default 20. What if I told you that routers do consider cost of the path to the ASBR even for E2 routes with a default metric of 20? Before you get fooled into believing otherwise, take a look at the topology below.

As a side note the metric of redistributed E2 routes varies by platform, for example it is 1 in Arista.

Simple topology below ...



First let's get interfaces configured on R1, R2, R3.

 R1#sh run int fast0/0  
 interface FastEthernet0/0  
  description connected to r2  
  ip address 1.1.1.1 255.255.255.0  
  duplex auto  
  speed auto  

 R1#sh run int fast0/1   
 interface FastEthernet0/1  
  description connected to r3  
  ip address 2.2.2.1 255.255.255.0  
  duplex auto  
  speed auto  

 R2#sh run int fast0/0  
 interface FastEthernet0/0  
  description connected to r1  
  ip address 1.1.1.2 255.255.255.0  
  duplex auto  
  speed auto  

 R2#sh run int fast0/1  
 interface FastEthernet0/1  
  description connected to lan  
  ip address 192.168.1.2 255.255.255.0  
  duplex auto  
  speed auto  

 R3#sh run int fast0/0  
 interface FastEthernet0/0  
  description connected to r1  
  ip address 2.2.2.3 255.255.255.0  
  duplex auto  
  speed auto  

 R3#sh run int fast0/1  
 interface FastEthernet0/1  
  description connected to lan  
  ip address 192.168.1.3 255.255.255.0  
  duplex auto  
  speed auto  

Next let's get basic OSPF configured and redistribute 192.168.1.0/24 from both R2 and R3 and as you would expect R1 is load balancing between R2 and R3 to reach 192.168.1.0/24. Note that the metric is 20.

 R1#sh run | sec ospf  
 router ospf 1  
  log-adjacency-changes  
  network 1.1.1.0 0.0.0.255 area 0  
  network 2.2.2.0 0.0.0.255 area 0  
   
 R2#sh run | sec ospf  
 router ospf 1  
  log-adjacency-changes  
  redistribute connected subnets  
  network 1.1.1.0 0.0.0.255 area 0  
   
 R3#sh run | sec ospf  
 router ospf 1  
  log-adjacency-changes  
  redistribute connected subnets  
  network 2.2.2.0 0.0.0.255 area 0  

 R1#sh ip route  
 O E2 192.168.1.0/24 [110/20] via 2.2.2.3, 00:00:01, FastEthernet0/1  
                     [110/20] via 1.1.1.2, 00:00:01, FastEthernet0/0  

It's a common misconception that OSPF E2 routes doesn't care about the cost of the path to the ASBR but notice how the changes to the cost to get to the ASBR affects the routes installed into the routing table.

Let's change the cost of the path by changing the interface cost to R3 on R1.

 R1#conf t  
 R1(config)#int fast0/1  
 R1(config-if)#ip ospf cost 10000  
 R1(config-if)#exit  
 R1(config)#exit  
 R1#sh ip route   
   
 R1# sh run int fast0/1  
 interface FastEthernet0/1  
  description connected to r3  
  ip address 2.2.2.1 255.255.255.0  
  ip ospf cost 10000  
  duplex auto  
  speed auto  
 end  
   
 R1#sh ip route 192.168.1.0  
 Routing entry for 192.168.1.0/24  
  Known via "ospf 1", distance 110, metric 20, type extern 2, forward metric 1  
  Last update from 1.1.1.2 on FastEthernet0/0, 00:01:04 ago  
  Routing Descriptor Blocks:  
  * 1.1.1.2, from 192.168.1.2, 00:01:04 ago, via FastEthernet0/0  
    Route metric is 20, traffic share count is 1  
   
 R1#sh ip route        
 O E2 192.168.1.0/24 [110/20] via 1.1.1.2, 00:01:36, FastEthernet0/0  

I thought E2 routes didn't care about OSPF costs to the ASBR, well it turns out that the forward metric is used when installing E2 routes. If more than one E2 route exists for a given prefix then the E2 route with the lower forward metric wins. Forward metric is the metric to get to the ASBR.

I shutdown R1 fast0/0 connecting to R2 to show you the forward metric of 192.168.1.0/24 from R3 on R1.

 R1#sh ip route 192.168.1.0   
 Routing entry for 192.168.1.0/24  
  Known via "ospf 1", distance 110, metric 20, type extern 2, forward metric 10000  
  Last update from 2.2.2.3 on FastEthernet0/1, 00:00:04 ago  
  Routing Descriptor Blocks:  
  * 2.2.2.3, from 2.2.2.3, 00:00:04 ago, via FastEthernet0/1  
    Route metric is 20, traffic share count is 1  

Now let's set both interfaces on R1 cost to 10000 and redistribute 198.168.0.1 as a E1 route on R2/R3 and see how the forward metric is changed.

 R2(config)#router ospf 1  
 R2(config-router)#redistribute connected subnets metric-type 1  
   
 R3(config)#router ospf 1  
 R3(config-router)#redistribute connected subnets metric-type 1  
   
 R1(config)#int fast0/0  
 R1(config-if)#ip ospf cost 10000  
 R1(config-if)#exit  
 R1(config)#exit  

 R1#sh ip route   
   
 R1#sh ip route 192.168.1.0  
 Routing entry for 192.168.1.0/24  
  Known via "ospf 1", distance 110, metric 10020, type extern 1  
  Last update from 2.2.2.3 on FastEthernet0/1, 00:00:04 ago  
  Routing Descriptor Blocks:  
   2.2.2.3, from 2.2.2.3, 00:00:04 ago, via FastEthernet0/1  
    Route metric is 10020, traffic share count is 1  
  * 1.1.1.2, from 192.168.1.2, 00:00:04 ago, via FastEthernet0/0  
    Route metric is 10020, traffic share count is 1  

Notice that the metric is now 10020 instead of 10000 because metric in E1 is path cost to the ASBR (which in this case is 10000 set by the ip ospf cost command on R1's interface) + the Cisco's default redistributed cost which is 20.

Also keep in mind when multiple routes exists OSPF will pick ...
  1. Intra-Area (O)
  2. Inter-Area (O IA)
  3. External Type 1 (E1)
  4. External Type 2 (E2)
  5. NSSA Type 1 (N1)
  6. NSSA Type 2 (N2)
Many more articles to come so ....

Please subscribe/comment/+1 if you like my posts as it keeps me motivated to write more and spread the knowledge.

No comments:

Post a Comment