Social Icons

Saturday, April 12, 2014

CCNP ROUTE: 3. Setting OSPF Metrics on Redistributed Routes

No matter the source of the redistributed route, OSPF has a default metric to use (1 for BGP, source route’s metric for another OSPF process, 20 for everything else).
However, OSPF can set the metrics for redistributed routes using the same options used for EIGRP.

Other options besides using the default metric are:

- Setting the default for all redistribute commands: The default-metric cost OSPF subcommand.
- Setting the metric for one route source: The metric cost parameters on the redistribute command.
- Setting different metrics for routes learned from a single source: Use the route-map parameter on the redistribute command.

OSPF defines external routes as either an external type 1 (E1) or external type 2 (E2) route.
By default, the OSPF redistribute command creates Type 2 routes, noting this external route type in the Type 5 LSA. 
The difference between the two lies in how OSPF calculates the metrics for E1 and E2 routes.

Case 1: Redistributing into OSPF as E2 Routes (default)

The router that performs the redistribution into OSPF becomes an autonomous system border router (ASBR) because it injects external routes into OSPF.
For each such route, that ASBR creates a Type 5 LSA for that subnet.
The Type 5 LSA includes the following fields:
- LSID: The subnet number
- Mask: The subnet mask
- Advertising router: The RID of the ASBR injecting the route
- Metric: The metric as set by the ASBR
- External Metric Type: The external metric type, either 1 or 2

When created, the ASBR floods the Type 5 LSA throughout the area.
Then, if any ABRs exist, the ABRs flood the Type 5 LSAs into any normal (nonstubby) areas.
When flooded, OSPF has little work to do to calculate the metric for an E2 route, because by definition, the E2 route’s metric is simply the metric listed in the Type 5 LSA.
In other words, the OSPF routers do not add any internal OSPF cost to the metric for an E2 route.
Because routers ignore internal cost when calculating E2 external route metrics, whenever an alternative route can be calculated, the metrics tie.

To avoid loops, OSPF routers use a tiebreaker system to allow a router to choose a best external route.
The logic differs slightly depending on whether the router in question resides in the same area as the ASBR (intra-area), or in a different area (interarea).

Rule (intra-area): When a router finds multiple routes for the same E2 destination subnet, it chooses the best route based on the lowest cost to reach any ASBR(s) that advertised the lowest E2 metric.
For example, if five ASBRs all advertised the same subnet as an E2 route, and two ASBRs advertised a metric of 10, and the other three advertised a metric of 20, either of the first two ASBRs could be used.
Then, the router calculates its lowest cost route to reach the ASBR and uses the next-hop IP address and outgoing interface listed in that route.

Addition to the rule (for inter-area): When the ASBR is in a different area, the calculation of the cost to reach the ASBR requires more information, and even an additional LSA type, as compared with the intra-area calculation.
To calculate their best route to reach the ASBR, a router in another area adds the cost to reach an ABR between the areas, plus that ABR’s cost to reach the ASBR.

ABRs create this new type of LSA—the Type 4 Summary ASBR LSA—to support the logic mentioned at Step 2.
The Type 4 ASBR LSA lists the RID of the ASBR, and the RID of the ABR that created and flooded the Type 4 LSA.
Most importantly, the Type 4 LSA lists that ABR’s cost to reach the ASBR.
In effect, the LSA makes an announcement like this: “I am ABR X, I can reach ASBR Y, and my cost to reach that ASBR is Z.”

ABRs create Type 4 LSAs in reaction to receiving an external LSA from some ASBR.
When an ABR forwards a Type 5 LSA into an area, the ABR looks at the RID of the ASBR that created the Type 5 LSA.
The ABR then creates a Type 4 LSA listing that ASBR, and the cost to reach that ASBR, flooding that Type 4 LSA into the neighboring areas.

The following list spells out the mechanics of the calculation used to break the tie when multiple equal-cost E2 routes exist for a particular subnet:
Step 1. Find the advertising ASBR(s) as listed in the Type 5 LSA(s) for Type 5 LSAs.
Step 2. Calculate the lowest cost route to reach any of the ASBR(s) based on the intra-area LSDB topology.
Step 3. Use the outgoing interface and next hop based on the best route to reach the ASBR (as chosen at Step 2).
Step 4. The route’s metric is unchanged–it is still simply the value listed in the Type 5 LSA.

In our topology, let's consider the route(s) R1 is learning from ASBRs R4 and R5 (both being configured with redistribution) regarding subnet 172.16.0.8/30 on R6.

R4#show run | i redistribute
 redistribute eigrp 1 subnets
R5#show run | i redistribute
 redistribute eigrp 1 subnets

Both ASBRs generate a Type 5 LSA into the OSPF domain, having the same default metric (20) and the same external type (E2), as shown by the database and routing table on R1:

R1#show ip ospf database          

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

                Router Link States (Area 0)

Link ID         ADV Router      Age         Seq#       Checksum Link count
1.1.1.1         1.1.1.1         1440        0x80000006 0x00AA61 8
2.2.2.2         2.2.2.2         1482        0x80000004 0x00E756 1
3.3.3.3         3.3.3.3         1440        0x80000004 0x004160 2
4.4.4.4         4.4.4.4         165         0x80000005 0x006030 2
5.5.5.5         5.5.5.5         918         0x80000005 0x00A4DB 2
9.9.9.9         9.9.9.9         1502        0x80000003 0x000B4E 2

                Net Link States (Area 0)

Link ID         ADV Router      Age         Seq#       Checksum
192.168.0.3     3.3.3.3         1439        0x80000003 0x006C3E

                Summary Net Link States (Area 0)

Link ID         ADV Router      Age         Seq#       Checksum
10.0.1.1        9.9.9.9         1502        0x80000003 0x00DE2C
10.0.1.2        9.9.9.9         1502        0x80000003 0x005772
10.0.1.3        9.9.9.9         1502        0x80000003 0x004D7B
10.0.10.10      9.9.9.9         1504        0x80000003 0x00AD0A
10.0.11.11      9.9.9.9         1504        0x80000003 0x00981D
192.168.3.0     9.9.9.9         1504        0x80000003 0x00F5AD
192.168.33.33   9.9.9.9         1504        0x80000003 0x007BE4
192.168.168.0   2.2.2.2         1484        0x80000003 0x00AA6F
192.168.169.170 2.2.2.2         1484        0x80000003 0x001159

                Type-5 AS External Link States

Link ID         ADV Router      Age         Seq#       Checksum Tag
172.16.0.0      4.4.4.4         167         0x80000003 0x00D301 0
172.16.0.0      5.5.5.5         920         0x80000001 0x00B919 0
172.16.0.4      4.4.4.4         167         0x80000003 0x00AB25 0
172.16.0.4      5.5.5.5         920         0x80000001 0x00913D 0
172.16.0.8      4.4.4.4         167         0x80000003 0x008349 0
172.16.0.8      5.5.5.5         920         0x80000001 0x006961 0
172.16.0.12     4.4.4.4         167         0x80000003 0x005B6D 0
172.16.0.12     5.5.5.5         921         0x80000001 0x004185 0
172.16.111.0    4.4.4.4         169         0x80000003 0x001C46 0
172.16.111.0    5.5.5.5         921         0x80000001 0x00025E 0
192.168.44.0    4.4.4.4         169         0x80000003 0x00D325 0
192.168.44.0    5.5.5.5         921         0x80000001 0x00B93D 0
192.168.55.0    4.4.4.4         169         0x80000003 0x005A93 0
192.168.55.0    5.5.5.5         922         0x80000001 0x0040AB 0

R1#show ip route ospf                 
     192.168.13.0/32 is subnetted, 1 subnets
O       192.168.13.13 [110/11] via 192.168.0.3, 00:15:34, FastEthernet0/0
O E2 192.168.44.0/24 [110/20] via 192.168.0.18, 00:15:34, Serial0/2
                     [110/20] via 192.168.0.14, 00:15:34, Serial0/1
     172.16.0.0/16 is variably subnetted, 5 subnets, 2 masks
O E2    172.16.0.12/30 [110/20] via 192.168.0.18, 00:15:34, Serial0/2
                       [110/20] via 192.168.0.14, 00:15:34, Serial0/1
O E2    172.16.0.8/30 [110/20] via 192.168.0.18, 00:15:34, Serial0/2
                      [110/20] via 192.168.0.14, 00:15:34, Serial0/1
