gurfin / ENCOR #8 - BGP Path selection

Created Mon, 03 Feb 2025 21:04:00 +0100 Modified Tue, 04 Feb 2025 21:13:54 +0000
217 Words

BGP Path selection

One of the most essential parts of BGP is its path selection algorithm. It dictates how BGP is to select which paths to promote to the RIB. Using the different Path attributes you can affect how routing of your prefixes is done within your network, in your peers network and even on the internet.

The path selection is done in a ascending order, where the first unequal attribute will be the determinator of which path is selected.

  1. Longest prefix
  2. Highest Weight (Cisco)
  3. Highest Local preference
  4. Local originated
  5. AIGP
  6. Shortest AS_Path
  7. Origin type
  8. Lowest MED
  9. External or internal BGP
  10. Lowest IGP nexthop
  11. If external, prefer oldest route
  12. Lowest RID
  13. Lowest cluster length
  14. Lowest neighbor address

Path attribute types

There are different types of path attributes which dictates if they are mandatory and also how they interact with other peers. The four types are: Well-known mandatory, Well-known discretionary, Optional transitive and Optional non-transitive.

Well-known attributes are always transitive, but optional attributes can be transitive. Here is a quote from the RFC:

The second high-order bit (bit 1) of the Attribute Flags octet is the Transitive bit. It defines whether an optional attribute is transitive (if set to 1) or non-transitive (if set to 0). For well-known attributes, the Transitive bit MUST be set to 1. https://www.rfc-editor.org/rfc/rfc4271