0% found this document useful (0 votes)
27 views13 pages

Understanding BGP Best Path Selection &..

Uploaded by

bok
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views13 pages

Understanding BGP Best Path Selection &..

Uploaded by

bok
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

12/3/2017 Understanding BGP Best Path Selection &...

- Cisco Support Community

Cisco Support English

Cisco Support Community


Register Login

Cisco Support Community / Network Infrastructure / Network Infrastructure Documents / Understanding BGP Best Path Selection &...  Options

All community

 Search the Community

Understanding BGP Best Path Selection & Manipulation

Introduction
This document outlines the BGP best path selection algorithm, and covers speci c con guration examples on how to manipulate
BGP’s best path decision based on di erent attributes.

Initial Topology

The following topology will be referenced for the entirety of this document unless otherwise stated. EIGRP is being used as the
underlying IGP for basic connectivity.

In the topology above R1 is receiving a similar BGP route (172.16.1.0/24) via R2 and R3. Prior to any user manipulation, R1 prefers
the path advertised from R2 over the path advertised from R3. This can be seen in the following output:

R1#sh ip bgp

BGP table version is 2, local router ID is 13.13.13.1

https://supportforums.cisco.com/t5/network-infrastructure-documents/understanding-bgp-best-path-selection-manipulation/ta-p/3150576 1/13
12/3/2017 Understanding BGP Best Path Selection &... - Cisco Support Community

Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,

r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,

x best-external, a additional-path, c RIB-compressed,

Origin codes: i - IGP, e - EGP, ? - incomplete

RPKI validation codes: V valid, I invalid, N Not found

Network Next Hop Metric LocPrf Weight Path

* 172.16.1.0/24 13.13.13.3 0 200 300 i

*> 12.12.12.2 0 200 300 i

The '>' shown in the output above indicates that the path with a next hop of 12.12.12.2 (R2) is the current best path.

R1#sh ip bgp 172.16.1.0/24

BGP routing table entry for 172.16.1.0/24, version 2