O E2    172.16.0.4/30 [110/20] via 192.168.0.18, 00:15:34, Serial0/2
                      [110/20] via 192.168.0.14, 00:15:34, Serial0/1
O E2    172.16.0.0/30 [110/20] via 192.168.0.18, 00:15:34, Serial0/2
                      [110/20] via 192.168.0.14, 00:15:34, Serial0/1
O E2    172.16.111.0/24 [110/20] via 192.168.0.18, 00:15:34, Serial0/2
                        [110/20] via 192.168.0.14, 00:15:34, Serial0/1
O E2 192.168.55.0/24 [110/20] via 192.168.0.18, 00:15:35, Serial0/2
                     [110/20] via 192.168.0.14, 00:15:35, Serial0/1
     10.0.0.0/32 is subnetted, 5 subnets
O IA    10.0.1.3 [110/128] via 192.168.0.22, 00:15:35, Serial0/0
O IA    10.0.1.2 [110/128] via 192.168.0.22, 00:15:35, Serial0/0
O IA    10.0.11.11 [110/129] via 192.168.0.22, 00:15:35, Serial0/0
O IA    10.0.10.10 [110/129] via 192.168.0.22, 00:15:35, Serial0/0
O IA    10.0.1.1 [110/64] via 192.168.0.22, 00:15:35, Serial0/0
     192.168.168.0/30 is subnetted, 1 subnets
O IA    192.168.168.0 [110/20] via 192.168.0.2, 00:15:36, FastEthernet0/0
     192.168.169.0/32 is subnetted, 1 subnets
O IA    192.168.169.170 [110/21] via 192.168.0.2, 00:15:36, FastEthernet0/0
     192.168.3.0/30 is subnetted, 1 subnets
O IA    192.168.3.0 [110/74] via 192.168.0.22, 00:15:36, Serial0/0
     192.168.33.0/32 is subnetted, 1 subnets
O IA    192.168.33.33 [110/75] via 192.168.0.22, 00:15:36, Serial0/0

At this moment, having the same cost to reach each ASBR, R1 installs all Type 5 LSAs received, since they all have the same parameters and load balances between the ASBR when sending to the external networks (172.16.0.8 included).
According to the steps above, R1 calculates the lowest cost route to reach any of the ASBR(s) - equal cost for the moment.
After modifying the cost to reach R5 (by increasing it), R1 will eventually choose R4 to be the next hop for its traffic to R6 and 172.16.0.8/30.

Formula for OSPF cost calculation is:
Interface Cost = Reference bandwidth / Interface bandwidth

Both links being serial links (1544 Kbps) and the reference bandwidth being 100Mbps, that leads to a cost of 64 on each link.
Modifying the bandwidth on the outgoing interface to R5 will determine R1 to recalculate the OSPF cost to ASBR R5 and finally choose ASBR R4 to be the next hop to the 172.16.x.x subnets.

R1#show interfaces serial 0/2
Serial0/2 is up, line protocol is up
  Hardware is GT96K Serial
  Internet address is 192.168.0.17/30
  MTU 1500 bytes, BW 1544 Kbit/sec, DLY 20000 usec
R1(config)#interface serial 0/2
R1(config-if)#bandwidth 1000
R1#show interfaces serial 0/2
Serial0/2 is up, line protocol is up
  Hardware is GT96K Serial
  Internet address is 192.168.0.17/30
  MTU 1500 bytes, BW 1000 Kbit/sec, DLY 20000 usec

R1#show ip route ospf
     192.168.13.0/32 is subnetted, 1 subnets
O       192.168.13.13 [110/11] via 192.168.0.3, 00:09:42, FastEthernet0/0
O E2 192.168.44.0/24 [110/20] via 192.168.0.14, 00:09:42, Serial0/1
     172.16.0.0/16 is variably subnetted, 5 subnets, 2 masks
