cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2108
Views
20
Helpful
11
Replies

OSPF Route Selection

faheemshaduli
Level 1
Level 1

Hi,

Greetings of the Day!

 

in OSPF if a router receives a route advertisement for same network with two different subnets which one will be chosen to install in the routing table. for an instance the router receives 10.0.0.0/16 and 10.0.0.0/30? kindly explain the selection process. 

 

Scenario 2

 

if the same router receives 10.0.0.0/30 through RIP in addition to the above ospf advertisements how the selection will happen?

 

this is not in a real time scenario. this doubt came in while studying the maximum prefix length match for route selection.

 

thanks. 

 

2 Accepted Solutions

Accepted Solutions

Martin L
VIP
VIP

 

process of selecting Best routes in the table is based on the longest prefix match; followed by lowest AD, then metrics

see https://www.cisco.com/c/en/us/support/docs/ip/enhanced-interior-gateway-routing-protocol-eigrp/8651-21.html?dtid=osscdc000283

 

 

Regards, ML
**Please Rate All Helpful Responses **

View solution in original post

Hello @faheemshaduli ,

what you see is correct , OSPF being a classless protocol is able to install both prefixes

>> 10.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
O 10.0.0.0/16 [110/2] via 192.168.0.1, 00:14:40, GigabitEthernet0/0
O 10.0.0.0/30 [110/2] via 172.17.10.2, 00:09:19, GigabitEthernet0/1

 

However, the longest prefix match is used first so for destination 10.0.0.1 or destination 10.0.0.2 R2 will use gi0/1 as exit interface for a packet with destination 10.10.20.5 it will send out gi0/0

 

This is because a classless routing protocol performs route exchange of subnets WITH their associated subent masks so 10.0.0.0/16 and 10.0.0.0/30 can both be installed in the IP routing table.

 

Georg's answer was focused on the concept of longest most specific prefix match first.

 

Hope to help

Giuseppe

 

View solution in original post

11 Replies 11

Martin L
VIP
VIP

 

process of selecting Best routes in the table is based on the longest prefix match; followed by lowest AD, then metric I think those steps would be the same for OSPF.

so, /30 is selected among  10.0.0.0/16 and 10.0.0.0/30

if you have both routes with exactly same prefix length, i.e. 10.0.0.0/30 via RIP and 10.0.0.0/30 via OSPF, OSPF wins because of AD 110 is lower then 120.

if OSPF  gets 2 routes for 10.0.0.0/30 from 2 different sources (neighbors), metric would determine the best way (exit). if both metrics are the same, OSPF does do equal load balance. 

 

 

Regards, ML
**Please Rate All Helpful Responses **

Hello,

 

basically, in scenario 1, OSPF will install the more specific route in the routing table. In scenario 2, the OSPF route will be installed, due to the fact that RIP has a higher (120) administrative distance than OSPF (110).

@Georg Pauwen Hi Georg,

 

thanks for the quick reply. 

i don't know if i am understanding it wrong but when I tested scenario 1 in GNS3 with three routers

R1->R2->R3

where R2 receives 10.0.0.0/16 from R1 and 10.0.0.0/30 from R3. the routing table of R2 has both the route installed. 

 

10.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
O 10.0.0.0/16 [110/2] via 192.168.0.1, 00:14:40, GigabitEthernet0/0
O 10.0.0.0/30 [110/2] via 172.17.10.2, 00:09:19, GigabitEthernet0/1

 

please help to get some clarity on this. 

 

Thanks. 

Hello @faheemshaduli ,

what you see is correct , OSPF being a classless protocol is able to install both prefixes

>> 10.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
O 10.0.0.0/16 [110/2] via 192.168.0.1, 00:14:40, GigabitEthernet0/0
O 10.0.0.0/30 [110/2] via 172.17.10.2, 00:09:19, GigabitEthernet0/1

 

However, the longest prefix match is used first so for destination 10.0.0.1 or destination 10.0.0.2 R2 will use gi0/1 as exit interface for a packet with destination 10.10.20.5 it will send out gi0/0

 

This is because a classless routing protocol performs route exchange of subnets WITH their associated subent masks so 10.0.0.0/16 and 10.0.0.0/30 can both be installed in the IP routing table.

 

Georg's answer was focused on the concept of longest most specific prefix match first.

 

Hope to help

Giuseppe

 

@Giuseppe Larosa thanks. much appreciated. 

Hi @Giuseppe Larosa,

thanks for the reply. to make it more clear on "longest prefix match" can you please advise which route will be chosen in the below routing table if a router has to destine a packet to ip address 172.16.32.1.

Eigrp - 172.16.32.0/27

OSPF - 172.16.32.0/19

RIP -  172.16.32.0/24

I believe the answer is EIGRP, but is it chosen based on the longest prefix or administrative distance?

 

Thanks Regards,

 

 

 

Hello @faheemshaduli ,

longest prefix match first so yes the answer is EIGRP prefix 172.16.32.0/27 regardless of AD value.

Just to make it clear an EIGRP external route D EX has AD 170 so even if prefix 172.16.32.0/27 was a D EX with D EX AD 170  it would still be chosen as exit path for destination 172.16.32.1.

An EIGRP internal route has AD 90.

However, longest prefix match first then AD then metric if applicable

 

Hope to help

Giuseppe

 

 

 

Martin L
VIP
VIP

 

process of selecting Best routes in the table is based on the longest prefix match; followed by lowest AD, then metrics

see https://www.cisco.com/c/en/us/support/docs/ip/enhanced-interior-gateway-routing-protocol-eigrp/8651-21.html?dtid=osscdc000283

 

 

Regards, ML
**Please Rate All Helpful Responses **

@Martin L Hi Martin,

 

thanks for the response. Actually My doubt is not about selecting the best route from the routeing table. it is about installing route into the table. 

Regards,

 


that doc has some info about installing routes into the table; it is integrated with protocol route selection.
but note that is old and does not mention CEF and recursion and valid next hop. I think you would have to read the CEF book.
Review Cisco Networking for a $25 gift card