Cost-Community (iBGP)
Last updated
Last updated
Topology: ine-spv4
Load bgp.cost-community.ibgp.init.cfg
Using IGP cost-community, influence R1 and R2 to prefer the route to XR2’s loopbacks via R4.
The cost-community is an extcommunity, which has two POIs (points of insertion). The cost community can be inserted as “pre-bestpath” in which it is evaluated before any other BGP bestpath step, including weight. Cost-community can also have a “IGP” POI, in which it is evaluated after the IGP nexthop metric for the route. This allows cost-community to essentially be a tie-breaker, as it is evaluated before the lowest RID step in the bestpath selection process.
In this lab, before we make any changes, R1 is preferring to reach XR2’s prefixes using R3 due to the lowest RID. The IGP metric to both next hops is identical.
Next, we configure R4 to set the cost-community with IGP POI outbound to iBGP peers. It also must send extcommunities to its iBGP peers. It is important to note that cost-community is not transitive. It cannot be sent to an eBGP peer. The only exception to this is when you translate AIGP into cost-community. In that one case, you can send the cost-community to an eBGP peer.
When setting cost-community you have two POI options: IGP or pre-bestpath. When none is specified, igp is assumed.
Next, you configure a community ID. The lowest community ID is preferred among routes with the same POI but different community IDs. For example, if we configure R3 to use community ID 23 but a higher value, R1 will still pick R3 as bestpath, due to the lower community ID. (The cost is only compared when the community ID is the same).
If we instead change the community ID to be the same value, only then are the final cost values compared, and R4 wins again.
It is important to note that when one path has a cost-community value, any other paths that don’t have a cost-community value will implicitly have the default value of (2^32)/2. This is the midpoint of the max possible value. A handy way to obtain this value is to solicit context-sensitive help on the route-map on IOS-XE.
To prove this, we can remove the cost-community from R3 and set R4 to a value above this number. R1 should now prefer R3 instead of R4, even though R3 is not sending any cost-community at all.
Also note that the default POI when none is specifed on IOS-XE is IGP.
We can also use the “bgp bestpath cost-community ignore” command if desired. Using this on R1 will make R1 skip this step and proceed on to the lowest RID.