O E2    172.16.0.12/30 [110/20] via 192.168.0.14, 00:09:42, Serial0/1
O E2    172.16.0.8/30 [110/20] via 192.168.0.14, 00:09:42, Serial0/1
O E2    172.16.0.4/30 [110/20] via 192.168.0.14, 00:09:42, Serial0/1
O E2    172.16.0.0/30 [110/20] via 192.168.0.14, 00:09:42, Serial0/1
O E2    172.16.111.0/24 [110/20] via 192.168.0.14, 00:09:42, Serial0/1
O E2 192.168.55.0/24 [110/20] via 192.168.0.14, 00:09:42, Serial0/1
     10.0.0.0/32 is subnetted, 5 subnets
O IA    10.0.1.3 [110/128] via 192.168.0.22, 00:09:42, Serial0/0
O IA    10.0.1.2 [110/128] via 192.168.0.22, 00:09:42, Serial0/0
O IA    10.0.11.11 [110/129] via 192.168.0.22, 00:09:42, Serial0/0
O IA    10.0.10.10 [110/129] via 192.168.0.22, 00:09:42, Serial0/0
O IA    10.0.1.1 [110/64] via 192.168.0.22, 00:09:43, Serial0/0
     192.168.168.0/30 is subnetted, 1 subnets
O IA    192.168.168.0 [110/20] via 192.168.0.2, 00:09:43, FastEthernet0/0
     192.168.169.0/32 is subnetted, 1 subnets
O IA    192.168.169.170 [110/21] via 192.168.0.2, 00:09:43, FastEthernet0/0
     192.168.3.0/30 is subnetted, 1 subnets
O IA    192.168.3.0 [110/74] via 192.168.0.22, 00:09:43, Serial0/0
     192.168.33.0/32 is subnetted, 1 subnets
O IA    192.168.33.33 [110/75] via 192.168.0.22, 00:09:44, Serial0/0

So, according to the 4 steps listed above, R1 found the advertising ASBRs, calculated the lowest cost route to reach any of the ASBR(s) and used the outgoing interface and next hop based on the best route to reach the ASBR (via 192.168.0.14, 00:09:42, Serial0/1).

Case 2: Redistributing into OSPF as E1 Routes

OSPF routers calculate the metrics of E1 routes by adding the internal cost to reach the ASBR to the external cost defined on the redistributing ASBR.

Rule: A type 1 route is always preferred over a type 2 route for the same destination.

Having the same configuration as above (on R1 - Se0/1 BW=1544Kbps, Se0/2 BW=1000Kbps), we can modify the metric type on R4 and R5 ASBRs to be E1 and then check the resulting metrics on R1.

R4(config)#router ospf 1
R4(config-router)#redistribute eigrp 1 subnets metric-type 1
R5(config)#router ospf 1
R5(config-router)#redistribute eigrp 1 subnets metric-type 1

R1#show ip route ospf | i E1
O E1 192.168.44.0/24 [110/84] via 192.168.0.14, 00:01:09, Serial0/1
O E1    172.16.0.12/30 [110/84] via 192.168.0.14, 00:01:09, Serial0/1
O E1    172.16.0.8/30 [110/84] via 192.168.0.14, 00:01:09, Serial0/1
O E1    172.16.0.4/30 [110/84] via 192.168.0.14, 00:01:09, Serial0/1
O E1    172.16.0.0/30 [110/84] via 192.168.0.14, 00:01:09, Serial0/1
O E1    172.16.111.0/24 [110/84] via 192.168.0.14, 00:01:09, Serial0/1
O E1 192.168.55.0/24 [110/84] via 192.168.0.14, 00:01:09, Serial0/1

R1 has chosen the path through R4, since the total cost is lower than through R5:
Path(R4) = 20 + 100000/1544 = 84
Path(R5) = 20 + 100000/1000 = 120

R1#show ip ospf border-routers 

OSPF Process 1 internal Routing Table

Codes: i - Intra-area route, I - Inter-area route

i 4.4.4.4 [64] via 192.168.0.14, Serial0/1, ASBR, Area 0, SPF 7
i 5.5.5.5 [100] via 192.168.0.18, Serial0/2, ASBR, Area 0, SPF 7

Note that for routers in a different area than the ASBR, the calculation of metric follows
the same general logic used when breaking ties for E2 routes. Generally, the computation
adds three items:
- The best intra-area cost to reach the ABR (per that area’s LSDB)
- The cost from that ABR to the ASBR (per Type 4 LSA)
- The external cost for the route (per Type 5 LSA)

No comments:

Post a Comment