I set up below topology on Cisco IOU environment. R1, R2 and R3 routers are configured with one loopback interface on each, having "1.1.1.1", "2.2.2.2" and "3.3.3.3" addresses respectively. These loopbacks are advertised on OSPF as well as BGP processes.
All three routers have full-mesh iBGP connection to each other and R1 is the route-reflector. R3's BGP table has two "2.2.2.2/32" prefix, advertised by R1 and R2, and it chooses R2's advertisement as best.
Please see R3's BGP table for 2.2.2.2/32 prefix
BGP routing table entry for 2.2.2.2/32, version 2
Paths: (2 available, best #2, table default, RIB-failure(17))
Advertised to update-groups:
1
Local
2.2.2.2 (metric 11) from 1.1.1.1 (1.1.1.1)
Origin IGP, metric 0, localpref 100, valid, internal
Originator: 2.2.2.2, Cluster list: 1.1.1.1
Local
2.2.2.2 (metric 11) from 2.2.2.2 (2.2.2.2)
Origin IGP, metric 0, localpref 100, valid, internal, best
I am a little bit confused on which BGP Best Path Algorithm criteria decides to choose R2's advertisement is best for R3.
To understand this, I tried injecting a higher MED from R2 to R3. It changed the best to the one advertised by R1. This shows that the correct criteria (without MED manipulation) is somewhere below "6-MED/Metric".
Your comments would be appreciated
Please also find the BGP configurations for R1, R2 and R3
R1
router bgp 5500
bgp router-id 1.1.1.1
bgp log-neighbor-changes
network 1.1.1.1 mask 255.255.255.255
neighbor 2.2.2.2 remote-as 5500
neighbor 2.2.2.2 update-source Loopback0
neighbor 2.2.2.2 route-reflector-client
neighbor 3.3.3.3 remote-as 5500
neighbor 3.3.3.3 update-source Loopback0
R2
router bgp 5500
bgp router-id 2.2.2.2
bgp log-neighbor-changes
network 2.2.2.2 mask 255.255.255.255
neighbor 1.1.1.1 remote-as 5500
neighbor 1.1.1.1 update-source Loopback0
neighbor 1.1.1.1 next-hop-self
neighbor 3.3.3.3 remote-as 5500
neighbor 3.3.3.3 update-source Loopback0
neighbor 3.3.3.3 next-hop-self
neighbor 10.0.24.4 remote-as 777
neighbor 10.0.28.8 remote-as 811
R3
router bgp 5500
bgp router-id 3.3.3.3
bgp log-neighbor-changes
network 3.3.3.3 mask 255.255.255.255
neighbor 1.1.1.1 remote-as 5500
neighbor 1.1.1.1 update-source Loopback0
neighbor 1.1.1.1 next-hop-self
neighbor 2.2.2.2 remote-as 5500
neighbor 2.2.2.2 update-source Loopback0
neighbor 2.2.2.2 next-hop-self
neighbor 10.0.36.6 remote-as 777