Jon Spindler here.
I wanted to post my BGP Path Selection notes from my CCIE R&S preparation that i found very helpful.
BGP Path Selection is a HUGE piece of the CCIE R&S Lab Exam, so i found it to be worth while to create some guides for myself in PLAIN ENGLISH.
Here it is:
Before path selection occurs, the router will perform some basic validity checks such as:
Is the next hop of the route reachable?
Is our local AS in the AS Path?
If the next hop is reachable and our AS is NOT in the AS Path attribute of the route, we move forward with the path selection process.
Weight - This is something you attach to incoming routes from neighbors to prefer one exit point over another. If there are multiple exit points in an AS advertising the same prefix, the one with the highest weight value will be preferred. This is only significant within the local AS. It COULD POTENTIALLY influence other iBGP peers in the AS in the case that it is manipulated on the Route Reflector, but NOT because the weight is carried in advertisements. Route Reflector Clients will prefer the path selection of the RR. Here is an example of this corner case:
Local Preference - This is only important to local AS to make decisions on how to EXIT towards a given destination. Setting the LOCAL Preference to be HIGHER on a certain router for a specific prefix will give local AS routers info that this is the preferred way to go towards that destination. The default is 100. This does not get passed outside of AS and therefor is NON-TRANSITIVE.
Locally Originated - These are routes that were originated via Network Statement, Aggregate-Address, or Redistribution.
AS Path - This is basically BGPs Hop Count. beginning with a prefix's origination, every AS that it is passed through (mostly) gets the AS number appended to the route with the exception of BGP Confederation SUB-AS whose function is completely transparent to external AS. When a router sees multiple advertisements for the same prefix with equal weight, and local preference values, it will look at the AS path lists on each of the routes and pick the one with the LEAST amount of ASs in the list.
Origin - If the AS path length is a tie, the outer will choose the route with the lowest Origin Type in the following order:
1. IGP routes
2. EGP Routes
3. Incomplete (?)
MED - If the routes are the same Origin Type, the route with the lowest MED value is chosen. The MED is the Multi-Exit Discriminator and often called the metric because in Cisco BGP, the MED is assigned based on the IGP metric for locally originated routes. MED is used to signal External AS peers which way they should enter into your AS to reach a specific prefix given they are connected to you via multiple entry points. MED can be assigned per neighbor, per prefix, & even match on things like the destination AS which might be different than the local AS. The remote AS will compare the otherwise equal prefixes and choose the path with the lowest MED value. It is not advertised past the neighboring AS.
E over I - If the Prefixes tie on MED as well, the BGP process will prefer a route that is from an External BGP peer over a route from an Internal BGP peer. The logic behind this is that if you are learning a route via eBGP, this route most likely does not belong to your AS and this means you should not route through another iBGP peer to get there. This is an attempt to break the tie in the BGP selection process for a given prefix. AD will only come in to play when the router is comparing between the BGP Best Path & other routing protocols before installing the route in the RIB.
Metric to Next Hop - If both prefixes are being learned from the same type of BGP peer, next the router will examine the IGP metric to the Next-Hop Attribute of the route and choose the lower IGP metric to this destination address.
Router ID - If the IGP metric to the Next-Hop value of the BGP prefix is the same for both routes, the one learned from the lowest BGP router-ID will be selected. The BGP router-id should be unique within the local AS and therefor should break the tie.
Lowest Neighbor IP - If the tie is STILL NOT BROKEN, for instance in the case that even the Router ID is the same, the preferred path will be the Lowest IP address of the neighbor. Since this is going to be unique, this should end it for good LOL.