cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
10820
Views
10
Helpful
5
Replies

BGP/OSPF Redistribution - BGP Route Not Preferred

matthewaho
Level 1
Level 1

Diagram is attached.

Router A and Router B are separate customer sites.  Each location is running OSPF as their IGP and BGP as the protocol to peer with their upstream carrier device (Rtr C).  Rtr A and Rtr B also share a direct point-to-point connection between them and are OSPF neighbors. 

On both Rtr A and Rtr B OSPF and BGP are redistributed into each other to provide two paths to each subnet, 10.10.10.0/24 and 20.20.20.0 /24 respectively, either through the carrier connection or through the direct point-to-point connection.

I wish to have the carrier connection be the preferred route and the point-to-point connection between locations be the secondary or failover connection.  I've employed the BGP distance command on Rtr A and Rtr B so that all routes received from the upstream carrier device are given an Administrative Distance of 100 so that they take priority over the 110 AD of the internal OSPF.  This part works fine.

I am able to take down the connection between Rtr A and Rtr C and all traffic re-routes across the point-to-point connection as expected.  The OSPF route over the point-to-point connection is installed in the routing table as expected.  However, when I restore the connection between Rtr A and Rtr C the BGP route does not replace the OSPF route when it returns.  The OSPF route over the point-to-point connection remains unless I clear the OSPF process in which case the BGP route will take over.

Any ideas on why BGP would not take precedence over an already installed OSPF route in this case?  I've tried accounting for the METRIC and WEIGHT of the BGP routes as well with route-maps but this hasn't fixed the issue.

Configs are as below:

---Rtr A---

!

hostname Rtr-A

!

interface GigabitEthernet0/0

ip address 1.1.1.1 255.255.255.252

!

interface GigabitEthernet0/1

ip address 10.10.10.1 255.255.255.0

!

interface GigabitEthernet0/2

ip address 5.5.5.1 255.255.255.252

ip ospf cost 50000

!

router bgp 100

network 1.1.1.0 mask 255.255.255.252

redistribute connected

redistribute ospf 1 match internal external 1 external 2

neighbor 1.1.1.2 remote-as 300

neighbor 1.1.1.2 soft-reconfiguration inbound

distance 100 1.1.1.2 0.0.0.0

!

router ospf 1

redistribute bgp 100 metric 100

network 10.10.10.0 0.0.0.255 area 0

network 5.5.5.0 0.0.0.3 area 0

---Rtr B---

!

hostname Rtr-B

!

interface GigabitEthernet0/0

ip address 20.20.20.1 255.255.255.0

!

interface GigabitEthernet0/1

ip address 2.2.2.1 255.255.255.252

!

interface GigabitEthernet0/2

ip address 5.5.5.2 255.255.255.252

ip ospf cost 50000

!

router bgp 200

network 2.2.2.0 mask 255.255.255.252

redistribute connected

redistribute ospf 1 match internal external 1 external 2

neighbor 2.2.2.2 remote-as 300

neighbor 2.2.2.2 soft-reconfiguration inbound

distance 100 2.2.2.2 0.0.0.0

!

router ospf 1

redistribute bgp 200 metric 100

network 20.20.20.0 0.0.0.255 area 0

network 5.5.5.0 0.0.0.3 area 0

---Rtr C---

!

hostname Rtr-C

!

interface GigabitEthernet0/0

ip address 1.1.1.2 255.255.255.252

!

interface GigabitEthernet0/1

ip address 2.2.2.2 255.255.255.252

!

interface GigabitEthernet0/2

ip address 222.222.222.1 255.255.255.252

!

router bgp 300

network 1.1.1.0 mask 255.255.255.252

network 2.2.2.0 mask 255.255.255.252

neighbor 1.1.1.1 remote-as 100

neighbor 1.1.1.1 soft-reconfiguration inbound

neighbor 1.1.1.1 next-hop-self

neighbor 2.2.2.2 remote-as 200

neighbor 2.2.2.2 soft-reconfiguration inbound

neighbor 2.2.2.2 next-hop-self

!

ip route 0.0.0.0 0.0.0.0 222.222.222.2

1 Accepted Solution

Accepted Solutions

Jon Marshall
Hall of Fame
Hall of Fame

Normally the issue you are seeing is -

1) the BGP route received has an AD of 20 and the OPSF route has an AD of 110. So the BGP route is installed into the IP routing table.

