cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
3566
Views
6
Helpful
49
Replies

OSPF - metric is even smaller when the device is more far away

jacky.cheuk
Level 1
Level 1

Hi everyone, 

The topology like below,

The switches and routers in the diagram all have OSPF connection.

R1,R2,R3,SW1 are in area0.

R4,R5,SW2 are in area4 

I got two WAN, WAN-A & WAN-B. When reaching destination 172.24.2.0/24, primary is using WAN-A. But when we used prefix-list to stop propagating 172.24.2.0/24 on R1,  reaching destination 172.24.2.0/24 will go through WAN-B.

   IMG_4153.JPEG

when using WAN-B, on R3, the metric/cost reaching 172.24.2.0/24 is 1001. 

#sh ip ro 172.24.2.0
Routing entry for 172.24.2.0/24
Known via "ospf 100", distance 110, metric 1001, type intra area
Last update from 192.168.39.182 on Tunnel1620, 1d03h ago
Routing Descriptor Blocks:
* 192.168.39.182, from 10.42.249.23, 1d03h ago, via Tunnel1620
Route metric is 1001, traffic share count is 1

However, on SW1, the metric/cost reaching 172.24.2.0/24 is 358. 

sh ip ro 172.24.2.0
Routing entry for 172.24.2.0/24
Known via "ospf 64", distance 110, metric 358, type inter area
Last update from 10.42.252.145 on TenGigabitEthernet1/2/1, 03:49:31 ago
Routing Descriptor Blocks:
* 10.42.252.145, from 192.168.13.4, 03:49:31 ago, via TenGigabitEthernet1/2/1
Route metric is 358, traffic share count is 1

How come the metric is even smaller when the device is more far away from 172.24.2.0/24? Isn't it the metric/cost of OSPF accumulate? 

================================================

Also, i got another question, when using "show ip ospf database summary 172.24.2.0" on R3, the Advertising Router is R2. Isn't it R3 a ABR already? it has one interface in area0 and one interface in area4. How come the Advertising Router is R2?

LS age: 1303
Options: (No TOS-capability, DC, Upward)
LS Type: Summary Links(Network)
Link State ID: 172.24.2.0 (summary Network Number)
Advertising Router: 192.168.12.4    ----->R2
LS Seq Number: 80000086
Checksum: 0xEB8E
Length: 28
Network Mask: /24
MTID: 0 Metric: 252

=========================================

Please help, i tried to find the answer but has no clue so far. 

49 Replies 49

.....

Never mind' I solve issue in my lab.

I will update  you soon 

I run lab try use copy your network, 
the IOU8 (SW1 in your network) have path to 30.0.0.0 via IOU6 
and the cost is correct as you can see 
NOW 
can you traceroute the 172.24.2.0/24 and check the path and check cost of each link in path

Screenshot (1002).png

so u had filtered on IOU5(R2) & IOU7(R1)? 

In my case, applying filter on R1 would lead to have next hop pointing to R3 and yet the metric is 358, which should be from R2. 

Applying filters on both R1 and R2 would lead to have next pointing to R3 and the metric is 1002.

I filter in IOU5(R2) this abr between area4 and area0 

And cost in show ip route and show ip ospf database is correct 

For you case did you do traceroute' did you check path via R3 how many hops appear' start from SW1 to destiantion calculate path (link cost)

If prefix is E1 or E2 then check defualt metric the asbr (router redistrubte this prefix)

I think you will get why path 1002

Applying filter in IOU5(R2) and getting the correct metric is correct, same situation in my environment. 

But pls try to apply filter in IOU7(R1) and see the metric on IOU8(SW1). 

My problem is when filter applied on R1 but not R2, the next hop of the best route to 172.24.2.0/24 is pointing to R3 but the metric is from 358 from R2. 

Metric with 1002 value on SW1 should be correct. 

as I mentioned before IOU7(R1) config with and without filter t have no effect, since IOU5(R2) is ABR not R1. 
check below

