Checked on lab, I think that the asumption is ok.
1. Configured BGP without redistributing statics, but with a a backup route. All worked ok, after the main link came up, the router deleted the backup route to 10.20.2.1 and used again the BGP one.
*Mar 1 00:25:45.871: BGP(0): 192.168.1.5 update run completed, afi 0, ran for 40ms, neighbor version 0, start version 28,8*Mar 1 00:25:45.875: BGP(0): 192.168.1.5 initial update completed
*Mar 1 00:25:45.939: BGP(0): 192.168.1.5 rcvd UPDATE w/ attr: nexthop 192.168.1.5, origin ?, path 65000 1
*Mar 1 00:25:45.943: BGP!
router bgp 2
no synchronization
bgp log-neighbor-changes
redistribute connected
redistribute static route-map NEEDED_STATICS
neighbor 192.168.1.5 remote-as 65000
no auto-summary
!
(0): 192.168.1.5 rcvd 10.20.1.0/24
*Mar 1 00:25:45.947: BGP(0): 192.168.1.5 rcvd 10.20.2.0/24
*Mar 1 00:25:45.955: BGP(0): 192.168.1.5 rcvd 10.20.3.0/24
*Mar 1 00:25:45.959: BGP(0): 192.168.1.5 rcvd 192.168.1.0/30
*Mar 1 00:25:45.967: BGP(0): 192.168.1.5 rcvd 192.168.1.8/30
*Mar 1 00:25:45.983: BGP(0): Revise route installing 1 of 1 route for 10.20.1.0/24 -> 192.168.1.5 to main IP table
*Mar 1 00:25:45.987: BGP(0): Revise route installing 1 of 1 route for 10.20.2.0/24 -> 192.168.1.5 to main IP table
*Mar 1 00:25:45.995: BGP(0): Revise route installing 1 of 1 route for 10.20.3.0/24 -> 192.168.1.5 to main IP table
*Mar 1 00:25:46.003: BGP(0): Revise route installing 1 of 1 route for 192.168.1.0/30 -> 192.168.1.5 to main IP table
2. Configured also a redistribute static command, therefore after a failure and recovery of the main link, the router is redistributing the backup route to its peer 192.168.1.5 and also learning that router from the same peer. And... NO GETTING IT INSIDE THE ROUTING TABLE![/color red]
*Mar 1 00:27:43.543: BGP(0): 192.168.1.5 rcvd UPDATE w/ attr: nexthop 192.168.1.5, origin ?, path 65000 1
*Mar 1 00:27:43.547: BGP(0): 192.168.1.5 rcvd 10.20.1.0/24
*Mar 1 00:27:43.555: BGP(0): 192.168.1.5 rcvd 10.20.2.0/24
*Mar 1 00:27:43.559: BGP(0): 192.168.1.5 rcvd 10.20.3.0/24
*Mar 1 00:27:43.567: BGP(0): 192.168.1.5 rcvd 192.168.1.0/30
*Mar 1 00:27:43.575: BGP(0): 192.168.1.5 rcvd 192.168.1.8/30
*Mar 1 00:27:43.587: BGP(0): Revise route installing 1 of 1 route for 10.20.1.0/24 -> 192.168.1.5 to main IP table
*Mar 1 00:27:43.595: BGP(0): Revise route installing 1 of 1 route for 10.20.3.0/24 -> 192.168.1.5 to main IP table
*Mar 1 00:27:43.603: BGP(0): Revise route installing 1 of 1 route for 192.168.1.0/30 -> 192.168.1.5 to main IP table
At the IP routing table:
10.0.0.0/24 is subnetted, 6 subnets
C 10.1.3.0 is directly connected, Loopback3
C 10.1.2.0 is directly connected, Loopback1
C 10.1.1.0 is directly connected, Loopback0
S 10.20.2.0 [250/0] via 192.168.1.10
B 10.20.3.0 [20/0] via 192.168.1.5, 00:07:09
B 10.20.1.0 [20/0] via 192.168.1.5, 00:07:09
192.168.1.0/30 is subnetted, 3 subnets
C 192.168.1.8 is directly connected, Serial0
B 192.168.1.0 [20/0] via 192.168.1.5, 00:07:09
C 192.168.1.4 is directly connected, Serial1
At the BGP table the situation is as follows:
RA#sh ip bgp
BGP table version is 42, local router ID is 10.1.3.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*> 10.1.1.0/24 0.0.0.0 0 32768 ?
*> 10.1.2.0/24 0.0.0.0 0 32768 ?
*> 10.1.3.0/24 0.0.0.0 0 32768 ?
*> 10.20.1.0/24 192.168.1.5 0 65000 1 ?
* 10.20.2.0/24 192.168.1.5 0 65000 1 ?
*> 192.168.1.10 0 32768 ?
*> 10.20.3.0/24 192.168.1.5 0 65000 1 ?
*> 192.168.1.0/30 192.168.1.5 0 65000 1 ?
*> 192.168.1.4/30 0.0.0.0 0 32768 ?
* 192.168.1.8/30 192.168.1.5 0 65000 1 ?
*> 0.0.0.0 0 32768 ?
Conclusion:
As we can see at the bgp table for RA, once the backup router has been used and, after the failure, the main link has been recovered, the bgp table has two paths for the studied router 10.20.2.0. One via its BGP neighbour (ASPATH 65000 1 ) and another generated by itself because of the redistribute static:
* 10.20.2.0/24 192.168.1.5 0 65000 1 ?
*> 192.168.1.10 0 32768 ?
Also, the prefered or elected one is the one generated by itself with a nexhop equal to the next hop of the static route.
Explanation:
Following the logic of bgp election process, the router preffers to elect a route with the highest weight. As the redistribute route has a default weight of 32768 it is prefered over the one learned by its peer.
Solution:
As stated above, the solution passes for tunning the redistribution of the static over BGP. Is really needed redistribute those statics? If so, filter that redistribution with a route map, i.e:
a) Tag the backup static routes with some tag (this example I am using 40, looks line NO).
ip route 10.20.2.0 255.255.255.0 192.168.1.10 250 tag 40[/color blue]
Take care don't forget the AD (250). It happened to me I was getting mad about what where was the failure!
b) Create a route a route map that blocks the redistribution of the statics that have been taged with the 40 tag.Redistribute the statics over bgp with a route map. In this case I have called it NEEDED_STATICS.
!
route-map NEEDED_STATICS deny 10
match tag 40
!
route-map NEEDED_STATICS permit 20
!
[/color blue]
c) Redistribute the statics over bgp with that route map.
!
router bgp 2
no synchronization
bgp log-neighbor-changes
redistribute connected
redistribute static route-map NEEDED_STATICS
neighbor 192.168.1.5 remote-as 65000
no auto-summary
!
[/color blue]
pepe123, I think it will fix your problem
jneiberger, thanks for pointing this issue to the correct path!
Regards.
Samuel Bonete.