bgp路由协议的配置与深入讲解(通过实例教大家判别BGP最优路由选路原则)

最近在遇到个路由选路问题,So,来温故下BGP的13条选路原则,结合实际应用来判定为何它是最优的选路?

网络拓扑如图:

bgp路由协议的配置与深入讲解(通过实例教大家判别BGP最优路由选路原则)(1)

在xs-PE查vrf TEST_12345的路由,存在三条路径,但是第二条最优的加到路由表中

RP/0/RSP0/CPU0:XS-ASR9010-01#show bgp vpnv4 unicast vrf TEST_12345 10.0.1.0

Wed May 6 21:16:03.200 BeiJing

BGP routing table entry for 10.0.1.0/25, Route Distinguisher: 100000:1

Versions:

Process bRIB/RIB SendTblVer

Speaker 7230065 7230065

Last Modified: Apr 10 10:25:27.999 for 4y03w

Paths: (3 available, best #2)

Not advertised to any peer

Path #1: Received by speaker 0

Not advertised to any peer

Local

172.16.1.253 (metric 120) from 192.168.8.110 (172.16.1.253)

Received Label 32277

Origin incomplete, metric 1, localpref 100, valid, internal, import-candidate, imported

Received Path ID 0, Local Path ID 0, version 0

Extended community: OSPF route-type:0:5:0x1 OSPF router-id:172.16.1.253 RT:100000:1

Originator: 172.16.1.253, Cluster list: 192.168.8.110

Source AFI: VPNv4 Unicast, Source VRF: TEST_12345, Source Route Distinguisher: 100000:1

Path #2: Received by speaker 0 //为何是这条路由最优?

Not advertised to any peer

Local

172.16.1.252 (metric 100) from 192.168.1.210 (172.16.1.252)

Received Label 24861

Origin incomplete, metric 1, localpref 100, valid, internal, best, group-best, import-candidate, imported

Received Path ID 0, Local Path ID 1, version 7230065

Extended community: OSPF route-type:0:5:0x1 OSPF router-id:172.16.1.252 RT:100000:1

Originator: 172.16.1.252, Cluster list: 192.168.1.210

Source AFI: VPNv4 Unicast, Source VRF: TEST_12345, Source Route Distinguisher: 100000:1

Path #3: Received by speaker 0

Not advertised to any peer

Local

172.16.1.252 (metric 100) from 192.168.2.239 (172.16.1.252)

Received Label 24861

Origin incomplete, metric 1, localpref 100, valid, internal, import-candidate, imported

Received Path ID 0, Local Path ID 0, version 0

Extended community: OSPF route-type:0:5:0x1 OSPF router-id:172.16.1.252 RT:100000:1

Originator: 172.16.1.252, Cluster list: 192.168.2.239

Source AFI: VPNv4 Unicast, Source VRF: TEST_12345, Source Route Distinguisher: 100000:1

选择best最优路由加载到路由表中:

RP/0/RSP0/CPU0:xs-ASR9010-01#show route vrf TEST_12345 10.0.1.0

Wed May 20 20:00:42.884 BeiJing

Routing entry for 10.0.1.0/25

Known via "bgp 64xxx", distance 200, metric 1, type internal

Installed May 14 01:04:56.878 for 6d18h

Routing Descriptor Blocks

172.16.1.252, from 192.168.1.210

Nexthop in Vrf: "default", Table: "default", IPv4 Unicast, Table Id: 0xe0000000

Route metric is 1

No advertising protos.

思科路由器bgp路由选路规则是按照以下13条件规则逐条去对比,直到选出最优路径

1.Prefer highest weight (local to router).

首选权重最高的路由<权重是一种cisco专有的属性,只用于当前路由器>

在本案例中,不涉及,因为路由是从远端发过来的。

2.Prefer highest local preference (global within AS).

本地优先级最高的路由<本地优先级用于AS内部>

这条也不用比,因为localpref都是100。

3.Prefer route originated by the local router (next hop = 0.0.0.0).

当前路由器通告的路由<bgp表中,当前路由器产生的路由的下一跳为0.0.0.0>

在本案例中,不涉及,因为路由是从远端发过来的,不是起源于本地。

4.Prefer shortest AS path.

AS路径最短的路由

因为在一个as中,as是一样的,这条忽略。

5.Prefer lowest origin code (IGP < EGP < incomplete).

比较Origin属性<IGP优先于EGP优先Incomplete>(i>e)

Origin属性都是imcomplete,这条也不用比较

6.Prefer lowest MED (exchanged between autonomous systems).

MED最小者<默认不比较来自不同AS路由的MED值,可通过bgp always-compare-med对比不同AS的med>

此案例中path#2和path#3是100,path#3是120,优选ptah#2和path#3,然后又在path#2和path#3中重复上面的五条优选规则去优选。

7.Prefer EBGP path over IBGP path.

外部路径(EBGP)优先于内部路径(IBGP)

因为都是ibgp路由,没有可比性。

8.Prefer the path through the closest IGP neighbor

选择经过最近的IGP邻居的路径<这意味着路由器首选AS中最短的内部路径-最短的前往BGP下一跳的路径)--IBGP

在此案例中received path和local path都是0没有可比性。

9.balance traffic

如果配置了maximum-path, 会安装多条路由到路由表<但是BGP继续比,只有一个打上>

此案例中bgp没有配置maximum-path,可以忽略。

10.Prefer oldest route for EBGP paths.

因为都是外部路径,选最先收到的(最旧的)<目的是减少抖动>。

在此案例中,path#1,和path#3的version id都为0,只有path#2 的数值最大,故选path#2,version表示的是生存的时间,数值越大,证明路由保留越长

11.Prefer the path with the lowest neighbor BGP router ID.

首选来自最低路由ID的BGP路由器的路由。

12.Prefer shortest cluster list

具有最低群集列表长度的路径。

13.Prefer the path with the lowest neighbor IP address.

最低邻居地址的路径 (比邻居的IP地址大小)。

综上,大家在没有看分析的前提下,可以一眼看哪条属性起作用了吗?

【笔者为网络工程师,工作多年,希望把自己的经验分享给大家,觉得有用的,可以关注、点赞、转发,如有相同或者不同观点,欢迎积极评论,谢谢!】

【对计算机网络技术感兴趣的,不妨跟着我从基础开始学习。基础专栏详见我的专栏-《深入解析OSI七层网络模型》,一起温故下基础,别有一番风味哈】

,

免责声明:本文仅代表文章作者的个人观点,与本站无关。其原创性、真实性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容文字的真实性、完整性和原创性本站不作任何保证或承诺,请读者仅作参考,并自行核实相关内容。文章投诉邮箱:anhduc.ph@yahoo.com

    分享
    投诉
    首页