Screenshot (1012).pngScreenshot (1013).pngScreenshot (1014).png

I think I get issue here' 

Apply the filter in R1 and share traceroute let see if I am right.

MHM

the think which I check three days in lab to match the issue you have and I dont success is 
 172.24.2.0/24 is advertise by router, this router IP is filter BY huge number of prefix list you have. 
this make  172.24.2.0/24 is learn from R1 but to reach R1 you need to pass through tunnel via R3. 
I know it crazy idea but that the only think explain the high cost of path via R1/R2.
how you can check by traceroute I think is best way 
how we can solve it, check the summary and allow the advertise router IP via prefix list 

thanks 
MHM

Peter Paluch
Cisco Employee
Cisco Employee

@jacky.cheuk and everyone,

Please allow me to join. I have reviewed the entire thread and the contributions made by @MHM Cisco World and @David Ruess, but if I am reading it all correctly, we don't have a clear answer yet.

Jacky, I would like to try to reconstruct what's happening from your link-state databases. This will require several back-and-forth cycles between me and you as I don't want to dump the complete LSDB databases from all your routers for privacy reasons, and so I will go step by step.

Would you mind collecting the following complete and unabbreviated outputs for me for the start?

On R1, SW1, R2, R3 (from all of them, the same set of commands):

terminal length 0
show ip route 172.24.2.0 255.255.255.0
show ip ospf
show ip ospf neighbor
show ip ospf interface brief
show ip ospf border-routers
show ip ospf database summary 172.24.2.0
show ip ospf rib 172.24.0.0 255.255.255.0

Thank you!

Best regards,
Peter

Hi Peter, 

You can access the results in here --- https://drive.google.com/drive/folders/1NOI34vqvloNswwv8dncj-cKYwnEqPwh2?usp=sharing

jackycheuk_0-1690787892008.png

Thank you for being helpful. 

Hello @jacky.cheuk ,

Thank you for the outputs. We are getting somewhere!

sw01 is not directly connected to area 4 where the 172.24.2.0/24 network lives, so it computes the best path to it through an ABR in area 0 that provides the least total cost to that network - which consists of the cost to reach the ABR inside area 0, plus the distance of that ABR to reach 172.24.2.0/24 which is advertised in the LSA3 from the ABR. Looking at sw01, it prefers the path throught the ABR 192.168.13.4, and the next hop toward that ABR goes through r3:

sw01# show ip route 172.24.2.0 255.255.255.0
Routing entry for 172.24.2.0/24
Known via "ospf 64", distance 110, metric 358, type inter area
Last update from 10.42.252.145 on TenGigabitEthernet1/2/1, 00:01:57 ago
Routing Descriptor Blocks:
* 10.42.252.145, from 192.168.13.4, 00:01:57 ago, via TenGigabitEthernet1/2/1
Route metric is 358, traffic share count is 1

sw01# show ip ospf border-routers
i 192.168.13.4 [106] via 10.42.252.145, TenGigabitEthernet1/2/1, ABR/ASBR, Area 0, SPF 7357

sw01# show ip ospf database summary 172.24.2.0
Routing Bit Set on this LSA in topology Base with MTID 0
LS age: 118
Options: (No TOS-capability, DC, Upward)
LS Type: Summary Links(Network)
Link State ID: 172.24.2.0 (summary Network Number)
Advertising Router: 192.168.13.4
LS Seq Number: 80000001
Checksum: 0xEF0F
Length: 28
Network Mask: /24
MTID: 0 Metric: 252

Note that the distance from sw01 to the ABR 192.168.13.4 is 106, and the ABR's distance to the destination network is 252, and 106+252=358 - exactly the sw01's total cost.

So in order to reach 172.24.2.0/24, sw01 picks r3 as the next hop, so let's see what's happening on r3:

rt03# show ip route 172.24.2.0 255.255.255.0
Routing entry for 172.24.2.0/24
Known via "ospf 100", distance 110, metric 1001, type intra area
Last update from 192.168.39.182 on Tunnel1620, 4w5d ago
Routing Descriptor Blocks:
* 192.168.39.182, from 10.42.249.23, 4w5d ago, via Tunnel1620
Route metric is 1001, traffic share count is 1

rt03# show ip ospf border-routers
...
i 192.168.13.4 [105] via 192.168.2.2, Tunnel1601, ABR/ASBR, Area 0, SPF 5232
...

rt03# show ip ospf database summary 172.24.2.0

OSPF Router with ID (10.42.249.80) (Process ID 100)

Summary Net Link States (Area 0)

LS age: 235
Options: (No TOS-capability, DC, Upward)
LS Type: Summary Links(Network)
Link State ID: 172.24.2.0 (summary Network Number)
Advertising Router: 10.42.249.80
LS Seq Number: 800005A4
Checksum: 0x1250
Length: 28
Network Mask: /24
MTID: 0 Metric: 1001

LS age: 578
Options: (No TOS-capability, DC, Upward)
LS Type: Summary Links(Network)
Link State ID: 172.24.2.0 (summary Network Number)
Advertising Router: 192.168.13.4
LS Seq Number: 80000001
Checksum: 0xEF0F
Length: 28
Network Mask: /24
MTID: 0 Metric: 252
...

r3 is well aware of the existence of ABR 192.168.13.4 and its LSA3. But the gotcha is that r3 is also an ABR with area 4 whicih is the home area for 172.24.2.0/24, and as you know, in OSPF, intra-area paths are always preferred to inter-area paths, no matter the cost. Therefore, even if it was a cheaper path for r3 to use the path through 192.168.13.4, it must not - the OSPF rules do not allow that. It has to ignore the cheaper inter-area path and stick with the intra-area path which happens to be more costly.

You may ask how is it possible, then, that sw01 does not derive its cost from the real cost of r3.

The answer lies in the nature of link-state routing. sw01, not being a member of area 4, does not see its topology. sw01 can only see the topology of those areas it is a member of. About networks in other areas, all it knows is what ABRs advertise them into area 0, how far the ABRs are from those networks, and how far sw01 is from those ABRs.

So when sw01 runs the shortest-path-first algorithm on this knowledge, obviously, it sees that the ABR 192.168.13.4 provides the least combined cost to 172.24.2.0/24. The fact that r3 also advertises 172.24.2.0/24 in its own LSA3 does not matter much to sw01 - the combined cost is too high for sw01 to be interested. The best path is through the ABR 192.168.13.4, and so sw01 decides to use that path.

But the path always starts with the next hop, and the next from from sw01 toward the ABR 192.168.13.4 still happens to be r3. And now notice what happens: Because r3 is a member of area 4 where 172.24.2.0/24 is located, r3 does not route based on area 0's knowledge which is what sw01 did - it routes based on the area 4 knowledge, and that's where the paths start diverging, along with their cost.

At the bottom of this disparity is the fact that because of OSPF rules (prefer intra-area paths to inter-area paths), sw01 and r3 used different link-state databases to compute the best path. sw01 used the topology from area 0, r3 used the topology from area 4.

This phenomenon in OSPF may occur at any time where an inter-area path through an ABR traverses through another transit ABR, because that transit ABR will be forced by OSPF rules to

- prefer intra-area paths if the destination network lives in another area the transit ABR is connected to
- only use area 0 for inter-area traffic if the destination network lives in yet another area that the transit ABR is not connected to

I know this is quite mind-boggling and will require some time to digest. If this explanation does not quite cut it, we can pull additional outputs from your routers to demonstrate how exactly this happened.

Best regards,
Peter

 

 

I already run lab' from sw1 the path through R2 is prefer even if R2 is far than R3' 

Lsa3 cost from R2 is less than R3.

