Skip to main content

CISCO:BGP Best Path Selection Algorithm

·2 mins
Rs
Rory Xing
Author
Rory Xing
Step by step the ladder is ascended
Table of Contents

本文介绍一下思科 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.



Comments