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 3.3.3.3 into area 3.
This route shows up with a cost of 20 on R1

R1#show ip route 3.3.3.3
Routing entry for 3.3.3.3/32
Known via "ospf 1", distance 110, metric 20, type extern 2, forward metric 128
Last update from 172.12.12.2 on Serial1/0, 00:02:54 ago
Routing Descriptor Blocks:
* 172.12.12.2, from 3.3.3.3, 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 3.3.3.3
O E2 3.3.3.3 [110/30] via 172.12.12.2, 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 3.3.3.3 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 3.3.3.3
O E1 3.3.3.3 [110/158] via 172.12.12.2, 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 3.3.3.3 | inc Metric
Metric Type: 1 (Comparable directly to link state metric)
Metric: 30

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


R1#show ip ospf database router 2.2.2.2 | section Link connected to: another Router
Link connected to: another Router (point-to-point)
(Link ID) Neighboring Router ID: 1.1.1.1
(Link Data) Router Interface address: 172.12.12.2
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.

    Jillian

    My blog : brosse à dent électrique 

    ReplyDelete

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