The following list of rules determines the best path:

1.Prefer the path with the largest WEIGHT. WEIGHT is a Cisco proprietary parameter, local to the router on which it is configured.

2.Prefer the path with the largest local preference (LOCAL_PREF).

3.Prefer the path that was locally originated through a network or aggregate BGP subcommand, or through redistribution from an IGP. Local paths sourced by network/redistribute commands are preferred over local aggregates sourced by the aggregate-address command.

4.Prefer the path with the shortest AS_PATH. The AS_PATH is a listing of the autonomous systems through which this particular update traveled to reach the local autonomous system. The fewer autonomous systems it crossed, the more preferred the route is. Note the following:

a.- This step is skipped if you configure bgp bestpath as-path ignore.

b.- An AS_SET counts as 1, no matter how many autonomous systems are in the set.

c.- The AS_CONFED_SEQUENCE is not included in the AS_PATH length.

5.Prefer the path with the lowest origin type: IGP is lower than EGP, and EGP is lower than INCOMPLETE.

6.Prefer the path with the lowest multi-exit discriminator (MED). Note the following:

a.- This comparison is done only if the first (neighboring) AS is the same in the two paths; any Confederation Sub-autonomous systems are ignored. In other words, MEDs are compared only if the first AS in the AS_SEQUENCE is the same for multiple paths. Any preceding AS_CONFED_SEQUENCE is ignored.

b.- If bgp always-compare-med is enabled, MEDs are compared for all paths. This option needs to be enabled over the entire AS, otherwise, routing loops can occur.

c.- If bgp bestpath med-confed is enabled, MEDs are compared for all paths that consist only of AS_CONFED_SEQUENCE (paths originated within the local confederation).

d.- Paths received from a neighbor with a MED of 4,294,967,295 will have the MED changed to 4,294,967,294 before insertion into the BGP table.

e.- Paths received with no MED are assigned a MED of 0, unless bgp bestpath missing-as-worst is enabled; in that case, they are assigned a MED of 4,294,967,294.

f.- The bgp deterministic med command also can influence this step.

7.Prefer external (eBGP) over internal (iBGP) paths. Paths containing AS_CONFED_SEQUENCE are local to the confederation and, therefore, are treated as internal paths. There is no distinction between Confederation External and Confederation Internal.

8.Prefer the path with the lowest IGP metric to the BGP next hop.

9.If the maximum-paths n command is enabled and there are multiple external or confederation external paths from the same neighboring AS or Sub-AS, BGP inserts up to n most recently received paths in the IP routing table. This allows eBGP multi-path load sharing. The maximum value of n is currently 6. The default value, when this option is disabled, is 1. The oldest received path is marked as the best path in the output of show ip bgp longer-prefixes, and the equivalent of next-hop-self is performed before forwarding this best path to internal peers.

10.If both paths are external, prefer the path that was received first (the oldest one). This step minimizes route flapping because a newer path won\'t displace an older one, even if it was the preferred route based on the RID. It is better practice to apply the additional decision steps in 11, 12, and 13 to iBGP paths only, to ensure a consistent best path decision within the network and thereby avoid loops. This step is skipped if any of the following is true:

a.- The bgp best path compare-routerid command is enabled.

b.- The router ID is the same for multiple paths because the routes were received from the same router.

c.- No current best path exists. An example of losing the current best path occurs when the neighbor offering the path goes down.

11.Prefer the route coming from the BGP router with the lowest router ID. The router ID is the highest IP address on the router, with preference given to loopback addresses. It can also be set manually using the bgp router-id command. If a path contains RR attributes, the originator ID is substituted for the router ID in the path selection process.

12.If the originator or RID is the same for multiple paths, prefer the path with the minimum cluster ID length. This will be present only in a BGP Route-Reflector environment in which clients peer with RRs or clients in other clusters. In this scenario, the client must be aware of the RR-specific BGP attribute.

13.Prefer the path coming from the lowest neighbor address. This is the IP address used in the BGP neighbor configuration, and it corresponds to the remote peer used in the TCP connection with the local router.



