BGP path selection process
The BGP process may receive advertisements from multiple peers for the same network prefix. Each of these announcements from a peer for a prefix is called a path. The BGP process selects the “best” path from all available paths and this path becomes the candidate route announced by BGP for inclusion in the Routing Information Base (RIB).
Depending on what other protocols also have candidate routes for this network prefix, the BGP route may or may not be added to the RIB. For instance if the RIB has candidate routes from both BGP and static routing for the same prefix, the static route, not the BGP route, be included in the RIB. This is because the static route process has a lower administrative cost than the BGP process.
It is important to note that BGP does not consider paths that contain a NEXT_HOP value that is not reachable via an entry in the RIB. For all valid paths, the Vyatta router uses a BGP path selection process based on decision process described in RFC 4271, section 9.1 and RFC 5004. BGP paths are preferred based on the following:
- LOCAL PREFERENCE: Prefer the path with the highest LOCAL_PREF.
- AS PATH LENGTH: Prefer the path with the shortest AS_PATH.
- ORIGIN: Prefer the path with the lowest ORIGIN type.
- MULTI_EXIT_DISC: Prefer the path with the lowest MED.
- PEER TYPE: Prefer the paths learned via eBGP over paths learned via iBGP.
- IGP METRIC. Prefer the paths with lower IGP metric for the path's NEXT_HOP address.
- BGP ID: Prefer the path with the lowest BGP ID.
- PEER IP: Prefer the path with the lowest peer IP address.
The best path selection process is performed as “first match and out.” This means that two paths be compared until the first difference in preference criteria. For example, two paths for the same network prefix may have the same LOCAL_PREF value, but different AS path lengths. In this case, the path with the shortest AS path would be the “best” path. If the peer IP address is being used to select the best path, this means that all other path criteria were the same for the available paths.
You can use show ip bgp to see the current best paths in the RIB.