This is a subject that is key to the core of BGP and is something that needs to understood from the start. It is essential to everything that you will study and work with later on. When working with BGP, there are attributes to every path that is advertised and distributed. When a router receives these advertisements, it takes all paths for a specific subnet from every peer device and evaluates them against each other. There is then a specific algorithm that is used in a top-down fashion for BGP best path selection. As the process goes through this algorithm, it compares paths until a clear “winner”, or best path is found.
- Path with the highest weight is preferred.
- Local Preference
- Prefer the path with the highest local preference.
- Locally Generated
- Prefer routes that are advertised via network or redistribute commands versus an aggregate-address command
- AS Path
- Prefer the path with the shortest AS-Path.
- Lowest Origin Type
- IGP preferred over EGP, EGP preferred over INCOMPLETE
- MED (multi-exit discriminator)
- Prefer the path with the lowest MED value.
- ‘e’ versus ‘i’
- Prefer eBGP over iBGP
In a lot of cases this is where things will stop. Commonly, some guides will even stop at this point. I want to make mention though that there ARE some additional criteria in the algorithm. For these criteria and a description, you can view the Cisco page LOCATED HERE.
This is something that you will want to memorize. You probably won’t even need to spend much trying to do so either. After the reading and labbing that comes with studying, you will remember the BGP best path selection algorithm in no time at all. If needed, just keep the list handy and you’ll understand which BGP path was selected and why.