And also he ask add filter in R1 the metric is unpredictable.

Hi Peter, 

Thanks for your detailed explanation. My OSPF knowledge is not profound, still got one question to ask. 

Isn't it the Inter-area and Intra-area routing selection should be viewed from the point of SW1?

From the point of SW1, the route to 172.24.2.0/24 is Inter-area(IA) when the next-hop is R3. 

 sw01#sh ip ro 172.24.0.0
Routing entry for 172.24.0.0/24, 4 known subnets
O IA 172.24.2.0
[110/358] via 10.42.252.145, 00:07:19, TenGigabitEthernet1/2/1           (10.42.252.145 --> R3)

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

And it is also Intra-area for R2 to 172.24.2.0/24

rt02#show ip route 172.24.2.0 255.255.255.0
Routing entry for 172.24.2.0/24
Known via "ospf 1", distance 110, metric 252, type intra area
Last update from 192.168.33.26 on Tunnel56, 7w0d ago
Routing Descriptor Blocks:
* 192.168.33.26, from 10.42.249.23, 7w0d ago, via Tunnel56
Route metric is 252, traffic share count is 1

Hello Jacky,

Isn't it the Inter-area and Intra-area routing selection should be viewed from the point of SW1?

I apologize but I am not sure if I understand what is your doubt and what is it you are asking about. Let me try to answer more broadly, and if that does not remove your doubts, please try to ask again.

The OSPF best path computation process works in a few stages:

1) The router computes the best paths inside every area it is directly attached to
2) Then the router computes the best paths toward networks advertised from all other areas the router is not directly attached to. If, however, the same network is already known through the intra-area computation done in the previous step, it won't be replaced by this inter-area computation, even if it would result into a smaller cost.
3) Finally, the router computes the best paths toward external networks. Similarly, if the same network is already known through an intra-area (stage 1) or inter-area (stage 2) computation, it won't be replaced by this external network computation.

So try to think about what SW1 is capable of computing based on its knowledge: We know it is attached to area 0 and some other areas but not to area 4. Hence, it cannot discover the network 172.24.2.0/24 through the intra-area path computation stage. It first discovers it when performing the inter-area computation, and the least cost path toward it ultimately leads through the ABR 192.168.13.4; that is what the total cost is derived from. So SW1 makes an assumption that all routers within area 0 make the same computation, and sends the packets for 172.24.2.0/24 along the shortest path to the ABR 192.168.13.4. Once again, it cannot consider the destination 172.24.2.0/24 to be an intra-area destination because it is not in any area that SW1 is directly attached to.

One thing to also keep in mind: While OSPF knows the exact path inside an area on how to reach the ABR, the routing table can only hold the next hop, and every hop makes its own independent routing choice. That is the fundamental principle of basic IP routing - even if on the control plane, we know the complete path hop-by-hop, we cannot enforce it on the data plane; we can only send it to the immediate next hop and hope that the next hop will forward it the way we would, but we have no way at all to control that. The next hop has its own routing table and its own mind.

Now, the best path from SW1 to the ABR 192.168.13.4 passes through R3. R3 is in a different position than SW1 because R3 is directly attached to area 0 and to area 4. When R3 does its intra-area path computation in area 4, it will discover the network 172.24.2.0/24, and based on OSPF rules, it must prefer this intra-area path to any other that might appear available. Hence, unbeknownst to SW1, R3 has to follow intra-area routing inside area 4 for the destination 1724.24.2.0/24, not the inter-area routing through area 0 as SW1 did. That's why R3's own distance is different because it cannot consider the inter-area path through area 0 which is the one SW1 calculated, only the intra-area path through area 4.

And it is also Intra-area for R2 to 172.24.2.0/24

That is because R2 is directly attached to area 4 but SW1 is not.

Please feel welcome to ask further!

Best regards,
Peter

 

Review Cisco Networking for a $25 gift card