Monday, June 2, 2008

OSPF - calculating external route metrics

This post explains how to find the costs for E1 and E2 routes in OSPF.

R1 <--- area0 ---> R2 <--- area3 ---> R3

R3 is redistributing it's loopback into area 3.
This route shows up with a cost of 20 on R1

R1#show ip route
Routing entry for
Known via "ospf 1", distance 110, metric 20, type extern 2, forward metric 128
Last update from on Serial1/0, 00:02:54 ago
Routing Descriptor Blocks:
*, from, 00:02:54 ago, via Serial1/0
Route metric is 20, traffic share count is 1

The cost of 20 comes from the default metric applied to routes redistributed routes.
Let's change the metric on R3:

R3(config)#router ospf 1
R3(config-router)#redistribute connected subnets ?
metric Metric for redistributed routes
metric-type OSPF/IS-IS exterior metric type for redistributed routes
route-map Route map reference
tag Set tag for routes redistributed into OSPF

R3(config-router)#redistribute connected subnets metric 30

On R1 we see the metric is 30 now:

R1#show ip route | inc
O E2 [110/30] via, 00:00:40, Serial1/0

So the metric of E2 routes is equal to the metric given to it when the route was redistributed by the ASBR.

What about E1 routes?
Let's change the metric of to type E1 on R3:

R3(config-router)#redistribute connected subnets metric 30 metric-type 1

View the metric on R1:

R1#show ip route | inc
O E1 [110/158] via, 00:00:34, Serial1/0

It's now 158! How did R1 come up with this metric? By adding these values

metric of route as redistributed (contained in type 5 LSA)
metric of R2 (ABR) to reach R3 (ASBR) (contained in type 4 LSA)
metric of R1 to reach R2 (ABR) (contained in R2's type 1 LSA)

we can view these costs with the show ip ospf database command:

R1#show ip ospf database external | inc Metric
Metric Type: 1 (Comparable directly to link state metric)
Metric: 30

R1#show ip ospf database asbr-summary | inc Metric
TOS: 0 Metric: 64

R1#show ip ospf database router | section Link connected to: another Router
Link connected to: another Router (point-to-point)
(Link ID) Neighboring Router ID:
(Link Data) Router Interface address:
Number of TOS metrics: 0
TOS 0 Metrics: 64

Metric total = 64+64+30 = 158

In summary:
E2 route metric is equal to the metric upon redistribution
E1 route metrics add up original metric, metric to ASBR from ABR, metric to ABR.

1 comment:

  1. I’m impressed, Actually rarely do I encounter a blog that’s each looks like this but if a person can understand codes such as you post here. They will say that this is a great help and so do I. I am very happy that I stumbled throughout this in my search for something relating to this.


    My blog : brosse à dent électrique 


Note: Only a member of this blog may post a comment.