An EBGP learned route has a BGP weight of 0

2) the EBGP link goes down. The OSPF route is now installed into the routing table and redistributed into BGP. So that route is now also in the BGP table.

A redistributed route is considered locally generated by BGP and so gets a weight of 32768

3) the EBGP link comes back up and so now the router has to two entries for the same network in it's BGP table. So using the best path selection BGP chooses the one with the higher weight and so sticks with the route learnt from OSPF.

The usual way around this is to simply modify the weight of all EBGP learnt routes to be higher than the locally generated route weight.

But you say you have tried this ?

Jon

View solution in original post

5 Replies 5

Jon Marshall
Hall of Fame
Hall of Fame

I've employed the BGP distance command on Rtr A and Rtr B so that all routes received from the upstream carrier device are given an Administrative Distance of 100 so that they take priority over the 110 AD of the internal OSPF.  This part works fine.

I'm not sure i follow this. EBGP routes have an AD of 20 so why do you need to modify the distance to 100. The EBGP routes should be preferred over the OSPF routes anyway ?

Perhaps you could clarify ?

What do the BGP table and the IP routing table look like when the backup link is being preferred ?

Jon

Jon Marshall
Hall of Fame
Hall of Fame

Normally the issue you are seeing is -

1) the BGP route received has an AD of 20 and the OPSF route has an AD of 110. So the BGP route is installed into the IP routing table.

An EBGP learned route has a BGP weight of 0

2) the EBGP link goes down. The OSPF route is now installed into the routing table and redistributed into BGP. So that route is now also in the BGP table.

A redistributed route is considered locally generated by BGP and so gets a weight of 32768

3) the EBGP link comes back up and so now the router has to two entries for the same network in it's BGP table. So using the best path selection BGP chooses the one with the higher weight and so sticks with the route learnt from OSPF.

The usual way around this is to simply modify the weight of all EBGP learnt routes to be higher than the locally generated route weight.

But you say you have tried this ?

Jon

Thanks for pointing that out, Jon.  You're correct.  I cobbled this diagram from a setup with a second router between the customer router and the upstream router which made it iBGP routes that I had to modify the AD on.  You're 100% correct.  In this case I shouldn't need to modify the AD for the BGP routes to be preferred over the OSPF routes.

Below is the IP and BGP tables as well as the OSPF RIB from Rtr A in three circumstances.

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

The primary MPLS connection is up originally:

Rtr-A#sh ip route

Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP

       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area

       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2

       E1 - OSPF external type 1, E2 - OSPF external type 2

       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2

       ia - IS-IS inter area, * - candidate default, U - per-user static route

       o - ODR, P - periodic downloaded static route, H - NHRP, l - LISP

       + - replicated route, % - next hop override

Gateway of last resort is not set

      1.0.0.0/8 is variably subnetted, 2 subnets, 2 masks

C        1.1.1.0/30 is directly connected, GigabitEthernet0/0

L        1.1.1.1/32 is directly connected, GigabitEthernet0/0

      2.0.0.0/30 is subnetted, 1 subnets

B        2.2.2.0 [100/0] via 1.1.1.2, 00:01:59

      5.0.0.0/8 is variably subnetted, 2 subnets, 2 masks

C        5.5.5.0/30 is directly connected, GigabitEthernet2/0

L        5.5.5.1/32 is directly connected, GigabitEthernet2/0

      10.0.0.0/8 is variably subnetted, 2 subnets, 2 masks

C        10.10.10.0/24 is directly connected, GigabitEthernet1/0

L        10.10.10.1/32 is directly connected, GigabitEthernet1/0

      20.0.0.0/24 is subnetted, 1 subnets

B        20.20.20.0 [100/0] via 1.1.1.2, 00:01:00

Rtr-A#sh ip bgp                                       

BGP table version is 23, local router ID is 10.10.10.1

Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,

              r RIB-failure, S Stale, m multipath, b backup-path, x best-external, f RT-Filter

Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path

*  1.1.1.0/30       1.1.1.2                  0             0 300 i

*>                      0.0.0.0                  0         32768 i

*> 2.2.2.0/30       1.1.1.2                  0             0 300 i

*  5.5.5.0/30       1.1.1.2                                0 300 200 ?

*>                      0.0.0.0                  0         32768 ?

*> 10.10.10.0/24    0.0.0.0                  0         32768 ?

