Skip to content

Instantly share code, notes, and snippets.

@stmps
Last active January 27, 2017 05:22
Show Gist options
  • Select an option

  • Save stmps/5784f1a583fd6e333690 to your computer and use it in GitHub Desktop.

Select an option

Save stmps/5784f1a583fd6e333690 to your computer and use it in GitHub Desktop.
BGP Path Selection Metrics

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.

  1. 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.

  1. Weight

    Weight stays local to the router where you configure it. Higher is better; the default is 0.

  2. 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.

  3. Prefer locally-originated paths

    Paths can be locally originated via a network command, redistribution from an IGP or the default-originate / aggregate-address commands.

  4. AS_PATH Length

    The number of AS "hops" to the destination. This is usually the tie-breaker between multiple BGP routes. Shorter AS_PATH is better.

  5. Prefer lowest origin type ( i < e < ? )

    The origin code is how the route got into the BGP domain.

    i = IGP. Statically configured with the network command.

    e = EGP. The EGP protocol. Father of BGP, no longer around.

    '?` = INCOMPLETE. Redistributed into BGP.

  6. Prefer lowest multi-exit discriminator (MED) (aka. METRIC)

    Like LOCAL_PREF, MED is only used if the first-hop AS is the same in the two paths. By modifying the metric, you can influence upstream routers and have them tweak their path downstream to you.

    Lower is better (like other metrics); default is 0.

    LOCAL_PREF is often set on routes on your side of the link (i.e. to influence outbound traffic), and MED is 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.

  7. Prefer eBGP over iBGP

  8. Prefer path with lowest IGP metric to BGP next-hop

  9. 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.

  10. Prefer the first received path (oldest)

    This effectively chooses the more stable route when the others are flapping.

  11. Prefer lowest router ID

    Router ID is either manually set with bgp router-id or is the highest IP address (loopbacks get preference.)

  12. Prefer minimum cluster list length

    Used in BGP route reflection. Out of scope.

  13. Lowest neighbor IP address

    When all else fails, this is guaranteed to be unique! Hopefully.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment