If BGP has multiple potential routes to a destination, how does it choose which one to install in the RIB? I'm glad you asked!
Don't panic - at the CCNP level, you'll only need to know up to step 4.
-
Next Hop Accessibility
Like IGPs, a route will never be installed in the route table if the next-hop router is inaccessible.
Unlike IGPs, this might not be obvious because the next-hop BGP router might not be directly connected.
Next-hop accessibility is the "zeroth" step - depending on who you ask.
-
Weight
Weight stays local to the router where you configure it. Higher is better; the default is 0.
-
Local Preference (
LOCAL_PREF)Local preference is used to choose between multiple exit points from one AS to another AS. It can be used to control the active/standby configuration when redundant connections are provisioned to a single upstream AS.
Higher is better; the default is 100.
-
Prefer locally-originated paths
Paths can be locally originated via a
networkcommand, redistribution from an IGP or thedefault-originate/aggregate-addresscommands. -
AS_PATHLengthThe number of AS "hops" to the destination. This is usually the tie-breaker between multiple BGP routes. Shorter
AS_PATHis better. -
Prefer lowest origin type (
i<e<?)The origin code is how the route got into the BGP domain.
i= IGP. Statically configured with thenetworkcommand.e= EGP. The EGP protocol. Father of BGP, no longer around.'?` = INCOMPLETE. Redistributed into BGP.
-
Prefer lowest multi-exit discriminator (
MED) (aka.METRIC)Like
LOCAL_PREF,MEDis only used if the first-hop AS is the same in the two paths. By modifying themetric, you can influence upstream routers and have them tweak their path downstream to you.Lower is better (like other metrics); default is 0.
LOCAL_PREFis often set on routes on your side of the link (i.e. to influence outbound traffic), andMEDis set on routes that are advertised to the remote neighbour (to influence inbound traffic when your AS has multiple connections to one other AS.)If you are dual-homing to multiple autonomous systems, you can make one path look artificially longer by prepending your own AS multiple times to the
AS_PATH. -
Prefer eBGP over iBGP
-
Prefer path with lowest IGP metric to BGP next-hop
-
Determine if BGP Multipath is required
BGP Multipath allows you to install multiple paths in the route table to the same destination. Multipath is out of the scope of this document.
-
Prefer the first received path (oldest)
This effectively chooses the more stable route when the others are flapping.
-
Prefer lowest router ID
Router ID is either manually set with
bgp router-idor is the highest IP address (loopbacks get preference.) -
Prefer minimum cluster list length
Used in BGP route reflection. Out of scope.
-
Lowest neighbor IP address
When all else fails, this is guaranteed to be unique! Hopefully.