*> 20.20.20.0/24    1.1.1.2                                0 300 200 ?

Rtr-A#sh ip ospf rib

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

                Base Topology (MTID 0)

OSPF local RIB

Codes: * - Best, > - Installed in global RIB

*   5.5.5.0/30, Intra, cost 50000, area 0, Connected

      via 5.5.5.1, GigabitEthernet2/0

*   10.10.10.0/24, Intra, cost 1, area 0, Connected

      via 10.10.10.1, GigabitEthernet1/0

*   20.20.20.0/24, Intra, cost 50001, area 0

      via 5.5.5.2, GigabitEthernet2/0

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

The MPLS connection is down (failover):

Rtr-A#sh ip route

Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP

       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area

       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2

       E1 - OSPF external type 1, E2 - OSPF external type 2

       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2

       ia - IS-IS inter area, * - candidate default, U - per-user static route

       o - ODR, P - periodic downloaded static route, H - NHRP, l - LISP

       + - replicated route, % - next hop override

Gateway of last resort is not set

      1.0.0.0/8 is variably subnetted, 2 subnets, 2 masks

C        1.1.1.0/30 is directly connected, GigabitEthernet0/0

L        1.1.1.1/32 is directly connected, GigabitEthernet0/0

      5.0.0.0/8 is variably subnetted, 2 subnets, 2 masks

C        5.5.5.0/30 is directly connected, GigabitEthernet2/0

L        5.5.5.1/32 is directly connected, GigabitEthernet2/0

      10.0.0.0/8 is variably subnetted, 2 subnets, 2 masks

C        10.10.10.0/24 is directly connected, GigabitEthernet1/0

L        10.10.10.1/32 is directly connected, GigabitEthernet1/0

      20.0.0.0/24 is subnetted, 1 subnets

O        20.20.20.0 [110/50001] via 5.5.5.2, 00:00:07, GigabitEthernet2/0

Rtr-A#sh ip bgp

BGP table version is 1, local router ID is 10.10.10.1

Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,

              r RIB-failure, S Stale, m multipath, b backup-path, x best-external, f RT-Filter

Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path

*  20.20.20.0/24    5.5.5.2              50001         32768 ?

Rtr-A#sh ip ospf rib

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

                Base Topology (MTID 0)

OSPF local RIB

Codes: * - Best, > - Installed in global RIB

*   5.5.5.0/30, Intra, cost 50000, area 0, Connected

      via 5.5.5.1, GigabitEthernet2/0

*   10.10.10.0/24, Intra, cost 1, area 0, Connected

      via 10.10.10.1, GigabitEthernet1/0

*>  20.20.20.0/24, Intra, cost 50001, area 0

      via 5.5.5.2, GigabitEthernet2/0

Rtr-A#

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

The MPLS connection is restored (should move back to MPLS, but remains on failover):

Rtr-A#sh ip route

Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP

       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area

       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2

       E1 - OSPF external type 1, E2 - OSPF external type 2

       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2

       ia - IS-IS inter area, * - candidate default, U - per-user static route

       o - ODR, P - periodic downloaded static route, H - NHRP, l - LISP

       + - replicated route, % - next hop override

Gateway of last resort is not set

      1.0.0.0/8 is variably subnetted, 2 subnets, 2 masks

C        1.1.1.0/30 is directly connected, GigabitEthernet0/0

L        1.1.1.1/32 is directly connected, GigabitEthernet0/0

      5.0.0.0/8 is variably subnetted, 2 subnets, 2 masks

C        5.5.5.0/30 is directly connected, GigabitEthernet2/0

L        5.5.5.1/32 is directly connected, GigabitEthernet2/0

      10.0.0.0/8 is variably subnetted, 2 subnets, 2 masks

C        10.10.10.0/24 is directly connected, GigabitEthernet1/0

L        10.10.10.1/32 is directly connected, GigabitEthernet1/0

      20.0.0.0/24 is subnetted, 1 subnets

O        20.20.20.0 [110/50001] via 5.5.5.2, 00:01:10, GigabitEthernet2/0

   Network          Next Hop            Metric LocPrf Weight Path

*  1.1.1.0/30       1.1.1.2                  0             0 300 i

*                        0.0.0.0                  0         32768 i

*  2.2.2.0/30       1.1.1.2                  0             0 300 i

*  5.5.5.0/30       1.1.1.2                                0 300 200 ?

*                        0.0.0.0                  0         32768 ?

*  10.10.10.0/24    1.1.1.2                                0 300 200 ?

*                          0.0.0.0                  0         32768 ?

*  20.20.20.0/24    1.1.1.2                                0 300 200 ?

*                           5.5.5.2              50001         32768 ?

Leaving my above post in place just so folks can see a snapshot of the various parts of the routing if necessary.  Jon, you're right!  I swear I tried modifying the WEIGHT for relevant networks with a route-map before and experienced the same behavior.  However, I just tried it again and it's failing back as expected now.  The BGP table shows only the MPLS route now and the OSPF route is visible in the OSPF RIB but is not used.

Thanks for the assistance in helping me walk through this!  No idea what I was doing before to mess it up, but it appears to be correct now.

------

ROUTE MAP CONFIG FROM RTR A

ip access-list standard WEIGHT

permit 20.20.20.0 0.0.0.255

permit 1.1.1.0 0.0.0.3

permit 2.2.2.0 0.0.0.3

!

!

!

!

!

route-map WEIGHT permit 10

match ip address WEIGHT

set weight 35000

!

route-map WEIGHT permit 20

router bgp 100

bgp log-neighbor-changes

network 1.1.1.0 mask 255.255.255.252

redistribute connected

redistribute ospf 1 match internal external 1 external 2

neighbor 1.1.1.2 remote-as 300

neighbor 1.1.1.2 next-hop-self

neighbor 1.1.1.2 soft-reconfiguration inbound

neighbor 1.1.1.2 route-map WEIGHT in

distance 100 1.1.1.2 0.0.0.0

------

Rtr-A#sh ip route

Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP

       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area

       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2

       E1 - OSPF external type 1, E2 - OSPF external type 2

       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2

       ia - IS-IS inter area, * - candidate default, U - per-user static route

       o - ODR, P - periodic downloaded static route, H - NHRP, l - LISP

       + - replicated route, % - next hop override

Gateway of last resort is not set

      1.0.0.0/8 is variably subnetted, 2 subnets, 2 masks

C        1.1.1.0/30 is directly connected, GigabitEthernet0/0

L        1.1.1.1/32 is directly connected, GigabitEthernet0/0

      2.0.0.0/30 is subnetted, 1 subnets

B        2.2.2.0 [100/0] via 1.1.1.2, 00:01:06

      5.0.0.0/8 is variably subnetted, 2 subnets, 2 masks

C        5.5.5.0/30 is directly connected, GigabitEthernet2/0

L        5.5.5.1/32 is directly connected, GigabitEthernet2/0

      10.0.0.0/8 is variably subnetted, 2 subnets, 2 masks

C        10.10.10.0/24 is directly connected, GigabitEthernet1/0

L        10.10.10.1/32 is directly connected, GigabitEthernet1/0

      20.0.0.0/24 is subnetted, 1 subnets

B        20.20.20.0 [100/0] via 1.1.1.2, 00:01:06

Rtr-A#sh ip bgp

BGP table version is 23, local router ID is 10.10.10.1

Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,

              r RIB-failure, S Stale, m multipath, b backup-path, x best-external, f RT-Filter

Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path

r> 1.1.1.0/30       1.1.1.2                  0         35000 300 i

r                   0.0.0.0                  0         32768 i

*> 2.2.2.0/30       1.1.1.2                  0         35000 300 i

*  5.5.5.0/30       1.1.1.2                                0 300 200 ?

*>                  0.0.0.0                  0         32768 ?

*  10.10.10.0/24    1.1.1.2                                0 300 200 ?

*>                  0.0.0.0                  0         32768 ?

*> 20.20.20.0/24    1.1.1.2                            35000 300 200 ?

Rtr-A#sh ip ospf rib

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

                Base Topology (MTID 0)

OSPF local RIB

Codes: * - Best, > - Installed in global RIB

*   5.5.5.0/30, Intra, cost 1, area 0, Connected

      via 5.5.5.1, GigabitEthernet2/0

*   10.10.10.0/24, Intra, cost 1, area 0, Connected

      via 10.10.10.1, GigabitEthernet1/0

*   20.20.20.0/24, Intra, cost 2, area 0

      via 5.5.5.2, GigabitEthernet2/0

No problem, glad to have helped.

Jon

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: