Wednesday, December 30, 2009

Best Path Selection from different OSPF Process ID


When two OSPF processes are configured on a router and if same prefix is received on both OSPF process, it will be treated as like received from two different routing protocol and metric/LSA type will be ignored. Selection will be purely based on administrative distance. If the administrative distance is same, Router appears to select the best path based on lowest process ID.


The below topology has been configured to run OSPF process 1 and 100 on both R1 and R2.






The above statement has been tested by two test cases,


Test Case 1 :

Loopback 2 on R2 is redistributed into process 123 and configured with “network 22.22.22.0 0.0.0.255 area 0 “ into process 1.


R2#show run | sec ospf

router ospf 1

router-id 150.1.2.2

log-adjacency-changes

network 22.22.22.2 0.0.0.0 area 0

network 150.1.12.2 0.0.0.0 area 0

router ospf 123

router-id 2.2.2.2

log-adjacency-changes

redistribute connected subnets route-map CONN2OSPF

network 150.1.21.2 0.0.0.0 area 0

R2#

R2#route-map CONN2OSPF permit 10

match interface Loopback2

R2#


On R1, it can be confirmed that 22.22.22.0/24 is received as Type 1 LSA (router) via process 1 and Type 5 LSA (external) via process 123,


R1#show ip ospf database router 150.1.2.2 | inc Process|22.22

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

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

(Link ID) Network/subnet number: 22.22.22.2

R1#show ip ospf database external 22.22.22.0

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

Type-5 AS External Link States

Routing Bit Set on this LSA

LS age: 1788

Options: (No TOS-capability, DC)

LS Type: AS External Link

Link State ID: 22.22.22.0 (External Network Number )

Advertising Router: 2.2.2.2

LS Seq Number: 80000001

Checksum: 0x90C5

Length: 36

Network Mask: /24

Metric Type: 2 (Larger than any link state path)

TOS: 0

Metric: 20

Forward Address: 0.0.0.0

External Route Tag: 0

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

R1#


On R1, it is observed that route from process ID of numerically less number is preferred. In our case, Type 1 LSA from OSPF process 1 is selected and installed in routing table.


Clearing the routing table or clearing OSPF process doesn’t make any difference.


R1#show ip route 22.22.22.0

Routing entry for 22.22.22.0/24

Known via "ospf 1", distance 110, metric 11, type intra area

Last update from 150.1.12.2 on Ethernet0/0.12, 00:00:17 ago

Routing Descriptor Blocks:

* 150.1.12.2, from 150.1.2.2, 00:00:17 ago, via Ethernet0/0.12

Route metric is 11, traffic share count is 1

R1#

R1#clear ip route *

R1#clear ip ospf process

Reset ALL OSPF processes? [no]: yes

R1#show ip route 22.22.22.0

% Network not in table

R1#show ip route 22.22.22.0

Routing entry for 22.22.22.0/24

Known via "ospf 1", distance 110, metric 11, type intra area

Last update from 150.1.12.2 on Ethernet0/0.12, 00:00:03 ago

Routing Descriptor Blocks:

* 150.1.12.2, from 150.1.2.2, 00:00:03 ago, via Ethernet0/0.12

Route metric is 11, traffic share count is 1

R1#


Test Case 2:

Loopback 2 on R2 is redistributed into process 1 and configured with “network 22.22.22.0 0.0.0.255 area 0 “ into process 123.


R2#show run | sec ospf

router ospf 1

router-id 150.1.2.2

log-adjacency-changes

redistribute connected subnets route-map CONN2OSPF

network 150.1.12.2 0.0.0.0 area 0

router ospf 123

router-id 2.2.2.2

log-adjacency-changes

network 22.22.22.2 0.0.0.0 area 0

network 150.1.21.2 0.0.0.0 area 0

R2#


On R1, it can now be observed that 22.22.22.0/24 is received as Type 1 LSA (router) via OSPF process 123 and Type 5 LSA (external) via OSPF process 1 as below,


R1#show ip ospf database router | inc Process|22.22.

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

(Link ID) Network/subnet number: 22.22.22.0

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

OSPF Router with ID (10.1.14.1) (Process ID 45)

R1#

R1#show ip ospf database external 22.22.22.0

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

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

Type-5 AS External Link States

Routing Bit Set on this LSA

LS age: 117

Options: (No TOS-capability, DC)

LS Type: AS External Link

Link State ID: 22.22.22.0 (External Network Number )

Advertising Router: 150.1.2.2

LS Seq Number: 80000001

Checksum: 0x5F63

Length: 36

Network Mask: /24

Metric Type: 2 (Larger than any link state path)

TOS: 0

Metric: 20

Forward Address: 0.0.0.0

External Route Tag: 0

OSPF Router with ID (10.1.14.1) (Process ID 45)

R1#


On R1, it is observed that route from process ID of numerically less number is preferred. In our case, Type 5 LSA from OSPF process 1 is selected and installed in routing table.


Clearing the routing table or clearing OSPF process doesn’t make any difference.


R1#show ip route 22.22.22.0

Routing entry for 22.22.22.0/24

Known via "ospf 1", distance 110, metric 20, type extern 2, forward metric 10

Last update from 150.1.12.2 on Ethernet0/0.12, 00:03:17 ago

Routing Descriptor Blocks:

* 150.1.12.2, from 150.1.2.2, 00:03:17 ago, via Ethernet0/0.12

Route metric is 20, traffic share count is 1

R1#

R1#clear ip route *

R1#clear ip ospf pro

Reset ALL OSPF processes? [no]: yes

R1#

R1#show ip route 22.22.22.0

% Network not in table

R1#show ip route 22.22.22.0

% Network not in table

R1#show ip route 22.22.22.0

Routing entry for 22.22.22.0/24

Known via "ospf 1", distance 110, metric 20, type extern 2, forward metric 10

Last update from 150.1.12.2 on Ethernet0/0.12, 00:00:00 ago

Routing Descriptor Blocks:

* 150.1.12.2, from 150.1.2.2, 00:00:00 ago, via Ethernet0/0.12

Route metric is 20, traffic share count is 1

R1#


Testcase 3:

Now let us try test case 2 setup, but allow route received from Process ID 123 to be installed in routing table and then advertise same prefix via OSPF process 1.


I have shut the interface connected & Configured for OSPF Process 1 and receive route 22.22.22.0/24 only from Process 123.


R1#conf t

Enter configuration commands, one per line. End with CNTL/Z.

R1(config)#int e0/0.12

R1(config-subif)#shut

R1(config-subif)#

R1(config-subif)#do sh ip ospf data router | in Proce|22.22.22.

OSPF Router with ID (150.1.1.1) (Process ID 123)

(Link ID) Network/subnet number: 22.22.22.0

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

OSPF Router with ID (10.1.14.1) (Process ID 45)

R1(config-subif)#do sh ip ospf data external 22.22.22.0

OSPF Router with ID (150.1.1.1) (Process ID 123)

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

OSPF Router with ID (10.1.14.1) (Process ID 45)

R1(config-subif)#do show ip route 22.22.22.2

Routing entry for 22.22.22.0/24

Known via "ospf 123", distance 110, metric 2, type intra area

Last update from 150.1.21.2 on Ethernet0/0.21, 00:02:55 ago

Routing Descriptor Blocks:

* 150.1.21.2, from 2.2.2.2, 00:02:55 ago, via Ethernet0/0.21

Route metric is 2, traffic share count is 1

R1(config-subif)#


Now, I will un shut the interface and receive route 22.22.22.0/24 from Process 1.


R1(config)#int e0/0.12

R1(config-subif)#no shut

R1(config-subif)#do sh ip ospf data router | inc Proce|22.22.22.

OSPF Router with ID (150.1.1.1) (Process ID 123)

(Link ID) Network/subnet number: 22.22.22.0

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

OSPF Router with ID (10.1.14.1) (Process ID 45)

R1(config-subif)#do sh ip ospf database external 22.22.22.0

OSPF Router with ID (150.1.1.1) (Process ID 123)

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

Type-5 AS External Link States

Routing Bit Set on this LSA

LS age: 510

Options: (No TOS-capability, DC)

LS Type: AS External Link

Link State ID: 22.22.22.0 (External Network Number )

Advertising Router: 150.1.2.2

LS Seq Number: 80000013

Checksum: 0x3B75

Length: 36

Network Mask: /24

Metric Type: 2 (Larger than any link state path)

TOS: 0

Metric: 20

Forward Address: 0.0.0.0

External Route Tag: 0

OSPF Router with ID (10.1.14.1) (Process ID 45)

R1(config-subif)#


It still can be observed that OSPF route from Process 123 is not preempted by route from Process 1.


When routing table is cleared, route from Process 1 will be installed.


R1#show ip route 22.22.22.2

Routing entry for 22.22.22.0/24

Known via "ospf 123", distance 110, metric 2, type intra area

Last update from 150.1.21.2 on Ethernet0/0.21, 00:07:18 ago

Routing Descriptor Blocks:

* 150.1.21.2, from 2.2.2.2, 00:07:18 ago, via Ethernet0/0.21

Route metric is 2, traffic share count is 1

R1#clear ip route *

R1#show ip route 22.22.22.2

Routing entry for 22.22.22.0/24

Known via "ospf 1", distance 110, metric 20, type extern 2, forward metric 10

Last update from 150.1.12.2 on Ethernet0/0.12, 00:00:01 ago

Routing Descriptor Blocks:

* 150.1.12.2, from 150.1.2.2, 00:00:01 ago, via Ethernet0/0.12

Route metric is 20, traffic share count is 1

R1#


Tried with modifying the router-id and it still it appears to select the route based on lowest process ID.


Conclusion:

The above testing appears that when a router running 2 OSPF processes receives same prefix from different process, it will ignore metric/LSA Type and will only check the Administrative Distance (AD). If both are same, it will install based on lowest process ID.


In case, we receive the prefix via highest process ID and already installed in routing table, it will not be preempted by the lowest process ID until you clear the routing table.


Note: This is not any Official statement and documented based on my testing and understanding.














6 comments:

  1. Thank you! Very usefull information. I did a lab and couldn't understand why router selected route with higher metric, I supposed that it was a bug. Now it's clear for me!

    ReplyDelete
  2. thanks loads! this fact is not documented properly anywhere.

    ReplyDelete
  3. thank you! good thinking!

    ReplyDelete
  4. Hi, Can we check this again, I think it's not lowest process id. It's based on which process id is enter first. For example ospf process id 2 and than all network command. After this enter router ospf process 1 than network statement. You will see route will be coming via process 2.

    ReplyDelete
    Replies
    1. Hi,

      Are you referring to the local prefixes installation into OSPF database?. Or the prefix learnt from different processes?. My testing was on prefixes lernt from different processes. But I think the local prefixes will be installed as you mentioned.

      -Nagendra

      Delete
  5. It is bases on what route is installed in the rib first, not the process id, as you clearly stated when you clear the process 1 and the route from 123 is installed, it is not preempted when you turn on process 1

    ReplyDelete