In the image below there are 7 routers all running BGP.
The routers are running the following ASNs:
- R1 and R4 – ASN 200
- R2, R3, R5 – ASN 100
- R8 and R10 – ASN 810.1.
R10 is advertising three Loopback networks into BGP and we’re seeing how BGP will by default choose R1’s path to R10. On R1 there are two different paths to R10s loopback IP 172.16.10.0/24.
In the bottom right the router shows the path through R2 (126.96.36.199) is the ‘best’ – ie. best path. This can be seen in the routing table:
Going down the list for path selection, the weight is set to 0 on both and the local preference are both default 100.
AS Path length and origin can be seen in the image above as well – 100, 810.1, both the same.
The routes are so evenly matched that BGP will go down to the tie breakers, ie.
- EBGP over iBGP
- IGP Metric to Next Hop
- Lowest RID
- Shortest cluster list
- Lowest Neighbor address
In this case BGP is selecting the neighbor going through R2 because it’s been exchanging routes for longer than R3.
To influence traffic outbound in BGP, we’ll need to send an advertisement inbound to R1. This will be accomplished typically with weight or local pref.
To modify by weight (Cisco proprietary) the first part of configuration will be a prefix-list and route map that can be applied inbound.
Next, the route-map needs to get applied inbound associated with the neighbor we want as more preferred – ie. R3 at 10.20.1.1.
The ‘clear ip bgp *’ refreshes inbound advertisements to the router. After the refresh, now we can see the route preference has changed to R3.
Weight can be seen as 12345.
Next is a Local Preference example. In the image below we have the same ASN list, but now we’re looking at R4 and R2. R4 is advertising it’s loopback subnet 188.8.131.52/24 over into ASN 100, and we want to change how traffic from R2 chooses it’s path to R4.
R2 currently has two routes to reach 184.108.40.206/24, one through it’s iBGP neighbor at R3, and one through R1 via EBGP.
R2 will install this route into it’s routing table via its eBGP neighbor because the administrative distance is shorter and EBGP will be preferred over iBGP. To modify the local preference inbound to prefer R3, we’ll need to create a prefix list, then route-map, saying change the local preference via R3. Local preference is AS specific/spread, not just locally significant.
R3 is receiving this route from R1, so the route-map needs to be applied under that neighbor inbound via router bgp <asn>. R3 and R1 are connected over the transit 10.20.1.0/30.
Now in R2 we can see that the best path is through R3 because the local pref is higher. This same local pref can be seen within the Autonomous System.
Once the advertisement leaves the local AS, Local pref is set back to the default 100.