Cisco Support Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Announcements
Webcast-Catalyst9k
New Member

Basic questions on preferred routes (BGP vs. OSPF)

Hey, imagine that I have in my routing table routes to a same destination:

a) iBGP (via a network /24) and OSPF destination via a /27 network address;

Given the administrative distance that for iBGP is 200, is the OSPF (adm distance=110) the preferred one in this case?

1 ACCEPTED SOLUTION

Accepted Solutions
Hall of Fame Super Bronze

Re: Basic questions on preferred routes (BGP vs. OSPF)

Longest prefix will dictate the preferred route, not the administrative distance.

Based on your example, if you were to send:

192.168.1.0/27 via OSPF

and

192.168.1.0/24 via BGP

You will prefer to reach hosts from 192.168.1.1-31 via OSPF and 192.168.1.32-254 via BGP.

HTH,

__

Edison.

6 REPLIES
Hall of Fame Super Gold

Re: Basic questions on preferred routes (BGP vs. OSPF)

Marlon

Your question is not clear to me. When you talk about a /24 for IBGP and a /27 for OSPF are these the masks for the networks you go through to get to the destination (in which case the mask of the network you go through does not have any impact on which route is preferred) or are these the masks of the prefix in the routing table (in which case you have two different prefixes and not two routes to the same prefix). Can you clarify this?

If it is two routes to the same prefix then OSPF is preferred over IBGP.

HTH

Rick

Hall of Fame Super Bronze

Re: Basic questions on preferred routes (BGP vs. OSPF)

Longest prefix will dictate the preferred route, not the administrative distance.

Based on your example, if you were to send:

192.168.1.0/27 via OSPF

and

192.168.1.0/24 via BGP

You will prefer to reach hosts from 192.168.1.1-31 via OSPF and 192.168.1.32-254 via BGP.

HTH,

__

Edison.

Hall of Fame Super Silver

Re: Basic questions on preferred routes (BGP vs. OSPF)

Hello Marlon,

the most specific route is used regardless of AD and metric.

So in your case if destination address is within the /27 the OSPF route is used.

If the destination address is out of the /27 but within the /24 the BGP route is used.

AD is considered by the IP routing mantainer when two different protocols offer a path to the same prefix.

In this case the lower AD route is installed.

In your case being the two subnets with different prefix length both are installed in the routing table and the most specific is used as explained above.

Hope to help

Giuseppe

New Member

Re: Basic questions on preferred routes (BGP vs. OSPF)

Hey thanks!

That explains what I see here, the prefix could win the decision over the AD itself!

Cisco Employee

Re: Basic questions on preferred routes (BGP vs. OSPF)

Marton,

If you allow me just a precision. It is not that the prefix length wins over the AD but rather that AD only comes into play if two prefixes with the same prefix length are learned from two different sources.

Regards

Harold Ritter
Sr. Technical Leader
CCIE 4168 (R&S, SP)
harold@cisco.com
México móvil: +52 1 55 8312 4915
Cisco México
Paseo de la Reforma 222
Piso 19
Cuauhtémoc, Juárez
Ciudad de México, 06600
México
Blue

Re: Basic questions on preferred routes (BGP vs. OSPF)

Marlon:

At the risk of being accused of beating a dead horse, let me say that the issue boils down to comparable routes.

Within a routing protocol, two comparable routes that are received will have their metrics compared. The better metric will be selected as the primary path.

When comparing two comparable routes learned from two different routing protocols, such as BGP and OSPF, the routing protocol with the lower AD will win.

Notice that in both cases the keyword to focus on is "comparable." That means they have to have the same prefix length. A /24 route and a /27 are not comparable, so no comparisons are drawn with regard to metrics or AD. Why? Because the more specific route - the one with the longer prefix -- is the better route, period. There is no comparison.

HTH

Victor

1355
Views
5
Helpful
6
Replies
CreatePlease to create content