Cisco Support Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Announcements

Welcome to Cisco Support Community. We would love to have your feedback.

For an introduction to the new site, click here. If you'd prefer to explore, try our test area to get started. And see here for current known issues.

New Member

Route Selection when BGP redistributed into OSPF

I have two routers R1 and R2 each connected to a different MPLS-VPN cloud. R1 is running eBGP to the PE router and OSPF to a Core router in the LAN. R2 is also running eBGP to the PE router but it is also running iBGP to another router R3. R3 is connected to the Core LAN router and is running OSPF. When I redistribute the BGP into the OSPF process on R1 and R3, the routes that get inserted into the routing table on the Core Lan router are always those from R1 (running eBGP).

I need to prefer the routes from R3 in the LAN Core. How can I do this?

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Route Selection when BGP redistributed into OSPF

The problem you are running into is due to Admin distance factor. On R3, the IBGP learnt route has an admin distance of 200 whereas the OSPF route's admin distance is only 110 and hence, it's preferred over the IBGP route. This results in R3 not redistributing the IBGP route into OSPF at all.

Try configuring the distance as follows on R3:

router bgp 23146

distance bgp 20 109 109

I haven't used the distance BGP command myself before but I think this should work. Issue the commands, clear ip bgp * soft & clear ip route * and check the status again on your LAN core router. There might be a very brief disruption when the clear ip route * command is issued.

HTH

Sundar

7 REPLIES
Cisco Employee

Re: Route Selection when BGP redistributed into OSPF

Are you certain the routes from R3 are even redistributed into OSPF. By default iBGP routes will not be redistributed into OSPF. You need to use the "bgp redistribute-internal" knob to allow iBGP routes to be redistributed into any IGP.

Also, once that is done, you can set the metric-type to 1 as you redistribute on R3 and set it to 2 on R1. This way routes from R3 will always be preferred over the same routes from R1.

Hope this helps,

Hope this helps,

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
New Member

Re: Route Selection when BGP redistributed into OSPF

Thanks for the reply.

I am using the "bgp redistribute-internal" command on R3. I've also added the metric-type setting on both routers, but the LAN core still prefers the route through R1. (*note: the configuration on R1 does not reflect the metric-type 2 configuration. Default metric-type = 2)

Here's the updated config...

**R3***

router ospf 1

log-adjacency-changes

redistribute connected

redistribute bgp 64609 metric-type 1 subnets

passive-interface GigabitEthernet0/1

network 10.2.203.96 0.0.0.31 area 2

network 10.2.203.128 0.0.0.31 area 2

!

router bgp 64609

no synchronization

bgp log-neighbor-changes

bgp redistribute-internal

redistribute ospf 1

neighbor 10.2.203.114 remote-as 64609

neighbor 10.2.203.114 soft-reconfiguration inbound

no auto-summary

**R1**

router ospf 1

log-adjacency-changes

auto-cost reference-bandwidth 4294967

redistribute bgp 65009 subnets route-map OSPF-REDISTRIBUTE-BGP

network 10.2.1.16 0.0.0.15 area 2

network 10.2.1.128 0.0.0.15 area 2

network 10.2.203.128 0.0.0.31 area 2

network 10.2.255.254 0.0.0.0 area 2

!

router bgp 65009

no synchronization

bgp log-neighbor-changes

bgp redistribute-internal

network 10.2.1.16 mask 255.255.255.240

network 10.2.1.128 mask 255.255.255.240

network 10.2.255.254 mask 255.255.255.255

redistribute ospf 1

neighbor 12.113.143.241 remote-as 7018

neighbor 12.113.143.241 soft-reconfiguration inbound

neighbor 12.113.143.241 prefix-list LOCAL-TO-BGP out

no auto-summary

!

ip access-list standard BGP-OSPF-IN

permit 10.7.252.1

permit 10.7.250.0 0.0.0.255

permit 10.7.251.0 0.0.0.255

!

route-map OSPF-REDISTRIBUTE-BGP permit 10

match ip address BGP-OSPF-IN

!

**LAN Core**

LAN-CORE>sho ip route 10.7.252.1

Routing entry for 10.7.252.1/32

Known via "ospf 2", distance 110, metric 1

Tag 7018, type extern 2, forward metric 1

Last update from 10.2.1.130 on GigabitEthernet13/47, 00:02:56 ago

Routing Descriptor Blocks:

* 10.2.1.130, from 10.2.255.254, 00:02:56 ago, via GigabitEthernet13/47

Route metric is 1, traffic share count is 1

Re: Route Selection when BGP redistributed into OSPF

Can you post the output of 'show ip ospf database external 10.7.252.1' from the core router.

Cisco Employee

Re: Route Selection when BGP redistributed into OSPF

I see what the issue is now. It is most probably a timing issue.

Let me explain. You are doing mutual redistribution. On R3, the routes learnt via OSPF are redistributed into BGP before BGP can redistribute them into OSPF, which would explain why LAN-CORE doesn't see the route being advertised by R3 via OSPF. You should use filtering as you redistribut from OSPF to BGP.

To verify this, issue a "sh ip bgp 10.7.252.1" on R3 and you should see this route as being locally originated (bgp next-hop = 0.0.0.0).

Hope this helps,

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
New Member

Re: Route Selection when BGP redistributed into OSPF

This is output from the LAN Core router. Notice that there is only 1 OSPF DB entry and it is comming from R1.

LAN-CORE>#sho ip ospf data ext 10.7.252.1

OSPF Router with ID (216.115.178.2) (Process ID 2)

Type-5 AS External Link States

Routing Bit Set on this LSA

LS age: 981

Options: (No TOS-capability, DC)

LS Type: AS External Link

Link State ID: 10.7.252.1 (External Network Number )

Advertising Router: 10.2.255.254

LS Seq Number: 8000002B

Checksum: 0xF8F0

Length: 36

Network Mask: /32

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

TOS: 0

Metric: 1

Forward Address: 0.0.0.0

External Route Tag: 7018

Here is the "sh ip bgp 10.7.252.1 from R3. It is indicating the correct "next-hop" address, but a rib-failure. The "sh ip ospf data ext 10.7.252.1" displays the route being learned from R1.

R3>#sho ip bgp 10.7.252.1

BGP routing table entry for 10.7.252.1/32, version 3565

Paths: (1 available, best #1, table Default-IP-Routing-Table, RIB-failure(17))

Not advertised to any peer

13979 64603, (received & used)

10.2.203.114 from 10.2.203.114 (172.24.39.9)

Origin IGP, localpref 100, valid, internal, best

R3>#sho ip ospf data ext 10.7.252.1

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

Type-5 AS External Link States

Routing Bit Set on this LSA

LS age: 167

Options: (No TOS-capability, DC)

LS Type: AS External Link

Link State ID: 10.7.252.1 (External Network Number )

Advertising Router: 10.2.255.254

LS Seq Number: 80000031

Checksum: 0xECF6

Length: 36

Network Mask: /32

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

TOS: 0

Metric: 1

Forward Address: 0.0.0.0

External Route Tag: 7018

Is this what you'd expect to see in this scenario? I will be filtering out the OSPF redistribution into BGP on R3 such that only the local LAN segments (those that are originated from LAN Core) are redistributed.

Re: Route Selection when BGP redistributed into OSPF

The problem you are running into is due to Admin distance factor. On R3, the IBGP learnt route has an admin distance of 200 whereas the OSPF route's admin distance is only 110 and hence, it's preferred over the IBGP route. This results in R3 not redistributing the IBGP route into OSPF at all.

Try configuring the distance as follows on R3:

router bgp 23146

distance bgp 20 109 109

I haven't used the distance BGP command myself before but I think this should work. Issue the commands, clear ip bgp * soft & clear ip route * and check the status again on your LAN core router. There might be a very brief disruption when the clear ip route * command is issued.

HTH

Sundar

New Member

Re: Route Selection when BGP redistributed into OSPF

Thanks to all who responded to this post.

The fix to this issue was a combination of setting the metric-type to 1 on R3 and also changing the AD for BGP internal and local routes on R3 to be less than that of ospf

Resulting configuration on R3 (obvious commands omitted):

router ospf 1

redistribute bgp 64609 metric-type 1 subnets

!

router bgp 64609

bgp redistribute-internal

redistribute ospf 1

distance bgp 20 109 109

The resulting routes on the LAN Core:

LAN-CORE># sho ip route 10.7.252.1

Routing entry for 10.7.252.1/32

Known via "ospf 2", distance 110, metric 2

Tag 13979, type extern 1

Last update from 10.2.203.133 on Vlan308, 00:00:18 ago

Routing Descriptor Blocks:

* 10.2.203.133, from 10.2.203.133, 00:00:18 ago, via Vlan308

Route metric is 2, traffic share count is 1

LAN-Core>#sho ip route 10.7.252.1

Routing entry for 10.7.252.1/32

Known via "ospf 2", distance 110, metric 2

Tag 13979, type extern 1

Last update from 10.2.203.133 on Vlan308, 00:06:56 ago

Routing Descriptor Blocks:

* 10.2.203.133, from 10.2.203.133, 00:06:56 ago, via Vlan308

Route metric is 2, traffic share count is 1

LAN-Core>#sho ip ospf data ext 10.7.252.1

OSPF Router with ID (216.115.178.2) (Process ID 2)

Type-5 AS External Link States

Routing Bit Set on this LSA

LS age: 551

Options: (No TOS-capability, DC)

LS Type: AS External Link

Link State ID: 10.7.252.1 (External Network Number )

Advertising Router: 10.2.203.133

LS Seq Number: 80000003

Checksum: 0x4EA5

Length: 36

Network Mask: /32

Metric Type: 1 (Comparable directly to link state metric)

TOS: 0

Metric: 1

Forward Address: 0.0.0.0

External Route Tag: 13979

LS age: 628

Options: (No TOS-capability, DC)

LS Type: AS External Link

Link State ID: 10.7.252.1 (External Network Number )

Advertising Router: 10.2.255.254

LS Seq Number: 80000034

Checksum: 0xE6F9

Length: 36

Network Mask: /32

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

TOS: 0

Metric: 1

Forward Address: 0.0.0.0

External Route Tag: 7018

LAN-Core>#sho ip route 10.7.252.1

Routing entry for 10.7.252.1/32

Known via "ospf 2", distance 110, metric 2

Tag 13979, type extern 1

Last update from 10.2.203.133 on Vlan308, 00:09:29 ago

Routing Descriptor Blocks:

* 10.2.203.133, from 10.2.203.133, 00:09:29 ago, via Vlan308

Route metric is 2, traffic share count is 1

418
Views
4
Helpful
7
Replies