BGP Path Selection Cheatsheet

BGP uses different metrics to select which path to send data. This is how BGP chooses paths.

Attribute Description/Notes Winning Metric
Weight local to the router Highest
LOCAL_PREF Within the ASN, 100 by default Highest
Locally Originated Local paths that are sourced by the network or redistribute commands are preferred over local aggregates that are sourced by the aggregate-address command Local
AS_PATH An AS_SET counts as 1 Shortest
Origin Type IGP < EGP < INCOMPLETE Lowest (IGP)
MED multi-exit discriminator Lowest
External Prefer eBGP over iBGP paths eBGP
IGP metric lowest IGP metric to the BGP next hop Lowest
Oldest Path Choose oldest to prevent flapping Oldest
Router ID router ID is the highest IP address on the router (prefer loopbacks) Lowest

For more details on how BGP best paths are chosen, see