Paths: (2 available, best #2, table default)

Advertised to update-groups:

Refresh Epoch 1

200 300

13.13.13.3 from 13.13.13.3 (34.34.34.3)

Origin IGP, localpref 100, valid, external

Refresh Epoch 1

200 300

12.12.12.2 from 12.12.12.2 (24.24.24.2)

Origin IGP, localpref 100, valid, external, best

R1#

The above output further illustrates that the path with a next hop address of 12.12.12.2 is currently being chosen as 'best', as well
as the BGP path attributes associated to the paths that are being compared.

Once R1 has selected the best path it performs a recursive routing lookup on the associated next hop address. In this case the next
hop address is 12.12.12.2, so the lookup will result in a next hop interface of FastEthernet0/0.

R1#sh ip route 12.12.12.2

Routing entry for 12.12.12.0/24

Known via "connected", distance 0, metric 0 (connected, via interface)

Redistributing via eigrp 1

Routing Descriptor Blocks:

* directly connected, via FastEthernet0/0

https://supportforums.cisco.com/t5/network-infrastructure-documents/understanding-bgp-best-path-selection-manipulation/ta-p/3150576 2/13
12/3/2017 Understanding BGP Best Path Selection &... - Cisco Support Community

Route metric is 0, traffic share count is 1

Once the lookup has been done for the Next Hop Address we now have the associated next hop interface which is installed for the
CEF entry:

R1#sh ip cef 172.16.1.0/24

172.16.1.0/24

nexthop 12.12.12.2 FastEthernet0/0

Determining Which Path is Best


BGP compares multiple path attributes when choosing which path is best. The list of steps that are performed in the comparison
can also be found in the Best Path Selection Algorithm.

The default Best Path Selection Algorithm includes the following steps:

1. Compare Weight

The path with the highest weight is preferred. If the weight is identical, move on to step 2.

This path attribute is only locally signi cant. If you change the weight on one router, it will not a ect any other router within the
Autonomous System. This is a Cisco Proprietary feature.

2. Compare Local Preference

The path with the highest local preference is preferred. If the local preference is identical, move on to step 3.

This path attribute is not locally signi cant. If you change the local preference on one router, it will a ect other routers within the
Autonomous System.

3. Is the Path Locally Originated?

Any path that has been originated on a local router will be preferred over any paths learned from a BGP Peer. If no locally originated
pre x exists in the BGP table for the paths being compared, move on to step 4.

In Cisco IOS this step is implemented by associating a weight of 32768 to any pre xes advertised into BGP on the local router.

For example, when R4 advertised the 172.16.1.0/24 pre x into BGP with the command network 172.16.1.0 mask 255.255.255.0
it automatically added a weight of 32768 to that pre x in the BGP table. This can be seen from the following output:

R4#sh ip bgp 172.16.1.0/24

BGP routing table entry for 172.16.1.0/24, version 2

Paths: (1 available, best #1, table default)

Advertised to update-groups:

Refresh Epoch 1

Local

https://supportforums.cisco.com/t5/network-infrastructure-documents/understanding-bgp-best-path-selection-manipulation/ta-p/3150576 3/13
12/3/2017 Understanding BGP Best Path Selection &... - Cisco Support Community

0.0.0.0 from 0.0.0.0 (172.16.1.1)

Origin IGP, metric 0, localpref 100, weight 32768, valid, sourced, local, best

This means that R4 will prefer its next hop address for the 172.16.1.0/24 subnet, regardless of similar paths learned via its BGP
peers.

4. Compare AS Path

The path with the shortest AS Path is preferred. If the AS Path is identical in length, move on to step 5.

5. Compare Origin

This step in the Best Path Selection process compares how BGP learned about a path originally. There are 3 origin codes:

IGP - the path was learned by BGP via the network statement and is interior to the originating Autonomous System

INCOMPLETE - the path was learned BGP in an unknown fashion, typically via Redistribution.

IGP > INCOMPLETE

If the origin is identical, move on to step 6.


6. Compare the Multi-Exit Discrimiator (MED)

The path with the lowest MED is preferred. This check is only done if the rst hop AS is identical in the paths being compared. If
the rst hop AS is di erent or the MED is identical, move on to step 7.
7. Compare Neighbor Type

Paths learned from eBGP peers are preferred over paths learned from iBGP peers. If all paths were learned from the same type of
peer, move on to step 8. If the best path is selected during this step, skip step 8 and move on to step 9.
8. IGP Metric

BGP advertises a pre x and a next hop address with any path. The path with the lower IGP metric to the associated next hop
address is preferred. If the IGP metrics are identical on all paths, move on to step 9.
9. Are Multiple Paths Allowed?

BGP by default will only install one path as best. If you con gure the maximum-paths command to allow more than one path to be
installed, BGP will use the IGP to load balance to the associated destination pre x.

At this point if the best path has not been selected, move on to step 10.
10. Compare Route Age

When both paths are learned from eBGP peers, BGP prefers the route that was learned first.

The logic is that the longer a route has been in the BGP Table, the more stable that path must be. This does not apply to iBGP
routes.
11. Compare Neighbor's Router-ID

Prefer the path that is learned from the peer with the lower BGP Router-ID. If the Router-ID is identical, move on to step 12.
12. Compare Cluster List Length

The path with the minimum Cluster List Length is preferred. (This only comes into play in BGP Route-Re ector environments)

https://supportforums.cisco.com/t5/network-infrastructure-documents/understanding-bgp-best-path-selection-manipulation/ta-p/3150576 4/13
12/3/2017 Understanding BGP Best Path Selection &... - Cisco Support Community

If the Cluster List Length is identical, move on to step 13.

13. Compare the Neighbor Address

This is the catch-all rule in the best path selection process. The path with the lower peer address (the IP address con gured with
the neighbor statement) is preferred. You cannot con gure multiple neighbors with the same IP address, so it is impossible for this
step to result in a tie.

Manipulating the Best Path


This section covers how to manipulate BGP Path Attributes to alter which path BGP chooses is best. The following Path Attributes
will be illustrated:

- Weight

- Local Preference

- AS Path

- MED

- Installing Multiple Paths

NOTE: All best path manipulation covered in this section will be done on a per neighbor basis. Altering path attributes per
prefix is not discussed to reduce complexity.

In each of the following examples BGP has chosen R2 as the preferred next hop to the 172.16.1.0/24 subnet prior to any user
con guration.

R1#sh ip bgp 172.16.1.0/24

BGP routing table entry for 172.16.1.0/24, version 2

Paths: (2 available, best #2, table default)

Advertised to update-groups:

Refresh Epoch 1

200 300

13.13.13.3 from 13.13.13.3 (34.34.34.3)

Origin IGP, localpref 100, valid, external

Refresh Epoch 1

200 300

12.12.12.2 from 12.12.12.2 (24.24.24.2)

Origin IGP, localpref 100, valid, external, best

Manipulating WEIGHT
R1's weight can be altered to prefer the next hop address of 13.13.13.3 for the 172.16.1.0/24 pre x. The following example uses
the weight keyword to do so, instead of setting the value with a route-map.
On R1:

https://supportforums.cisco.com/t5/network-infrastructure-documents/understanding-bgp-best-path-selection-manipulation/ta-p/3150576 5/13
12/3/2017 Understanding BGP Best Path Selection &... - Cisco Support Community

Here we con gure a WEIGHT of 1 to all pre xes learned from the neighbor 13.13.13.3:

R1#conf t

Enter configuration commands, one per line. End with CNTL/Z.

R1(config)#router bgp 100

R1(config-router)#neighbor 13.13.13.3 weight 1

R1(config-router)#end

R1#

The Pre xes learned from R3 must be updated for this con guration to take a ect. You can request a route refresh from R3 to
accomplish this with the command clear ip bgp 13.13.13.3 soft in.

Now when BGP goes to compare the Best Path Attributes of the two known paths the rst thing that is checked is weight. Since the
weight of the R3 path is 1, and the weight of the R2 path is 0 (by default) R1 prefers the path with a next hop address of
13.13.13.3.

R1#sh ip bgp 172.16.1.0/24

BGP routing table entry for 172.16.1.0/24, version 5

Paths: (2 available, best #1, table default)

Advertised to update-groups:

Refresh Epoch 2

200 300

13.13.13.3 from 13.13.13.3 (34.34.34.3)

Origin IGP, localpref 100, weight 1, valid, external, best

Refresh Epoch 2

200 300

12.12.12.2 from 12.12.12.2 (24.24.24.2)

Origin IGP, localpref 100, valid, external

R1#

Weight is only illustrated in the show ip bgp output when a value is present. The Path with a next hop of 12.12.12.2 does not
illustrate the weight in this example because no value has been set by the user.

The next hop interface for tra c destined to the 172.16.1.0/24 pre x is now updated to FastEthernet0/1.

R1#sh ip cef 172.16.1.0/24

172.16.1.0/24

nexthop 13.13.13.3 FastEthernet0/1

https://supportforums.cisco.com/t5/network-infrastructure-documents/understanding-bgp-best-path-selection-manipulation/ta-p/3150576 6/13
12/3/2017 Understanding BGP Best Path Selection &... - Cisco Support Community

R1#

Manipulating LOCAL PREFERENCE

R1's local preference can be altered to prefer the next hop address of 13.13.13.3 for the 172.16.1.0/24 pre x. The following
example uses a route-map to set the value.
On R1:

Here we con gure a Local Preference of 101 (the default is 100) to all pre xes learned from the neighbor 13.13.13.3:

R1#

R1#conf t

Enter configuration commands, one per line. End with CNTL/Z.

R1(config)#route-map RM_LOCAL_PREF permit 10

R1(config-route-map)#set local-preference 101

R1(config-route-map)#exit

R1(config)#

R1(config)#router bgp 100

R1(config-router)#neighbor 13.13.13.3 route-map RM_LOCAL_PREF in (can only be set inbound)

R1(config-router)#end

R1#clear ip bgp 13.13.13.3 soft in

R1#

Since the weight of both paths are identical, BGP then checks the local preference to determine which path is best. Since the path
learned from R3 now has a higher local preference, it is preferred:

R1#sh ip bgp 172.16.1.0/24

BGP routing table entry for 172.16.1.0/24, version 3

Paths: (2 available, best #2, table default)

Advertised to update-groups:

Refresh Epoch 2

200 300

12.12.12.2 from 12.12.12.2 (24.24.24.2)

Origin IGP, localpref 100, valid, external

Refresh Epoch 3

200 300

13.13.13.3 from 13.13.13.3 (34.34.34.3)

Origin IGP, localpref 101, valid, external, best

R1#

https://supportforums.cisco.com/t5/network-infrastructure-documents/understanding-bgp-best-path-selection-manipulation/ta-p/3150576 7/13
12/3/2017 Understanding BGP Best Path Selection &... - Cisco Support Community

The next hop interface for tra c destined to the 172.16.1.0/24 pre x is now updated to FastEthernet0/1.

R1#sh ip cef 172.16.1.0/24

172.16.1.0/24

nexthop 13.13.13.3 FastEthernet0/1

R1#

Manipulating the AS PATH

R1's AS Path can be altered to prefer the next hop address of 13.13.13.3 for the 172.16.1.0/24 pre x.The following example uses
a route-map to prepend additional hops onto the AS Path of the path learned from R2.

On R1:

Here we con gure an AS Path with 2 additional hops for all of pre xes learned from the neighbor 12.12.12.2:

R1#

R1#conf t

Enter configuration commands, one per line. End with CNTL/Z.

R1(config)#route-map RM_AS_PATH_PREPEND

R1(config-route-map)#set as-path prepend 200 200

R1(config-route-map)#exit

R1(config)#router bgp 100

R1(config-router)#neighbor 12.12.12.2 route-map RM_AS_PATH_PREPEND in (could be done inbound or


outbound)

R1(config-router)#end

R1#clear ip bgp 12.12.12.2 soft in

R1#

Now the path learned from R2 will have 2 additional hops associated to it. This will make the path from R3 more preferred since it is
shorter:

R1#sh ip bgp 172.16.1.0/24

BGP routing table entry for 172.16.1.0/24, version 3

Paths: (2 available, best #1, table default)

Advertised to update-groups:

Refresh Epoch 2

200 300

13.13.13.3 from 13.13.13.3 (34.34.34.3)

Origin IGP, localpref 100, valid, external, best

Refresh Epoch 3

200 200 200 300

https://supportforums.cisco.com/t5/network-infrastructure-documents/understanding-bgp-best-path-selection-manipulation/ta-p/3150576 8/13
12/3/2017 Understanding BGP Best Path Selection &... - Cisco Support Community

12.12.12.2 from 12.12.12.2 (24.24.24.2)

Origin IGP, localpref 100, valid, external

R1#

The next hop interface for tra c destined to the 172.16.1.0/24 pre x is now updated to FastEthernet0/1.

R1#sh ip cef 172.16.1.0/24

172.16.1.0/24

nexthop 13.13.13.3 FastEthernet0/1

R1#

Manipulating MED

R1's MED can be altered to prefer the next hop address of 13.13.13.3 for the 172.16.1.0/24 pre x. The following example uses a
route-map to set the value.

On R2:

MED can only be con gured outbound to in uence which path is the preferred entry point into an Automonous System. We want to
in uence R1 to prefer the path via R3, so we con gure a higher MED value to be advertised from R2 to R1 than from R3 to R1.

R2#

R2#conf t

Enter configuration commands, one per line. End with CNTL/Z.

R2(config)#route-map RM_MED permit 10

R2(config-route-map)#set metric 1 (In Cisco IOS, you use the metric keyword to alter MED for BGP)

R2(config-route-map)#exit

R2(config)#router bgp 200

R2(config-router)#neighbor 12.12.12.1 route-map RM_MED out

R2(config-router)#end

R2#clear ip bgp 12.12.12.1 soft out

R2#

Now when R1 reaches step 6 in the best path selection process, it will choose the path learned from R3 since the MED is lower (a
default of 0) than what is advertised by R2:

R1#sh ip bgp 172.16.1.0/24

BGP routing table entry for 172.16.1.0/24, version 3

Paths: (2 available, best #2, table default)

Advertised to update-groups:

Refresh Epoch 2

https://supportforums.cisco.com/t5/network-infrastructure-documents/understanding-bgp-best-path-selection-manipulation/ta-p/3150576 9/13
12/3/2017 Understanding BGP Best Path Selection &... - Cisco Support Community

200 300

12.12.12.2 from 12.12.12.2 (24.24.24.2)

Origin IGP, metric 1, localpref 100, valid, external

Refresh Epoch 3

200 300

13.13.13.3 from 13.13.13.3 (34.34.34.3)

Origin IGP, localpref 100, valid, external, best

R1#

If a MED value has not been set by the BGP peer, we will not show the value of 0 in the show ip bgp output.

The next hop interface for tra c destined to the 172.16.1.0/24 pre x is now updated to FastEthernet0/1.

R1#sh ip cef 172.16.1.0/24

172.16.1.0/24

nexthop 13.13.13.3 FastEthernet0/1

R1#

Installing Multiple Paths

By default BGP will only choose one path as best. If multiple paths are learned to a destination subnet the user can con gure BGP
to load balance with the underlying IGP.

On R1:

Adjusting the number of paths that BGP is allowed to install can be done as follows:

R1#

R1#conf t

Enter configuration commands, one per line. End with CNTL/Z.

R1(config)#router bgp 100

R1(config-router)#maximum-paths 2

R1(config-router)#end

R1#

With this con guration in place BGP can now install 2 paths to the 172.16.1.0/24 subnet. The path that R2 and R3 advertise are
identical in the best path selection process up to step 9, so they're both candidates for installation in the Routing Table.

R1#sh ip bgp 172.16.1.0/24

BGP routing table entry for 172.16.1.0/24, version 4

Paths: (2 available, best #2, table default)

https://supportforums.cisco.com/t5/network-infrastructure-documents/understanding-bgp-best-path-selection-manipulation/ta-p/3150576 10/13
12/3/2017 Understanding BGP Best Path Selection &... - Cisco Support Community

Multipath: eBGP

Advertised to update-groups:

Refresh Epoch 4

200 300

12.12.12.2 from 12.12.12.2 (24.24.24.2)

Origin IGP, localpref 100, valid, external, multipath(oldest)

Refresh Epoch 3

200 300

13.13.13.3 from 13.13.13.3 (34.34.34.3)

Origin IGP, localpref 100, valid, external, multipath, best

R1#

Now when BGP does the recursive routing lookup for the Next Hop addresses of each path it will use both next hop interfaces to
load balance tra c via the IGP (in this case EIGRP):

R1#sh ip cef 172.16.1.0/24

172.16.1.0/24

nexthop 12.12.12.2 FastEthernet0/0

nexthop 13.13.13.3 FastEthernet0/1

R1#

Now both interfaces are used to forward tra c.

Final Thoughts
The advantage that BGP has over all other routing protocols is the ability to control path selection based on di erent routing
policies. The policy to apply to in uence tra c into and out of your network should be based on what ts within your existing
deployment and what you nd easiest to manage.

Version history

Revision #: 1 of 1
Last update: 02-12-2013 10:58 AM
Updated by: jawestbr

View article history

Labels (1)

WAN Routing and Switchi…

https://supportforums.cisco.com/t5/network-infrastructure-documents/understanding-bgp-best-path-selection-manipulation/ta-p/3150576 11/13
12/3/2017 Understanding BGP Best Path Selection &... - Cisco Support Community

Everyone's tags (7)

bgp bgp_algorithm bgp_best_path ccie route route_manipulation routing

 15 Helpful

Share

COMMENTS

02-20-2013 04:29 A
Anonymous N/A

Excelent document, I really liked that is is very concise. If someone needs to learn BGP path selection, I think this document is a great
starting point. It is also very good for refreshing what you already know. Thanks James!

11-19-2013 06:34 P
Dennis McLaughlin Cisco Employee

Great doc Brooks. Very detailed and easy to follow along. Keep up the good work.

Thanks,

Top Tags VIEW ALL

troubleshoot catalyst_6500 con guration error_message catalyst_6000 ios catalyst_4500 faq catalyst_3750 ospf

ip_routing catalyst_4000 vlan cat_os bgp ipv6 routing catos router supervisor catalyst_3550 memory_issues

connectivity_issues design port_issues nat eigrp catalyst_2950 catalyst_3560 upgrade

 Top

     
Facebook
Twitter
+
Google
YouTube
LinkedIn
Instagram
https://supportforums.cisco.com/t5/network-infrastructure-documents/understanding-bgp-best-path-selection-manipulation/ta-p/3150576 12/13
12/3/2017 Understanding BGP Best Path Selection &... - Cisco Support Community

Contacts Privacy Statement


Feedback Cookie Policy 
Site Map Trademarks
Terms & Conditions Help

https://supportforums.cisco.com/t5/network-infrastructure-documents/understanding-bgp-best-path-selection-manipulation/ta-p/3150576 13/13

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy