CCIE SP — BGP 13条选路原则

If the next hop is unreachable, do not consider it.
如果下一跳不可达,是不会参加选举的!

Weight

Prefer the path that has the largest weight.
思科的专有属性,优选值高的路径,而且本地本地有效;

PS:Juniper没有这个概念;思科默认32768;华为对应的是PrefVal,默认是0;H3C类似华为是PrefVal,但默认是32768;

如下当两个设备同时发默认路由,默认DC优选h3c发的,但如果DC想优选huawei设备发来的默认路由(故障时才使用h3c的默认路由),那么就需要在h3c收到这条默认路由后把PrefVal 改成32768,让其bypass这个选路规则,用后面的规则如LP优选huawei发的:

Local Preference

If the routes have the same weight, use the route with the highest local preference. The local preference attribute only is local to the autonomous system and does not get passed to EBGP neighbors. The higher the local preference, the more preferred the route is.
默认情况下,从EBGP学来的路由local preference是100,解决本AS域出口路由选择。他不会把此参数传递给EBGP的邻居,优选值高的;

Originated

If the routes have the same local preference, prefer the route that was originated by BGP on this router.
优选从本路由器使发的路由,包括本地network,重分发和或IGP已有的路由,有BGP配置的聚合地址也包括在内。查看BGP路由表时可以看到有时路由前面带了一个“r”,说明在IGP中已经存在此路由了;

优先级为:default-originate > default-information-originate > network > redistribute > aggregate-address

AS Path

If no route was originated, prefer the route with the shortest AS path.

Origin Code

If all paths are of the same AS length, prefer the route with lowest origin code (IGP < EGP < INCOMPLETE).
EGP是指那种老的协议,现在已经不再用了;

MED

If the origin codes are the same, prefer the path with the lowest Multi Exit Discriminator (MED 范围0到4,294,967,295). The MED is exchanged between ASs; however, the MED that comes into an AS does not leave. The MED can be used to influence the outbound decision of another AS. The lower the MED, the more preferred the route.
而且MED只在相同AS的情况下才对比,默认情况下不同AS的路由是不对比MED的。解决本AS域的入口路由选择。如果配置了“bgp always-compare-med”,那么所有路径都会比较MED,而不考虑是否来自同一个AS,如果用了这条命令,那么为了防止环路,建议整个AS中都应用。另外一个跟MED相关的命令是“bgp deterministic-med”,如果路由从多个路径学来,他会把同AS的划为一个group,同group的对比MED,然后胜出者再进行对比。关于这两个命令可以看链接:How the bgp deterministic-med Command Differs from the bgp always-compare-med Command在IOS平台默认不开启derministic-med,而IOX是默认开启的

另外MED的通告规则:

  1. ebgp在发布从ibgp学来的路由时,会清除MED的值。如果想强制通告,可以在宣告的路由上使用“set metric-type internal”;
  2. 如果使用network或redistribute命令将来自IGP的路由通告到BGP中,那么BGP的MED是从IGP的metric导出的;
  3. 如果是aggregate-address命令注入路由,BGP的MED不被设置;

External paths over internal paths

If the MEDs are the same, prefer external paths over internal paths.
EBGP > confederation > IBGP

The path through the closest IGP neighbor

If they are still the same, prefer the path through the closest IGP neighbor.
优选对BGP下一跳具有最低IGP度量值的路径。

2013-5-10更新:8.5 – Extcommunity Cost
当用户配置了Extcommunity Cost,那么BGP选路就对比此参数,COST越低越优选。可以用“bgp bestpath cost-community ignore”命令ignore此功能;更多详细的信息,可以看下面的BLOG:
Influencing BGP path selection with the extcommunity cost attribute

Multiple paths

Determine if multiple paths require installation in the routing table for BGP Multipath.
如果配置了“maximum-path N”。而且从同一个AS的对等体收到多条外部路由,侧可以将N条路由加入到路由表中,使EBGP负载分担。N最大不能超过6;没有配置此命令时,默认是1。可以通过“sh ip bgp X.X.X.X”来查看最优的路径,这个最优是按接收时间来定的。在这条最优路由转发到内部对等体之前,需要执行与“next-hop-self”一样的功能。

2017-5-4更新:multipath eBGP|iBGP|eiBGP
默认什么都不加就是最开始解释的,针对eBGP的负载均衡;iBGP的选项类似,只针对iBGP做负载;但eiBGP有些特殊,他可以让ebgp和ibgp的路由负载,并且忽略BGP下一跳IGP的metric,如下CCO文档:

“Similarly, multiple paths are installed for internal peers that are equal based on the BGP best-path algorithm. The IGP metric to the BGP next-hop is the same as the best-path IGP metric unless the router is configured for unequal cost iBGP multipath or eiBGP multipath.”
http://www.cisco.com/c/en/us/td/docs/routers/asr9000/software/routing/command/reference/rrasr9kbgp.html#wp1361967

另外就是一定要注意的,如果开启的eiBGP负载均衡,那么很容易产生环路,所以一定要仔细考虑好现网中的路由,在进行部署

Prefer the path that was received first

When both paths are external, prefer the path that was received first (the oldest one)
这可以使路由抖动重新收敛的影响降到最低,因为新的路径不会取代老的路径。

BGP Router ID

If they are still the same, prefer the path with the lowest BGP Router ID.
如果路径包含RR属性,在选择时,用ORIGINATOR_ID来替代router id。

Cluster-ID

如果从路由反射器学到,优选最小Cluster-ID的路由,如果router id相同,那么优选CLUSTER_LIST长度最短的路径。

Peer Adress

优选具有最低对等体地址的路由。

暂时更新到这,里面有解释的基本上是我常遇到的!
以后如有新的理解及内容,会不定期更新!

此文章于2012-11-12更新:

此文章于2012-12-01更新:

更新MED的相关信息

本文出自 Frank's Blog

版权声明:


本文链接:CCIE SP — BGP 13条选路原则
版权声明:本文为原创文章,仅代表个人观点,版权归 Frank Zhao 所有,转载时请注明本文出处及文章链接
你可以留言,或者trackback 从你的网站

No Responses to “CCIE SP — BGP 13条选路原则”

  1. kobegirl说道:

    Hi Yong哥,

    第10条,如果配置了bestpath compare router-id, 则比较Router ID会提前到第10条 最老路由前面去哈,防止路由有故障切走后,故障恢复切不回来。。。测试的时候发现地:)

  2. frank说道:

    Yes, you are right!
    Actually, I had attached a good link to my blog that include more judgment condition in 2012~ Please check the last part of the blog. Now I download the PDF version and upload to blog.

留言哦

blonde teen swallows load.xxx videos