CISCO:BGP Best Path Selection Algorithm

本文介绍一下思科BGP的13条选路原则。
XR:show bgp ipv4 unicast x.x.x.x/x bestpath-compare

Weight(越大越好)

思科的专有属性,优选值高的路径,而且本地本地有效。

Local Preference (越大越好)

默认情况下,从iBGP学来的路由local preference是100,解决本AS域出口路由选择。他不会把此参数传递给EBGP的邻居,优选值高的。

Originated

优选从本路由器使发的路由,包括本地network,重分发和或IGP已有的路由,有BGP配置的聚合地址也包括在内。
查看BGP路由表时可以看到有时路由前面带了一个“r”,说明在IGP中已经存在此路由了。
优先级为:default-originate > default-information-originate > network > redistribute > aggregate-address

AS Path(越短越好)

As-path最短的优选。

介绍一些命令:

as-path-loopcheck out disable
默认XR设备会check peer AS是否在AS-PATH中,如果在就不发, 使用“ as-path-loopcheck out disable ”取消这个feature。
(标准是会发,Peer 不收)

Origin( I>E )

IGP>EGP>Incomplete

MED (越小越好)

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是默认开启的。

EBGP>IBGP

EBGP > confederation > IBGP

IGP cost for next-hop (越小越好)

优选对BGP下一跳具有最低IGP度量值的路径。

Multiple paths

Prefer the path that was received first

BGP Router ID (越小越好)

如果路径包含RR属性,在选择时,用ORIGINATOR_ID来替代router id。

Cluster-ID (越小越好)

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

Peer Adress (越小越好)

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

BGP相关命令

ibgp policy out enforce-modifications
//To allow an outbound route policy for an internal BGP (iBGP) peer to modify all BGP route attributes, only when an iBGP route is sent to another iBGP peer (only on route-reflectors), use the ibgp policy out enforce-modifications command in router configuration mode. To disable this feature, use the no form of this command.
           

2 comments

Comments feed for this article

  1. Linux’s avatar

    Hi Xu,

    1. Cost pre-bestpath (small best )
    2. Weight (Lager best)
    3. Local-preference (Lager best)
    4. Local Org
    5. Aigp (Small best)
    6. AS-path
    7. Org Code
    8. MED (Small best)
    9. EBGP > IBGP
    10. 最近的IGP下一跳
    11. Cost IGP(Samll Best)
    12. Best old route
    13. Cluster-List
    14. RID
    15. Neighbor address.

    Reply

  2. xuxing’s avatar

    route-policy SET_WEIGHT
    if destination in STATIC then
    set weight 40000
    else
    pass
    endif
    end-policy

    Reply

Reply

Your email address will not be published. Required fields are marked *