A router receives prefix announcements via eBGP. Your network can either be multi-homed or peer and receive announcements for the same prefix from multiple sources. From these multiple sources, the router selects one announcement as best. The selected best prefix announcement is used for routing.
The following criteria helps in the selection of the best prefix announcement:
- Each prefix needs (wants) only one single path
- Based on the attributes of the BGP announcement
- Always the same decision, with the same parameters, making it deterministic
With the help of below example of BGP routing algorithm according to RFC4271, you can understand how your network chooses the prefix:
- Your router will check if next hop is reachable
- Your router chooses the route with the highest local preference
- Your router prefers the route with shortest AS path
- Your router prefers the route with the lowest origin attribute
- Your router prefers the route with the lowest MED Value
- Your router prefers the routes received from eBGP
- Your router prefers the routes learned from the router with lower router ID
- Your router prefers the routes learned from the router with lower IP address
- In terms of your internal routing protocol, your router prefers the nearest exit from the network
- Dependent on implementation : prefers more stable,(= older) routes
*Important rules are in bold while implementations are more vendor-specific
After checking if the BGP announcement is valid, the router selects the best path. The paths with reachable next hop are only considered, the not reachable next hop is announced as discarded.
The DE-CIX Academy Knowledgecard on BGP Routing is below, you can also download it here.