Overview

It is very common in BGP to receive multiple route information for a specific network address. When multiple BGP routes are received for the same network address, the best path (optimal route) is determined and registered in the routing table. In addition, only the best-path route information is advertised to other neighbors.

In what order the path attributes of the BGP routes are evaluated to determine the best path is illustrated in detail.

Best path selection with BGP and IGP

In principle, only one optimal route (best path) is registered in the routing table, even if there are multiple routes to a particular network. This is true for both IGPs such as OSPF and BGP.

In an IGP such as OSPF, the selection of the best path is based on a metric. There are many different ways to calculate the metric, but in the end it is a single number. The route information with the smallest metric is the best path.

In BGP, on the other hand, the best path is selected based on path attributes, and there is more than one path attribute added to BGP route information. The flexibility in determining the best path based on various path attributes is a major feature of BGP.

Figure Determining the best path in IGP and BGP
Figure Determining the best path in IGP and BGP

Equal-cost load balancing or unequal-cost load balancing also allows multiple routes destined to a network to be registered in the routing table.

BGP Best Path Selection Process

assumption

Before determining the best path, the assumption is that the received BGP route information must be valid. The following conditions must be satisfied before a received BGP route can be used

  • The IP address of the NEXT_HOP attribute must be reachable.
  • When synchronization is enabled, the conditions for synchronization must be satisfied.

In the current Cisco IOS, BGP synchronization is disabled by default. In addition, it is unlikely that you will ever configure BGP in such a way that synchronization must be enabled, so you do not need to be aware of any particular conditions regarding synchronization.Please make sure that the first condition, the IP address of the NEXT_HOP attribute, is reachable.

It is also assumed that it is not considered a loop by AS_PATH. However, if it is considered a loop by AS_PATH, it will not be stored in the BGP table because it discards the BGP route in the first place.

BGP Best Path Selection Process

When multiple BGP routes for the same network address are received, the best path is determined by evaluating the path attributes attached to the routes in the following order

Some of the following processes include determining the best path independent of path attributes. Once the best path is determined for a process, no further processes are examined.

  1. Prefer BGP route with the highest WEIGHT
  2. Prefer BGP route with the highest LOCAL_PREF
  3. Prefer locally generated BGP route
  4. Prefer BGP route with shortest AS_PATH
  5. Prefer BGP route with the smallest ORIGIN
  6. Prefer BGP route with the smallest MED
  7. Prefer EBGP route over IBGP route
  8. Prefer BGP route with the smallest IGP metric to reach NEXT_HOP
  9. When EBGP route, give priority to the route received first
  10. Prefer BGP route received from BGP neighbor with smallest router ID
  11. Prefer BGP route with the smallest CLUSTER_LIST
  12. Prefer BGP route received from BGP neighbor with smallest IP address

In the following sections, each process will be looked at in a little more detail. For the sake of explanation, only the attributes of each item will be focused on. Remember, however, that there are many different attributes attached to a BGP route, not just one. In the BGP table in the figure, the best path is denoted by “>” to match Cisco’s notation.

There is no need to memorize the order in which attributes are evaluated when selecting the best path. Refer to this page and others when needed. If you are taking the CCNP or CCIE, please memorize it.

Prefer BGP route with the highest WEIGHT

The WEIGHT attribute is Cisco proprietary. If configured to add WEIGTH, the BGP route with the highest WEIGHT attribute is assumed to be the best path.

Figure WEIGHT
Figure WEIGHT

Prefer BGP route with the highest LOCAL_PREF

Next to WEIGHT, examine the LOCAL_PREF attribute. The LOCAL_PREF attribute is used to determine the router that will be the exit point when routing to another AS’s network. The BGP route with the highest LOCAL_PREF attribute is determined as the best path.

Figure LOCAL_PREF
Figure LOCAL_PREF

Prefer locally generated BGP route

A locally generated BGP route is one that is generated as a BGP route by configuring the network command or the aggregate-address command. Prefer BGP route generated by the router itself over BGP route received from other BGP neighbors.

Prefer BGP route with shortest AS_PATH

AS_PATH lists the AS number that the BGP route traversed. The length of AS_PATH is the number of AS numbers it contains. For example, in the following figure, the length of AS_PATH for BGP route 192.168.1.0/24 received from R2 is “2”; the length of AS_PATH for BGP route 192.168.1.0/24 received from R3 is “3”. In other words, the BGP route with the fewest number of ASes traversed is determined as the best path in preference.

Figure AS_PATH
Figure AS_PATH

Prefer BGP route with the smallest ORIGIN

The ORIGIN attribute has 3 values.

  • 0 (IGP)
  • 1 (EGP)
  • 2 (Incomplete)

The BGP route with the smallest ORIGIN attribute is determined to be the best path.

Figure ORIGIN
Figure ORIGIN

However, the ORIGIN attribute rarely determines the best path. This is because the ORIGIN attribute added to a BGP route is basically 0, i.e., IGP.

Normally, ORIGIN is not used to determine the best path, but in the CCIE lab exam, there may be conditions that make ORIGIN the best path.

Prefer BGP route with the smallest MED

MED is an attribute used to determine the router that is the entry point for routing from a neighboring AS to its own network. An attribute that corresponds to a metric in an IGP such as OSPF, with the smaller value having priority.

Figure MED
Figure MED

Note that there are various conditions for MED evaluations, which are omitted here in detail.

Prefer EBGP route over IBGP route

The BGP route received from an EBGP neighbor is preferred over the BGP route received from an IBGP neighbor.

Figure  Prefer EBGP route over IBGP route
Figure Prefer EBGP route over IBGP route

Prefer BGP route with the smallest IGP metric to reach NEXT_HOP

When a BGP route is registered in the routing table, the next hop is the IP address of the NEXT_HOP attribute; the IP address of the NEXT_HOP attribute is not necessarily the IP address of the directly connected network. Sometimes the routing table is searched recursively in order to route to the IP address of the NEXT_HOP attribute. BGP routes received from IBGP neighbors usually require a recursive lookup of the routing table.

The BGP route with the smallest IGP metric value when recursively searching for the IP address of the NEXT_HOP attribute is preferred as the best path.

Figure  Prefer BGP route with the smallest IGP metric to reach NEXT_HOP
Figure Prefer BGP route with the smallest IGP metric to reach NEXT_HOP

When EBGP route, give priority to the route received first

In the case of a BGP route received from an EBGP neighbor, the route received first is determined as the best path.

Prefer BGP route received from BGP neighbor with smallest router ID

BGP routers, like OSPF, have router ID to identify each router. The BGP route received from the BGP neighbor with the smallest router ID is determined as the best path in preference.

Figure Router ID
Figure Router ID

Prefer BGP route with the smallest CLUSTER_LIST

CLUSTER_LIST is a path attribute that is added when the route reflector is configured. CLUSTER_LIST contains the router ID of the route reflector; the route with the smallest router ID in CLUSTER_LIST is determined as the best path.

Prefer BGP route received from BGP neighbor with smallest IP address

Multiple BGP neighbors can also be established with the same router with different IP addresses.And when the best path cannot be determined in the process up to this point, the BGP route received from the BGP neighbor with the smallest IP address is given priority as the best path.

Figure  Prefer BGP route received from BGP neighbor with smallest IP address
Figure Prefer BGP route received from BGP neighbor with smallest IP address

Most of the time, it’s up to MED to decide.

When multiple BGP routes are received for a specific network address as described above, the best path is determined by various path attributes. However, to determine the best path, it is not necessary to evaluate even the back end of such a process. Commonly used path attributes to determine the best path include

  • LOCAL_PREF
  • AS_PATH
  • MED

Adjust the path attribute so that the best path is determined up to MED. To adjust path attributes, Cisco routers use route-maps.

Summary

Points

  • In BGP, the best path can be flexibly determined by path attributes.
  • The process for determining the best path is as follows
  1. Prefer BGP route with the highest WEIGHT
  2. Prefer BGP route with the highest LOCAL_PREF
  3. Prefer locally generated BGP route
  4. Prefer BGP route with shortest AS_PATH
  5. Prefer BGP route with the smallest ORIGIN
  6. Prefer BGP route with the smallest MED
  7. Prefer EBGP route over IBGP route
  8. Prefer BGP route with the smallest IGP metric to reach NEXT_HOP
  9. When EBGP route, give priority to the route received first
  10. Prefer BGP route received from BGP neighbor with smallest router ID
  11. Prefer BGP route with the smallest CLUSTER_LIST
  12. Prefer BGP route received from BGP neighbor with smallest IP address

  • The path attributes often used when determining the best path are “LOCAL_PREF”, “MED”, and “AS_PATH”.