1.5b Path Selection
To decide which route is the best, each BGP router has a “best path selection” algorithm, where the information from two similar paths are compared. This is because it is not unusual for a BGP speaker to receive the same route from multiple peers. In fact, this is quite normal when you have multiple upstreams or peers.
Before we cover how the BGP best path selection algorithm works, however, it’s important to know that not all of the received BGP routes are candidates for being selected as the best route. There are many reasons for this, a common one being that the next-hop advertised as an attribute for the route is inaccessible.
1.5b i Attributes
Now, let’s take a look at the factors that govern selecting a best route candidate (and the order they are considered in) using the BGP selection algorithm on a Cisco router:
| Priority | Attribute | Description |
| 1 | Weight | Prefer the path with the highest weight. This is a value that is local to the router and is Cisco proprietary. Default weight is 0. |
| 2 | Local Preference | The local preference is use within an AS and exchanged between iBGP routers. Highest local preference is preferred, default value is 100. |
| 3 | Originate | Prefer the path that the local router originated. In the BGP table you will see next hop 0.0.0.0. Will prefer routes that are installed into BGP locally, over a route installed into BGP on another router. |
| 4 | AS Path Length | Prefer the path with the shortest AS Path Length. E.g. AS Path 1 2 3 is preferred over AS Path 1 2 3 4 5. |
| 5 | Origin Code | Prefer the lowest Origin Code. The three Origin Codes are IGP < EGP < Incomplete |
| 6 | MED | Prefer the path with the lowest MED. The MED is exchanged between autonomous systems. |
| 7 | eBGP > iBGP | As it says on the tin, prefer the eBGP path over an iBGP path. |
| 8 | Shortest IGP Path | Prefer the path within the AS with the lowest IGP metric to the BGP next-hop. |
| 9 | Oldest Path | AS it says on the tin, prefer the path received first (oldest path). |
| 10 | Router ID | Prefer the path of the BGP neighbor that has the lowest Router ID. |
| 11 | Neighbor IP Address | Prefer the path of the BGP neighbour that has the lowest IP address. |
1.5.b ii Best path selection algorithm
In order to find the best route, BGP will go thru each attribute listed above. Higher priority wins.
Details can be found here: BGP Best Path Selection Algorithm
1.5.b iii Load balancing
By default, BGP operates by selecting a single best path to each destination prefix, however Equal Cost Multi-Path Routing is configurable. In order for this to occur, the following details must match:
- Weight
- Local Preference
- AS Path (Both AS numbers and AS Path Length)
- Origin Code
- MED
- IGP metric
The next hop address for each path must be different.
To configure this, use the command maximum-paths <number of paths>.
router bgp 65000
maximum-paths 2
This is useful if you are doing multipath to the same AS but will not work when your paths are to different AS’. If your multipath is to different AS’ but have the same AS Path Length, we can use an additional command: bgp bestpath as-path multipath-relax, which only checks AS Path Length.
router bgp 100
bgp bestpath as-path multipath-relax
BGP unequal cost load sharing
By default, traffic sharing on multipath in BGP is 1:1 or Equal-cost, but just like with EIGRP, we can manipulate this to do unequal-cost multi-path.
The below example is taken from https://aboutnetworks.net/bgp-load-sharing/
Unequal cost load sharing for outgoing traffic from AS-4.

Now we have 20Mbps between AS-4 and AS-2 and 40Mbps between AS-4 and AS3.
For this, on R4 we have first to configure the real bandwidth on the physical interfaces to R2 and R3:
interface GigabitEthernet0/1
description to R2
bandwidth 20000
ip address 10.0.0.14 255.255.255.252
duplex full
speed auto
media-type rj45
!
interface GigabitEthernet0/3
description to R3
bandwidth 40000
ip address 10.0.0.18 255.255.255.252
duplex full
speed auto
media-type rj45!
And then, we need to configure BGP dmzlink-bw globally and for each uplink:
router bgp 4
bgp log-neighbor-changes
bgp bestpath as-path multipath-relax
bgp dmzlink-bw
network 4.4.4.4 mask 255.255.255.255
neighbor 10.0.0.13 remote-as 2
neighbor 10.0.0.13 next-hop-self
neighbor 10.0.0.13 dmzlink-bw
neighbor 10.0.0.17 remote-as 3
neighbor 10.0.0.17 next-hop-self
neighbor 10.0.0.17 dmzlink-bw
neighbor 10.0.0.22 remote-as 5
neighbor 10.0.0.22 next-hop-self
maximum-paths 4
R4#
Now, let’s look at the routing table for 0.0.0.0/0:
R4#show ip route 0.0.0.0
Routing entry for 0.0.0.0/0, supernet
Known via "bgp 4", distance 20, metric 0, candidate default path
Tag 2, type external
Last update from 10.0.0.17 00:03:14 ago
Routing Descriptor Blocks:
10.0.0.17, from 10.0.0.17, 00:03:14 ago
Route metric is 0, traffic share count is 2
AS Hops 1
Route tag 2
MPLS label: none
* 10.0.0.13, from 10.0.0.13, 00:03:14 ago
Route metric is 0, traffic share count is 1
AS Hops 1
Route tag 2
MPLS label: none
R4#
Now you can see we have a share count 2:1 between the two interfaces, based on the bandwidth configured.
Comments
So empty here ... leave a comment!