The notes here apply to OpenBGPD as found in OpenBSD 4.0 and higher.
Path Selection Process
OpenBGPD will only ever install one route in the route table for a particular destination network (prefix). If OpenBGPD receives information about that prefix from more than one peer, a decision must be made on which one to use. The prefixes received will be evaluated against each other if the follow criteria matches:
- Prefix length is the same
- Both routes are for the same destination network
- The NEXT_HOP is reachable
OpenBGPD uses the following process to determine the “best” route:
- Local Preference. Higher local preference is preferred.
- AS_PATH length. Shorter AS_PATH is preferred.
- Origin code. Lower origin code is preferred. (IGP > EGP > Incomplete)
- Multi Exit Discriminator. Lowest MED is preferred. Note that MEDs are only compared if the two routes where announced to us from the same AS. (The MED can be used even if the peers are in different ASes using
rde med compare always)
- Prefer eBGP learned routes over iBGP learned routes.
- Weight. This is administratively set using the
weightkeyword in the bgpd config file. Note that by default, the weights are equal.
- Route age. The older route (i.e., the more stable route) is preferred. Note that this step is only performed when the
rde route-ageoption is set to
evaluate. By default it is set to
- BGP ID of the peer that announced the route to us. Lowest BGP ID is preferred.
- Lowest peer address. This is the final, tie-breaking rule. The BGP peer that has the lowest IP address wins.
If at any step in the process a route is found to be more preferred than the other, the process is aborted and that route is taken as the “best” route to the destination network.
UPDATE (Aug 2012): The bgpd path selection process is now documented in the bgpd(8) man page.
Next Hop Resolution
When looking for and validating next-hop addresses, OpenBGPD will only consider static routes and routes added by other dynamic routing protocols. BGP-learned routes and the default route are not considered. This behavior can be overridden using the
nexthop qualify via configuration option.
BGP Path Attributes
The following BGP path attributes can be controlled via bgpd.conf.
- Default value for routes received from iBGP peers is 100. Default value for routes recieved from eBGP peers is 0. LOCAL_PREF is never advertised to eBGP peers.
- MULTI_EXIT_DISC (MED)
- The MED is only advertised to an eBGP peer if it's being sourced from the local router. The MED is always advertised to iBGP peers (if it's present for a given prefix).
- Communities are advertised to all peers (iBGP and eBGP).
- By default the next-hop is set to whatever the peer advertises as the next-hop. The next-hop can be set to an alternate address or can be used to create null routes by using the
- Weight is a local attribute and is never redistributed to peers. It is used as tie-breaking criteria when comparing two equal routes.
Refer to the bgpd.conf(5) man page for details on how to manipulate the path attributes.