1.优选有最大Weight的路由 (范围0 到 65,535)
A:weight是CISCO私有的参数,路由器配置了权重后在本地有效。
3.优选有最大LOCAL_PREF值的路由(范围 0到 4,294,967,295).
4.优选从本路由器始发的路由(包括本地network配置的重分布,或者在IGP表中已经有一些需要被配置路由聚合的地址,在BGP中用Aggregate命令配置的路由聚合)
5.优选有最短AS_PATH的路由
A.如果配置了Bgp bestpath as-path ignore,则这个步骤被忽略
B.一个AS路径集被当作一个AS,无论在这个集合中有多少AS。
C.AS路径长度中没有包括AS_CONFED_SEQUENCE。
6.根据Origin属性.优选具有最低起源类型的路由(IGP>EG>Incomplete)
7.优选最小MED 值的路由(范围 0到4,294,967,295).
A.只有在通过两条路径得到第一个AS(对等体)是同一个AS时才进行MED比较;任何子自治域的联盟系统都会被忽略。也就是说,只有在AS序列号中第一个AS号码一致时,才进行MED比较;任何联盟AS序列号(AS_CONFED_SEQUENCE)都会被忽略。
B.如果路由器上配置了 bgp always—compare—med ,在全部的路径进行MED比较。但是这需要全体AS 都同时启用这个功能,否则有可能发生路由环路。
C.如果路由器上配置了 bgp bestpath med confed ,将对所有只包括AS_CONFED_SEQUENCE的路径进行MED比较(即路径是起源于本地联盟)。
D.如果接收到的路径没有分配MED值,则将此路径分配为0,除非路由器上配置了bestpath missing—is—worst,将被看作MED值为4,294,967,295的路由将在注入到BGP路由选择表之前被改为4,294,967,294。
E.BGP明确的MED值9(详见本章后面的"BGP明确的MED"段落)也可以影响此步骤。
8.外部路由EBGP优先于联盟(confederation)外部路由优于内部路由IBGP(优选 E-BGP路由)
注意,路径中包括AS_CONFEND_SEQUENCE属性对联盟只有在本地有效,因此被看作是内部路径。无法区别外部联盟和内部联盟。
9. 优选能通过最近的IGP邻居到达的路径(优选对BGP下一跳具有最低IGP度量值的路径);
10.如果在路由器上配置了maximum—pathsN,而且从同一个对等体自治域/子自治域接收到多条外部/外部联盟的路径,则最多可以将N条最近接收到的路径加入到IP路由选择表中。这可以使得eBGP在多条路径上进行负载分担。目前N所代表的最大数目是6;当没有启用此功能时,缺省数值是1。在输入了show ip bgp x.x.x.x后系统输出信息中可以看到最早接收到的路径被标记为最优路径,在将这条最优路径转发到内部对等体之前,需要执行与next_hop_self作用相同的功能。
11.如果是external的路由,优选最老的路由(最先被学习到的路由).
A.此步骤可以将路由摆动的影响减到最小,因为新接收到的路径不会取代老的,即使这条新接收的路径是通过下面提及到的额外路径选择标准来进行选择的。这使得只在iBGP路径下应用额外的选择步骤更有意义。
B.此步骤可以被bgp bestpath compare_routerid命令语句所关闭。
C.如果路由器标志是一样的,此步骤可以被屏蔽,因为这说明路由器正在从自己那里接收路由。
D.如果当前没有最优路由器,此步骤可以被屏蔽。当提供某个路径的对等体路由器宏机,就会发生丢失当前最优路径的情况。
12.如果在同一时间学习到多条到同一目的地的路由,优选最小BGP-router-ID的路由,注意,如果一个路径包括路由反射器属性,起始者标识将代替路由器标识在路径选择过程中起作用。
12.如果路由从路由反射器上学习到 ,优选最小Cluster-ID(BGP_ID of the route reflector)长度的路由,而且它运行客户机和其他反射器族中的RR/Clients 之间做对等连接,在这种情况下,路由器必须知道BGP协议中的RR的具体配置。
13.优选具有最低对等体地址接收到的路径。这个地址是在BGP对等体上配置并使用的地址,这个地址是本地对等体路由器在其上配置TCP邻居并与远端对等体建立连接时采用的地址。


1 选择权重大的,从其它学来的路由默认是0
2 选择本地优先级,默认都是100 (用于AS内部)
3 优先选择自己加到BGE表中路由,之后才是从别的学来的路由 当前通告的路由下一跳为 0.0.0.0
4 选择经过AS最少的路由
5 选择路由起源, i 或? IGP<EGP<?
6 WED最小的,注意配置 BGP always-compare-med 否则只在AS相同路由之间比较
7 外部EBGP优先IEGP
8 如同步被关,选择IGP代价最小的
9 对于EBGP路由选择最老的
10 BGP路由ID最小的
11 IP地址最小的