BGP13种选路原则

 

作者简介:大家好,我是Asshebaby,热爱网工,有网络方面不懂的可以加我一起探讨

 :1125069544

当前专栏: 网络HCIP内容

特色专栏: 常见的项目配置

本文内容:BGP的基本配置以及使用介绍       

实验拓扑:

目录

第一种:

1,丢弃下一跳不可达的路由

2优选Local-Preference属性值最大的路由

3 本地始发路由优于从对等体学习到的路由

1、在AR3的lo66接口上配置该地址,并引入BGP中,查看AR3的BGP路由表信息。(测试import>从对等体学习到的)

2、测试Network>import>从对等体学习到的路

[AR3-bgp]undo network 66.66.66.66 32

3、测试自动聚合优于Network

4、测试手动聚合优于自动聚合

4 优选AS_Path最短的路由

5 优选Origin属性最优的路由

6 优选MED属性值最小的路由

7 优选从EBGP学习到的路由

8 优选到Next-hop的IGP度量值最小的路由

9 优选Cluster_List最短的路由

10 优选Router_ID最小的路由

11 优选具有最小IP地址的对等体通告的路由


做之前先配置预配:

r1:
 

#
interface GigabitEthernet0/0/0
 ip address 10.1.12.1 255.255.255.0 
#
interface GigabitEthernet0/0/1
interface LoopBack0
 ip address 1.1.1.1 255.255.255.255 
#
interface LoopBack66
 ip address 66.66.66.66 255.255.255.255 
#
bgp 100
 router-id 1.1.1.1
 peer 10.1.12.2 as-number 200 
 #
 ipv4-family unicast
  undo synchronization
  network 0.0.0.0 
  network 66.0.0.0 
  network 66.66.66.66 255.255.255.255 
  peer 10.1.12.2 enable
#

r2:
 

#
interface GigabitEthernet0/0/0
 ip address 10.1.12.2 255.255.255.0 
#
interface GigabitEthernet0/0/1
 ip address 10.1.23.2 255.255.255.0 

#
interface LoopBack0
 ip address 2.2.2.2 255.255.255.255 
#
bgp 200
 router-id 2.2.2.2
 peer 3.3.3.3 as-number 200 
 peer 3.3.3.3 connect-interface LoopBack0
 peer 10.1.12.1 as-number 100 
 #
 ipv4-family unicast
  undo synchronization
  peer 3.3.3.3 enable
  peer 3.3.3.3 next-hop-local 
  peer 10.1.12.1 enable
#
ospf 1 router-id 2.2.2.2 
 area 0.0.0.0 
  network 2.2.2.2 0.0.0.0 
  network 10.1.23.2 0.0.0.0 
#

r3:

#
interface GigabitEthernet0/0/0
 ip address 10.1.23.3 255.255.255.0 
#
interface GigabitEthernet0/0/1
 ip address 10.1.34.3 255.255.255.0 

interface LoopBack0
 ip address 3.3.3.3 255.255.255.255 
#
interface LoopBack1
#
interface LoopBack66
 ip address 66.66.66.66 255.255.255.255 
#
bgp 200
 router-id 3.3.3.3
 peer 2.2.2.2 as-number 200 
 peer 2.2.2.2 connect-interface LoopBack0
 peer 4.4.4.4 as-number 200 
 peer 4.4.4.4 connect-interface LoopBack0
 #
 ipv4-family unicast
  undo synchronization
  peer 2.2.2.2 enable
  peer 4.4.4.4 enable
#
ospf 1 router-id 3.3.3.3 
 area 0.0.0.0 
  network 3.3.3.3 0.0.0.0 
  network 10.1.23.3 0.0.0.0 
  network 10.1.34.3 0.0.0.0 
#

r4:
 

#
interface GigabitEthernet0/0/0
 ip address 10.1.45.4 255.255.255.0 
#
interface GigabitEthernet0/0/1
 ip address 10.1.34.4 255.255.255.0 
#
interface GigabitEthernet0/0/2
#
interface NULL0
#
interface LoopBack0
 ip address 4.4.4.4 255.255.255.255 
#
bgp 200
 router-id 4.4.4.4
 peer 3.3.3.3 as-number 200 
 peer 3.3.3.3 connect-interface LoopBack0
 peer 10.1.45.5 as-number 300 
 #
 ipv4-family unicast
  undo synchronization
  peer 3.3.3.3 enable
  peer 3.3.3.3 next-hop-local 
  peer 10.1.45.5 enable
#
ospf 1 router-id 4.4.4.4 
 area 0.0.0.0 
  network 4.4.4.4 0.0.0.0 
  network 10.1.34.4 0.0.0.0 
#

r5:
 

#
interface GigabitEthernet0/0/0
 ip address 10.1.45.5 255.255.255.0 
#
interface GigabitEthernet0/0/1
#
interface GigabitEthernet0/0/2
#
interface NULL0
#
interface LoopBack0
 ip address 5.5.5.5 255.255.255.255 
#
interface LoopBack66
 ip address 66.66.66.66 255.255.255.255 
#
bgp 300
 router-id 5.5.5.5
 peer 10.1.45.4 as-number 200 
 #
 ipv4-family unicast
  undo synchronization
  network 66.66.66.66 255.255.255.255 
  peer 10.1.45.4 enable
#

第一种:

1,丢弃下一跳不可达的路由

测试方法:

  1. 将AR1和AR5上的loopback66接口地址宣告到BGP中。

进入r1上 network 66.66.66.66 32

2、预先已经在AR2和AR4上向AR3配置了peer 3.3.3.3 next-hop-local这条命令就是告诉其他对等体,我发给你们的路由,下一跳来找我,所以AR3上会有两条去往66.66.66.66/32的路由

<AR3>dis bgp routing-table

 BGP Local router ID is 3.3.3.3

 Status codes: * - valid, > - best, d - damped,

               h - history,  i - internal, s - suppressed, S - Stale

               Origin : i - IGP, e - EGP, ? - incomplete

 Total Number of Routes: 2

      Network            NextHop        MED        LocPrf    PrefVal Path/Ogn

 *>i  66.66.66.66/32     2.2.2.2         0          100        0      100i

 * i                     4.4.4.4         0          100        0      300i

<AR3>

在r3上看

可以看到,在默认情况下,BGP所有选路规则中前10条都无法比较出,直至匹配了Router_ID小的路由,所以选择了对等体2.2.2.2的路由,

而将4.4.4.4的路由标记为有效,但不是最优。

可以通过display bgp routing-table 66.66.66.66 32查看具体原因:(不是首选的Router_ID)

<AR3>dis bgp routing-table  66.66.66.66

 BGP local router ID : 3.3.3.3

 Local AS number : 200

 Paths:   2 available, 1 best, 1 select

 BGP routing table entry information of 66.66.66.66/32:

 From: 2.2.2.2 (2.2.2.2)

 Route Duration: 00h02m19s  

 Relay IP Nexthop: 10.1.23.2

 Relay IP Out-Interface: GigabitEthernet0/0/0

 Original nexthop: 2.2.2.2

 Qos information : 0x0

 AS-path 100, origin igp, MED 0, localpref 100, pref-val 0, valid, internal, bes

t, select, active, pre 255, IGP cost 1

 Not advertised to any peer yet

 BGP routing table entry information of 66.66.66.66/32:

 From: 4.4.4.4 (10.1.45.4)

 Route Duration: 00h09m34s  

 Relay IP Nexthop: 10.1.34.4

 Relay IP Out-Interface: GigabitEthernet0/0/1

 Original nexthop: 4.4.4.4

 Qos information : 0x0

 AS-path 300, origin igp, MED 0, localpref 100, pref-val 0, valid, internal, pre

 255, IGP cost 1, not preferred for router ID

 Not advertised to any peer yet

<AR3>

此时:去r2undo 掉next-hop-local 查看路由表的效果:

[AR2-bgp]undo peer 3.3.3.3 next-hop-local

配置上述命令后可能需要等待更新周期才能看到路有变化,可使用下列命令进行刷新:
refresh bgp internal export|import 或者 refresh bgp external export|import

[AR3]dis bgp routing-table

 BGP Local router ID is 3.3.3.3

 Status codes: * - valid, > - best, d - damped,

               h - history,  i - internal, s - suppressed, S - Stale

               Origin : i - IGP, e - EGP, ? - incomplete

 Total Number of Routes: 2

      Network            NextHop        MED        LocPrf    PrefVal Path/Ogn

 *>i  66.66.66.66/32     2.2.2.2         0          100        0      100i

 * i                     4.4.4.4         0          100        0      300i

[AR3]

可以看到,原来优选了对等体2.2.2.2的路由现在下一跳地址变为了10.1.12.1,因为路由器会将从EBGP学习到的路由信息原封不动的发送给其他对等体,而peer 3.3.3.3 next-hop-local这条命令就是告诉其他对等体,我发给你们的路由,下一跳来找我。所以对于AR3来说10.1.12.1是不可达的,所以将该条路由标记为无效也不是最优的路由。从而选择了对等体4.4.4.4发来的。

  1. 通过preferred-Value值最大的路由

在配置前回复默认状态,查看ar3路由器的路由表:

<AR3>dis bgp routing-table

 BGP Local router ID is 3.3.3.3

 Status codes: * - valid, > - best, d - damped,

               h - history,  i - internal, s - suppressed, S - Stale

               Origin : i - IGP, e - EGP, ? - incomplete

 Total Number of Routes: 2

      Network            NextHop        MED        LocPrf    PrefVal Path/Ogn

 *>i  66.66.66.66/32     2.2.2.2         0          100        0      100i

 * i                     4.4.4.4         0          100        0      300i

测试方法:

在R3上面配置route-policy

#

route-policy PrefVal permit node 10

 apply preferred-value 100

#

在BGP200里面运用该策略:

  peer 4.4.4.4 route-policy PrefVal import

<AR3>

dis route-policy PrefVal

Route-policy : PrefVal

  permit : 10 (matched counts: 2)

    Apply clauses :

      apply preferred-value 100

[AR3]

此时查看路由表

[AR3]dis route-policy PrefVal

Route-policy : PrefVal

  permit : 10 (matched counts: 2)

    Apply clauses :

      apply preferred-value 100 //该路由策略的意思是直接将来自4.4.4.4对等体的所有路由的preferred-value属性值都标记为100

[AR3]dis bgp rou

[AR3]dis bgp routing-table

 BGP Local router ID is 3.3.3.3

 Status codes: * - valid, > - best, d - damped,

               h - history,  i - internal, s - suppressed, S - Stale

               Origin : i - IGP, e - EGP, ? - incomplete

 Total Number of Routes: 2

      Network            NextHop        MED        LocPrf    PrefVal Path/Ogn

 *>i  66.66.66.66/32     4.4.4.4         0          100        100    300i

 * i                     2.2.2.2         0          100        0      100i

[AR3]

可以看到,来自对等体4.4.4.4的路由的PrefVal属性值被标记为100,且被选为最优路由。
查看具体原因:

[AR3]dis bgp routing-table 66.66.66.66

 BGP local router ID : 3.3.3.3

 Local AS number : 200

 Paths:   2 available, 1 best, 1 select

 BGP routing table entry information of 66.66.66.66/32:

 From: 4.4.4.4 (10.1.45.4)

 Route Duration: 00h03m51s  

 Relay IP Nexthop: 10.1.34.4

 Relay IP Out-Interface: GigabitEthernet0/0/1

 Original nexthop: 4.4.4.4

 Qos information : 0x0

 AS-path 300, origin igp, MED 0, localpref 100, pref-val 100, valid, internal, best, select, active, pre 255, IGP cost 1

 Not advertised to any peer yet

 BGP routing table entry information of 66.66.66.66/32:

 From: 2.2.2.2 (2.2.2.2)

 Route Duration: 00h13m54s  

 Relay IP Nexthop: 10.1.23.2

 Relay IP Out-Interface: GigabitEthernet0/0/0

 Original nexthop: 2.2.2.2

 Qos information : 0x0

 AS-path 100, origin igp, MED 0, localpref 100, pref-val 0, valid, internal, pre

 255, IGP cost 1, not preferred for PreVal

 Not advertised to any peer yet

[AR3]

针对来自对等体2.2.2.2的路由,显示:PreVal不是最优的。

2优选Local-Preference属性值最大的路由

先恢复初始配置。
AR3的初始BGP路由信息:

[AR3-bgp]dis bgp routing-table

 BGP Local router ID is 3.3.3.3

 Status codes: * - valid, > - best, d - damped,

               h - history,  i - internal, s - suppressed, S - Stale

               Origin : i - IGP, e - EGP, ? - incomplete

 Total Number of Routes: 2

      Network            NextHop        MED        LocPrf    PrefVal Path/Ogn

 *>i  66.66.66.66/32     2.2.2.2         0          100        0      100i

 * i                     4.4.4.4         0          100        0      300i

[AR3-bgp]

可以看到默认的locPre为100

测试方法:

1、在AR3上对来自对等体4.4.4.4的路由,将其LocPrf调整为101。

#

route-policy LocPrf permit node 10

 apply local-preference 101

#

peer  4.4.4.4 route-policy LocPrf  import

查看路由策略

AR3-bgp]dis route-policy LocPrf

Route-policy : LocPrf

  permit : 10 (matched counts: 1)

    Apply clauses :

      apply local-preference 101

查看路由表:

[AR3-bgp]dis bgp routing-table

 BGP Local router ID is 3.3.3.3

 Status codes: * - valid, > - best, d - damped,

               h - history,  i - internal, s - suppressed, S - Stale

               Origin : i - IGP, e - EGP, ? - incomplete

 Total Number of Routes: 2

      Network            NextHop        MED        LocPrf    PrefVal Path/Ogn

 *>i  66.66.66.66/32     4.4.4.4         0          101        0      300i

 * i                     2.2.2.2         0          100        0      100i

可以看到,对等体4.4.4.4的路由的LocPrf属性值被标记为101,并成为最优路由。
查看具体原因:

[AR3-bgp]dis bgp routing-table  66.66.66.66

 BGP local router ID : 3.3.3.3

 Local AS number : 200

 Paths:   2 available, 1 best, 1 select

 BGP routing table entry information of 66.66.66.66/32:

 From: 4.4.4.4 (10.1.45.4)

 Route Duration: 00h02m30s  

 Relay IP Nexthop: 10.1.34.4

 Relay IP Out-Interface: GigabitEthernet0/0/1

 Original nexthop: 4.4.4.4

 Qos information : 0x0

 AS-path 300, origin igp, MED 0, localpref 101, pref-val 0, valid, internal, best, select, active, pre 255, IGP cost 1

 Not advertised to any peer yet

 BGP routing table entry information of 66.66.66.66/32:

 From: 2.2.2.2 (2.2.2.2)

 Route Duration: 00h26m41s  

 Relay IP Nexthop: 10.1.23.2

 Relay IP Out-Interface: GigabitEthernet0/0/0

 Original nexthop: 2.2.2.2

 Qos information : 0x0

 AS-path 100, origin igp, MED 0, localpref 100, pref-val 0, valid, internal, pre

 255, IGP cost 1, not preferred for Local_Pref //显示不是最优的路由针对对等体2.2.2.2的路由,显示不是最优的Local_Pref。

 Not advertised to any peer yet

[AR3-bgp]

3 本地始发路由优于从对等体学习到的路由

本地始发具体规则为:
手动聚合>自动聚会>Network>import>从对等体学习到的路由
为了验证上述选路规则,本实验将从后往前匹配条件进行验证。
在初始情况下,AR3上的BGP路由表信息如下:

<AR3>dis bgp routing-table

 BGP Local router ID is 3.3.3.3

 Status codes: * - valid, > - best, d - damped,

               h - history,  i - internal, s - suppressed, S - Stale

               Origin : i - IGP, e - EGP, ? - incomplete

 Total Number of Routes: 2

      Network            NextHop        MED        LocPrf    PrefVal Path/Ogn

 *>i  66.66.66.66/32     2.2.2.2         0          100        0      100i

 * i                     4.4.4.4         0          100        0      300i

<AR3>

可以从NextHop信息看到,去往66.66.66.66/32的路由是来自不同对等体的

1、在AR3的lo66接口上配置该地址,并引入BGP中,查看AR3的BGP路由表信息。(测试import>从对等体学习到的)

相关命令如下:

#

ip ip-prefix 66 permit 66.66.66.66 32

route-policy 66 permit node 10

 if-match ip-prefix 66

 apply as-path 200 additive

 apply local-preference 100

#import-route direct route-policy 66

[AR3-route-policy]dis bgp routing-table

 BGP Local router ID is 3.3.3.3

 Status codes: * - valid, > - best, d - damped,

               h - history,  i - internal, s - suppressed, S - Stale

               Origin : i - IGP, e - EGP, ? - incomplete

 Total Number of Routes: 1

      Network            NextHop        MED        LocPrf    PrefVal Path/Ogn

 *>   66.66.66.66/32     0.0.0.0         0          100        0      200?

发现是直接从本地学到的但是还有两条没看见了他这里只显示了最优的路由:

但是可以从以下看见:

AR3-route-policy]dis bgp routing-table  66.66.66.66

 BGP local router ID : 3.3.3.3

 Local AS number : 200

 Paths:   1 available, 1 best, 1 select

 BGP routing table entry information of 66.66.66.66/32:

 Imported route.

 From: 0.0.0.0 (0.0.0.0)

 Route Duration: 00h01m04s  

 Direct Out-interface: InLoopBack0

 Original nexthop: 127.0.0.1

 Qos information : 0x0

 AS-path 200, origin incomplete, MED 0, localpref 100, pref-val 0, valid, local,best, select, pre 0

 Advertised to such 2 peers:

    2.2.2.2

4.4.4.4

2、测试Network>import>从对等体学习到的路

当你在r3上

Bgp 200

network 66.66.66.66 32

你又会发现他会优先选择那个network的:

[AR3-bgp]dis bgp routing-table

 BGP Local router ID is 3.3.3.3

 Status codes: * - valid, > - best, d - damped,

               h - history,  i - internal, s - suppressed, S - Stale

               Origin : i - IGP, e - EGP, ? - incomplete

 Total Number of Routes: 2

      Network            NextHop        MED        LocPrf    PrefVal Path/Ogn

 *>   66.66.66.66/32     0.0.0.0         0                     0      i

 *                       0.0.0.0         0          100        0      200?

下面那条是你direct导入的。

[AR3-bgp]dis bgp routing-table  66.66.66.66 32

 BGP local router ID : 3.3.3.3

 Local AS number : 200

 Paths:   2 available, 1 best, 1 select

 BGP routing table entry information of 66.66.66.66/32:

 Network route.

 From: 0.0.0.0 (0.0.0.0)

 Route Duration: 00h02m12s  

 Direct Out-interface: InLoopBack0

 Original nexthop: 127.0.0.1

 Qos information : 0x0

 AS-path Nil, origin igp, MED 0, pref-val 0, valid, local, best, select, pre 0

 Advertised to such 2 peers:

    2.2.2.2

    4.4.4.4

 BGP routing table entry information of 66.66.66.66/32:

 Imported route.

 From: 0.0.0.0 (0.0.0.0)

 Route Duration: 00h04m12s  

 Direct Out-interface: InLoopBack0

 Original nexthop: 127.0.0.1

 Qos information : 0x0

 AS-path 200, origin incomplete, MED 0, localpref 100, pref-val 0, valid, local,

 pre 0, not preferred for route type

 Not advertised to any peer yet

[AR3-bgp]

[AR3-bgp]undo network 66.66.66.66 32

3、测试自动聚合优于Network

为了测试更为直观,现在改为使用88.0.0.0/8 的路由条目作为测试,AR2、AR4上配置一条静态路由

ip route-static 88.0.0.0 8 NULL 0

Bgp 200

Import static

,并引入BGP中。

在AR3BGP中宣告一条88.0.0.0 8的路由,同时配置两条静态路由:

ip route-static 88.0.0.0 255.0.0.0 NULL0

ip route-static 88.128.0.0 255.128.0.0 NULL0

Bgp 200

Import static

查看效果

[AR3]dis bgp routing-table

 BGP Local router ID is 3.3.3.3

 Status codes: * - valid, > - best, d - damped,

               h - history,  i - internal, s - suppressed, S - Stale

               Origin : i - IGP, e - EGP, ? - incomplete

 Total Number of Routes: 5

      Network            NextHop        MED        LocPrf    PrefVal Path/Ogn

 *>   66.66.66.66/32     0.0.0.0         0          100        0      200?

 *>   88.0.0.0           0.0.0.0         0                     0      ?

 * i                     2.2.2.2         0          100        0      ?

 * i                     4.4.4.4         0          100        0      ?

 *>   88.128.0.0/9       0.0.0.0         0                     0      ?

[AR3]

启用自动聚合功能:

[AR3-bgp]summary automatic

看效果:

[AR3-bgp]dis bgp routing-table

 BGP Local router ID is 3.3.3.3

 Status codes: * - valid, > - best, d - damped,

               h - history,  i - internal, s - suppressed, S - Stale

               Origin : i - IGP, e - EGP, ? - incomplete

 Total Number of Routes: 7

      Network            NextHop        MED        LocPrf    PrefVal Path/Ogn

 *>i  66.66.66.66/32     2.2.2.2         0          100        0      100i

 * i                     4.4.4.4         0          100        0      300i

 *>   88.0.0.0           127.0.0.1                             0      ?

 *                       0.0.0.0         0                     0      ?

 * i                     2.2.2.2         0          100        0      ?

 * i                     4.4.4.4         0          100        0      ?

 s>   88.128.0.0/9       0.0.0.0         0                     0      ?

[AR3-bgp]

此时静态路88.128.0.0/9聚合后会被抑制,变为无效路由,查看具体路由信息:

[AR3-bgp]dis bgp routing-table  88.0.0.0

 BGP local router ID : 3.3.3.3

 Local AS number : 200

 Paths:   4 available, 1 best, 1 select

 BGP routing table entry information of 88.0.0.0/8:

 Summary automatic route

 Route Duration: 00h01m25s  

 Direct Out-interface: NULL0

 Original nexthop: 127.0.0.1

 Qos information : 0x0

 AS-path Nil, origin incomplete, pref-val 0, valid, local, best, select, pre 255

 Aggregator: AS 200, Aggregator ID 3.3.3.3

 Advertised to such 2 peers:

    2.2.2.2

    4.4.4.4

 BGP routing table entry information of 88.0.0.0/8:

 Imported route.      因为前面我们是采用import路由引入进去bgp的所有也可以看出自动聚合是高于import的   同理network也是一样的。

 From: 0.0.0.0 (0.0.0.0)

 Route Duration: 00h02m03s  

 Direct Out-interface: NULL0

 Original nexthop: 0.0.0.0

 Qos information : 0x0

 AS-path Nil, origin incomplete, MED 0, pref-val 0, valid, local, pre 60, not pr

eferred for route type

 Not advertised to any peer yet

 BGP routing table entry information of 88.0.0.0/8:

 From: 2.2.2.2 (2.2.2.2)

 Route Duration: 00h05m15s  

 Relay IP Nexthop: 10.1.23.2

 Relay IP Out-Interface: GigabitEthernet0/0/0

 Original nexthop: 2.2.2.2

 Qos information : 0x0

 AS-path Nil, origin incomplete, MED 0, localpref 100, pref-val 0, valid, intern

al, pre 255, IGP cost 1, not preferred for route type

 Not advertised to any peer yet

 BGP routing table entry information of 88.0.0.0/8:

 From: 4.4.4.4 (4.4.4.4)

 Route Duration: 00h05m06s  

 Relay IP Nexthop: 10.1.34.4

 Relay IP Out-Interface: GigabitEthernet0/0/1

 Original nexthop: 4.4.4.4

 Qos information : 0x0

 AS-path Nil, origin incomplete, MED 0, localpref 100, pref-val 0, valid, intern

al, pre 255, IGP cost 1, not preferred for router ID

 Not advertised to any peer yet

可以看到,最终选了自动聚合的路由,而Network不是最优的路由类型。

4、测试手动聚合优于自动聚合

保持前面配置不变,在AR3的BGP视图中执行以下命令:

[AR3-bgp]aggregate 88.0.0.0 8 detail-suppressed

1

观察AR3的BGP路由表信息:

[AR3]dis bgp routing-table

 BGP Local router ID is 3.3.3.3

 Status codes: * - valid, > - best, d - damped,

               h - history,  i - internal, s - suppressed, S - Stale

               Origin : i - IGP, e - EGP, ? - incomplete

 Total Number of Routes: 8

      Network            NextHop        MED        LocPrf    PrefVal Path/Ogn

 *>i  66.66.66.66/32     2.2.2.2         0          100        0      100i

 * i                     4.4.4.4         0          100        0      300i

 *>   88.0.0.0           127.0.0.1                             0      ?

 *                       127.0.0.1                             0      ?

 *                       0.0.0.0         0                     0      ?

 * i                     2.2.2.2         0          100        0      ?

 * i                     4.4.4.4         0          100        0      ?

 s>   88.128.0.0/9       0.0.0.0         0                     0      ?

[AR3]

发现多出几条127.0.0.1的路由:

看详细信息:

[AR3]dis bgp routing-table 88.0.0.0

 BGP local router ID : 3.3.3.3

 Local AS number : 200

 Paths:   5 available, 1 best, 1 select

 BGP routing table entry information of 88.0.0.0/8:

 Aggregated route.                  手动聚合最优先

 Route Duration: 00h01m45s  

 Direct Out-interface: NULL0

 Original nexthop: 127.0.0.1

 Qos information : 0x0

 AS-path Nil, origin incomplete, pref-val 0, valid, local, best, select, pre 255

 Aggregator: AS 200, Aggregator ID 3.3.3.3, Atomic-aggregate

 Advertised to such 2 peers:

    2.2.2.2

    4.4.4.4

 BGP routing table entry information of 88.0.0.0/8:

 Summary automatic route             自动聚合

 Route Duration: 00h10m16s  

 Direct Out-interface: NULL0

 Original nexthop: 127.0.0.1

 Qos information : 0x0

 AS-path Nil, origin incomplete, pref-val 0, valid, local, pre 255, not preferre

d for route type

 Aggregator: AS 200, Aggregator ID 3.3.3.3

 Not advertised to any peer yet

 BGP routing table entry information of 88.0.0.0/8:

 Network route.                  为此我在加上一条network的路由证明

 From: 0.0.0.0 (0.0.0.0)

 Route Duration: 00h06m04s  

 Direct Out-interface: NULL0

 Original nexthop: 0.0.0.0

 Qos information : 0x0

 AS-path Nil, origin igp, MED 0, pref-val 0, valid, local, pre 60, not preferred

 for route type

 Not advertised to any peer yet

 BGP routing table entry information of 88.0.0.0/8:

 Imported route.                        Network --import

 From: 0.0.0.0 (0.0.0.0)

 Route Duration: 00h10m54s  

 Direct Out-interface: NULL0

 Original nexthop: 0.0.0.0

 Qos information : 0x0

 AS-path Nil, origin incomplete, MED 0, pref-val 0, valid, local, pre 60, not pr

eferred for route type

 Not advertised to any peer yet

可以看到最优的是手动聚合的路由-----自动聚合路由---netw聚合-import-外部

4 优选AS_Path最短的路由

恢复初始配置,查看AR3 BGP 路由表:

<AR3>dis bgp routing-table

 BGP Local router ID is 3.3.3.3

 Status codes: * - valid, > - best, d - damped,

               h - history,  i - internal, s - suppressed, S - Stale

               Origin : i - IGP, e - EGP, ? - incomplete

 Total Number of Routes: 2

      Network            NextHop        MED        LocPrf    PrefVal Path/Ogn

 *>i  66.66.66.66/32     2.2.2.2         0          100        0      100i

 * i                     4.4.4.4         0          100        0      300i

测试方法:

对来自对等体2.2.2.2的路由,为其添加一个Path属性值100,使其成为次优路由:

#

route-policy 66 permit node 10

 if-match ip-prefix 66

 apply as-path 100 additive

#

ip ip-prefix 66 index 10 permit 66.66.66.66 32

  peer 2.2.2.2 route-policy 66 import

<AR3>dis bgp routing-table

 BGP Local router ID is 3.3.3.3

 Status codes: * - valid, > - best, d - damped,

               h - history,  i - internal, s - suppressed, S - Stale

               Origin : i - IGP, e - EGP, ? - incomplete

 Total Number of Routes: 2

      Network            NextHop        MED        LocPrf    PrefVal Path/Ogn

 *>i  66.66.66.66/32     4.4.4.4         0          100        0      300i

 * i                     2.2.2.2         0          100        0      100 100i

<AR3>

<AR3>dis bgp routing-table  66.66.66.66

 BGP local router ID : 3.3.3.3

 Local AS number : 200

 Paths:   2 available, 1 best, 1 select

 BGP routing table entry information of 66.66.66.66/32:

 From: 4.4.4.4 (4.4.4.4)

 Route Duration: 00h40m25s  

 Relay IP Nexthop: 10.1.34.4

 Relay IP Out-Interface: GigabitEthernet0/0/1

 Original nexthop: 4.4.4.4

 Qos information : 0x0

 AS-path 300, origin igp, MED 0, localpref 100, pref-val 0, valid, internal, best, select, pre 255, IGP cost 1

 Not advertised to any peer yet

 BGP routing table entry information of 66.66.66.66/32:

 From: 2.2.2.2 (2.2.2.2)

 Route Duration: 00h01m24s  

 Relay IP Nexthop: 10.1.23.2

 Relay IP Out-Interface: GigabitEthernet0/0/0

 Original nexthop: 2.2.2.2

 Qos information : 0x0

 AS-path 100 100, origin igp, MED 0, localpref 100, pref-val 0, valid, internal,

 pre 255, IGP cost 1, not preferred for AS-Path

 Not advertised to any peer yet

<AR3>

5 优选Origin属性最优的路由

恢复拓扑初始化配置,查看当前AR3的BGP路由表信息:

[AR3]dis bgp routing-table

 BGP Local router ID is 3.3.3.3

 Status codes: * - valid, > - best, d - damped,

               h - history,  i - internal, s - suppressed, S - Stale

               Origin : i - IGP, e - EGP, ? - incomplete

 Total Number of Routes: 2

      Network            NextHop        MED        LocPrf    PrefVal Path/Ogn

 *>i  66.66.66.66/32     2.2.2.2         0          100        0      100i

 * i                     4.4.4.4         0          100        0      300i

[AR3]

如上图所示,由于在 AR1、AR5上使用的是Network方式宣告的66.66.66.66/32的路由对应的Origin属性为i。

Origin属性相应关联:

i - IGP —> Network

e - EGP—> 该方式可以通过route-policy修改测试

? - incomplete—> import

i>e>?

测试方法:

1 将来自对等体2.2.2.2的路由使用路由策略将其Origin属性改为EGP。

#

route-policy 66 permit node 10

 apply origin egp 100

#

Bgp 200

  peer 2.2.2.2 route-policy 66 import

查看效果:

[AR3-bgp]dis bgp routing-table

 BGP Local router ID is 3.3.3.3

 Status codes: * - valid, > - best, d - damped,

               h - history,  i - internal, s - suppressed, S - Stale

               Origin : i - IGP, e - EGP, ? - incomplete

 Total Number of Routes: 2

      Network            NextHop        MED        LocPrf    PrefVal Path/Ogn

 *>i  66.66.66.66/32     4.4.4.4         0          100        0      300i

 * i                     2.2.2.2         0          100        0      100e

可以看到,此时对等体2.2.2.2的路由Origin属性改为了e,且变为了次优

[AR3-bgp]

详细信息:

[AR3-bgp]dis bgp routing-table  66.66.66.66

 BGP local router ID : 3.3.3.3

 Local AS number : 200

 Paths:   2 available, 1 best, 1 select

 BGP routing table entry information of 66.66.66.66/32:

 From: 4.4.4.4 (4.4.4.4)

 Route Duration: 00h49m43s  

 Relay IP Nexthop: 10.1.34.4

 Relay IP Out-Interface: GigabitEthernet0/0/1

 Original nexthop: 4.4.4.4

 Qos information : 0x0

 AS-path 300, origin igp, MED 0, localpref 100, pref-val 0, valid, internal, best, select, pre 255, IGP cost 1

 Not advertised to any peer yet

 BGP routing table entry information of 66.66.66.66/32:

 From: 2.2.2.2 (2.2.2.2)

 Route Duration: 00h00m47s  

 Relay IP Nexthop: 10.1.23.2

 Relay IP Out-Interface: GigabitEthernet0/0/0

 Original nexthop: 2.2.2.2

 Qos information : 0x0

 AS-path 100, origin egp, MED 0, localpref 100, pref-val 0, valid, internal, pre

 255, IGP cost 1, not preferred for Origin

 Not advertised to any peer yet

2 保持前面的配置,在AR5上将原来的Network方式改为import方式引入BGP。

在r5上

Bgp 300

undo network 66.66.66.66 255.255.255.255

Import direct

[AR3-bgp]dis bgp routing-table

 BGP Local router ID is 3.3.3.3

 Status codes: * - valid, > - best, d - damped,

               h - history,  i - internal, s - suppressed, S - Stale

               Origin : i - IGP, e - EGP, ? - incomplete

 Total Number of Routes: 3

      Network            NextHop        MED        LocPrf    PrefVal Path/Ogn

 *>i  5.5.5.5/32         4.4.4.4         0          100        0      300?

 *>i  66.66.66.66/32     2.2.2.2         0          100        0      100e

 * i                     4.4.4.4         0          100        0      300?

[AR3-bgp]

你最开始在r3上面把来自r2的66路由改成了e 然后现在是在r5上把来自r4的66路由改成?

此时?就成为了e的次优路径.

  1. e>?

[AR3-bgp]dis bgp routing-table 66.66.66.66

 BGP local router ID : 3.3.3.3

 Local AS number : 200

 Paths:   2 available, 1 best, 1 select

 BGP routing table entry information of 66.66.66.66/32:

 From: 2.2.2.2 (2.2.2.2)

 Route Duration: 00h08m46s  

 Relay IP Nexthop: 10.1.23.2

 Relay IP Out-Interface: GigabitEthernet0/0/0

 Original nexthop: 2.2.2.2

 Qos information : 0x0

 AS-path 100, origin egp, MED 0, localpref 100, pref-val 0, valid, internal, best, select, pre 255, IGP cost 1

 Not advertised to any peer yet

 BGP routing table entry information of 66.66.66.66/32:

 From: 4.4.4.4 (4.4.4.4)

 Route Duration: 00h04m03s  

 Relay IP Nexthop: 10.1.34.4

 Relay IP Out-Interface: GigabitEthernet0/0/1

 Original nexthop: 4.4.4.4

 Qos information : 0x0

 AS-path 300, origin incomplete, MED 0, localpref 100, pref-val 0, valid, intern

al, pre 255, IGP cost 1, not preferred for Origin

 Not advertised to any peer yet

6 优选MED属性值最小的路由

恢复拓扑初始配置,查看AR3的BGP路由表信息。

<AR3>dis bgp routing-table

 BGP Local router ID is 3.3.3.3

 Status codes: * - valid, > - best, d - damped,

               h - history,  i - internal, s - suppressed, S - Stale

               Origin : i - IGP, e - EGP, ? - incomplete

 Total Number of Routes: 2

      Network            NextHop        MED        LocPrf    PrefVal Path/Ogn

 *>i  66.66.66.66/32     2.2.2.2         0          100        0      100i

 * i                     4.4.4.4         0          100        0      300i

<AR3>

测试方法:

将来自对等体2.2.2.2的路由的MED属性值改为1:

#

route-policy 66 permit node 10

 apply cost 1

#

Bgp 200 

peer 2.2.2.2 route-policy 66 import

  compare-different-as-med        #允许比较来自不同AS的路由的MED属性(默认情况下BGP只会对来自同一AS的路由进行MED属性值的比较)

[AR3-bgp]dis bgp routing-table

 BGP Local router ID is 3.3.3.3

 Status codes: * - valid, > - best, d - damped,

               h - history,  i - internal, s - suppressed, S - Stale

               Origin : i - IGP, e - EGP, ? - incomplete

 Total Number of Routes: 2

      Network            NextHop        MED        LocPrf    PrefVal Path/Ogn

 *>i  66.66.66.66/32     4.4.4.4         0          100        0      300i

 * i                     2.2.2.2         1          100        0      100i

[AR3-bgp]dis cu

详细信息

[AR3-bgp]dis bgp routing-table  66.66.66.66

 BGP local router ID : 3.3.3.3

 Local AS number : 200

 Paths:   2 available, 1 best, 1 select

 BGP routing table entry information of 66.66.66.66/32:

 From: 4.4.4.4 (4.4.4.4)

 Route Duration: 00h05m40s  

 Relay IP Nexthop: 10.1.34.4

 Relay IP Out-Interface: GigabitEthernet0/0/1

 Original nexthop: 4.4.4.4

 Qos information : 0x0

 AS-path 300, origin igp, MED 0, localpref 100, pref-val 0, valid, internal, best, select, pre 255, IGP cost 1

 Not advertised to any peer yet

 BGP routing table entry information of 66.66.66.66/32:

 From: 2.2.2.2 (2.2.2.2)

 Route Duration: 00h01m51s  

 Relay IP Nexthop: 10.1.23.2

 Relay IP Out-Interface: GigabitEthernet0/0/0

 Original nexthop: 2.2.2.2

 Qos information : 0x0

 AS-path 100, origin igp, MED 1, localpref 100, pref-val 0, valid, internal, pre

 255, IGP cost 1, not preferred for MED

 Not advertised to any peer yet

7 优选从EBGP学习到的路由

恢复初始配置,查看AR2的路由表信息:

[AR3]dis bgp routing-table

 BGP Local router ID is 3.3.3.3

 Status codes: * - valid, > - best, d - damped,

               h - history,  i - internal, s - suppressed, S - Stale

               Origin : i - IGP, e - EGP, ? - incomplete

 Total Number of Routes: 2

      Network            NextHop        MED        LocPrf    PrefVal Path/Ogn

 *>i  66.66.66.66/32     2.2.2.2         0          100        0      100i

 * i                     4.4.4.4         0          100        0      300i

[AR3]

<AR2>dis ip routing-table  p bgp

Route Flags: R - relay, D - download to fib

------------------------------------------------------------------------------

Public routing table : BGP

         Destinations : 1        Routes : 1        

BGP routing table status : <Active>

         Destinations : 1        Routes : 1

Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

    66.66.66.66/32  EBGP    255  0           D   10.1.12.1       GigabitEthernet

0/0/0

BGP routing table status : <Inactive>

         Destinations : 0        Routes : 0

<AR2>

<AR2>dis bgp routing-table

 BGP Local router ID is 2.2.2.2

 Status codes: * - valid, > - best, d - damped,

               h - history,  i - internal, s - suppressed, S - Stale

               Origin : i - IGP, e - EGP, ? - incomplete

 Total Number of Routes: 1

      Network            NextHop        MED        LocPrf    PrefVal Path/Ogn

 *>   66.66.66.66/32     10.1.12.1       0                     0      100i

<AR2>

在r3上:

#

route-policy 66 permit node 10

 apply as-path 200 additive

#

Bgp 200

  network 66.66.66.66 255.255.255.255 route-policy 66

<AR2>dis bgp routing-table

 BGP Local router ID is 2.2.2.2

 Status codes: * - valid, > - best, d - damped,

               h - history,  i - internal, s - suppressed, S - Stale

               Origin : i - IGP, e - EGP, ? - incomplete

 Total Number of Routes: 2

      Network            NextHop        MED        LocPrf    PrefVal Path/Ogn

 *>   66.66.66.66/32     10.1.12.1       0                     0      100i

 * i                     3.3.3.3         0          100        0      200i

<AR2>dis ip rou

<AR2>dis ip routing-table p  b

<AR2>dis ip routing-table p  bgp

Route Flags: R - relay, D - download to fib

------------------------------------------------------------------------------

Public routing table : BGP

         Destinations : 1        Routes : 1        

BGP routing table status : <Active>

         Destinations : 1        Routes : 1

Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

    66.66.66.66/32  EBGP    255  0           D   10.1.12.1       GigabitEthernet

0/0/0

BGP routing table status : <Inactive>

         Destinations : 0        Routes : 0

<AR2>dis bgp routing-table  66.66.66.66

 BGP local router ID : 2.2.2.2

 Local AS number : 200

 Paths:   2 available, 1 best, 1 select

 BGP routing table entry information of 66.66.66.66/32:

 From: 10.1.12.1 (1.1.1.1)

 Route Duration: 02h04m01s  

 Direct Out-interface: GigabitEthernet0/0/0

 Original nexthop: 10.1.12.1

 Qos information : 0x0

 AS-path 100, origin igp, MED 0, pref-val 0, valid, external, best, select, acti

ve, pre 255

 Advertised to such 1 peers:

    3.3.3.3

 BGP routing table entry information of 66.66.66.66/32:

 From: 3.3.3.3 (3.3.3.3)

 Route Duration: 00h02m21s  

 Relay IP Nexthop: 10.1.23.3

 Relay IP Out-Interface: GigabitEthernet0/0/1

 Original nexthop: 3.3.3.3

 Qos information : 0x0

 AS-path 200, origin igp, MED 0, localpref 100, pref-val 0, valid, internal, pre

 255, IGP cost 1, not preferred for peer type

 Not advertised to any peer yet

<AR2>

8 优选到Next-hop的IGP度量值最小的路由

恢复初始配置,查看AR3初始BGP路由信息:

[AR3-bgp]dis  bgp routing-table

 BGP Local router ID is 3.3.3.3

 Status codes: * - valid, > - best, d - damped,

               h - history,  i - internal, s - suppressed, S - Stale

               Origin : i - IGP, e - EGP, ? - incomplete

 Total Number of Routes: 2

      Network            NextHop        MED        LocPrf    PrefVal Path/Ogn

 *>i  66.66.66.66/32     2.2.2.2         0          100        0      100i

 * i                     4.4.4.4         0          100        0      300i

[AR3-bgp]dis bgp routing-table  66.66.66.66

 BGP local router ID : 3.3.3.3

 Local AS number : 200

 Paths:   2 available, 1 best, 1 select

 BGP routing table entry information of 66.66.66.66/32:

 From: 2.2.2.2 (2.2.2.2)

 Route Duration: 00h02m30s  

 Relay IP Nexthop: 10.1.23.2

 Relay IP Out-Interface: GigabitEthernet0/0/0

 Original nexthop: 2.2.2.2

 Qos information : 0x0

 AS-path 100, origin igp, MED 0, localpref 100, pref-val 0, valid, internal, best, select, pre 255, IGP cost 1

 Not advertised to any peer yet

 BGP routing table entry information of 66.66.66.66/32:

 From: 4.4.4.4 (4.4.4.4)

 Route Duration: 00h02m30s  

 Relay IP Nexthop: 10.1.34.4

 Relay IP Out-Interface: GigabitEthernet0/0/1

 Original nexthop: 4.4.4.4

 Qos information : 0x0

 AS-path 300, origin igp, MED 0, localpref 100, pref-val 0, valid, internal, pre

 255, IGP cost 1, not preferred for router ID

 Not advertised to any peer yet

可以看到,当前到两个对等体的IGP开销都为1。

测试方法:

因为AR2、AR3、AR4之间使用的是OSPF作为IGP

将AR3与AR2连接的接口的OSPF的开销值改为10。

[AR3-bgp]int  g0/0/0

[AR3-GigabitEthernet0/0/0]ospf cost  10

[AR3]dis bgp routing-table  66.66.66.66

 BGP local router ID : 3.3.3.3

 Local AS number : 200

 Paths:   2 available, 1 best, 1 select

 BGP routing table entry information of 66.66.66.66/32:

 From: 4.4.4.4 (4.4.4.4)

 Route Duration: 00h04m54s  

 Relay IP Nexthop: 10.1.34.4

 Relay IP Out-Interface: GigabitEthernet0/0/1

 Original nexthop: 4.4.4.4

 Qos information : 0x0

 AS-path 300, origin igp, MED 0, localpref 100, pref-val 0, valid, internal, bes

t, select, pre 255, IGP cost 1

 Not advertised to any peer yet

 BGP routing table entry information of 66.66.66.66/32:

 From: 2.2.2.2 (2.2.2.2)

 Route Duration: 00h04m54s  

 Relay IP Nexthop: 10.1.23.2

 Relay IP Out-Interface: GigabitEthernet0/0/0

 Original nexthop: 2.2.2.2

 Qos information : 0x0

 AS-path 100, origin igp, MED 0, localpref 100, pref-val 0, valid, internal, pre

 255, IGP cost 10, not preferred for IGP cost

 Not advertised to any peer yet

扩展-BGP路由负载分担

扩展:

当在前面的8条BGP路由匹配规则都无法比较出最优路由时,可以为该BGP路由设置负载分担,而BGP默认只对AS_Path完全相同的路由进行负载分担。

可以使用:load-balancing as-path-ignore忽略AS_Path的不一致。

另外,在配置负载分担前,BGP自身虽然有多条次优路由,但设备只会选择最优的那条路由放进RIB和FIB中,如下图所示:

[AR3]dis ip routing-table  protocol  bgp

Route Flags: R - relay, D - download to fib

------------------------------------------------------------------------------

Public routing table : BGP

         Destinations : 1        Routes : 1        

BGP routing table status : <Active>

         Destinations : 0        Routes : 0

BGP routing table status : <Inactive>

         Destinations : 1        Routes : 1

Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

    66.66.66.66/32  IBGP    255  0          R    2.2.2.2         GigabitEthernet

0/0/0

在公网中到达同一目的地的路由形成负载分担时,系统会首先判断最优路由的类型。

若最优路由为IBGP路由则只是IBGP路由参与负载分担,若最优路由为EBGP路由则只是EBGP路由参与负载分担,即公网中到达同一目的地的IBGP和EBGP路由不能形成负载分担。

[AR3-bgp]maximum load-balancing ibgp ?  #针对路由的IBGP或EBGP配置负载分担的数量

  INTEGER<1-8>  Specify maximum equal cost routes

[AR3-bgp]load-balancing as-path-ignore  #忽略AS_Path的不一致的路由的负载分担

9 优选Cluster_List最短的路由

恢复拓扑初始配置。

测试方法,拓扑做以下修改:

1、取消在AR1上宣告路由,只在AR5上宣告。

2、配置AR3为RR,AR4为AR3的客户端。

3、AR2与AR4之间配置基于回环接口的IBGP关系。

经过上面的修改后,在AR2上会收到AR4的BGP路由,和AR3反射过来的BGP路由66.66.66.66/32。

默认情况下,前面8条规则无法比较出最优路由,此时需要根据Cluster_List进行比较。

如上图所示,设备最终选择了来自对等体4.4.4.4的IBGP路由为最优,而对于来自对等体3.3.3.3的路由,以为来自对等体3.3.3.3的Cluster_List不为空。

在BGP(Border Gateway Protocol)中,Cluster_List(集群列表)是一种用于避免循环的路由属性。它用于解决以下情况:当一个路由反射器(Route Reflector)将一个路由反射给其他反射器时,可能会导致路由循环。

在BGP网络中,路由反射器用于简化路由器之间的BGP对等体关系。它们接收来自客户端路由器的路由信息,并将其反射给其他客户端路由器。当一个路由反射器将一条路由发送给其他反射器时,可能会遇到问题,因为路由信息可能会在不同的反射器之间循环传播。

为了解决这个问题,BGP引入了Cluster_List属性。当一个路由反射器接收到一条路由信息时,它会检查该路由的Cluster_List属性。Cluster_List是一个有序的集群标识符列表,用于跟踪路由信息的传播路径。

在BGP中,路由器使用Cluster_List属性来比较和处理路由信息。具体比较的方式如下:

当一个路由反射器收到一条路由信息时,它首先检查Cluster_List属性是否为空。如果为空,表示该路由是首次被反射,可以继续处理。

如果Cluster_List属性不为空,则路由反射器会检查列表中的集群标识符是否包含自己的集群标识符。如果集群标识符列表中包含自己的标识符,表示该路由已经经过当前的路由反射器处理过了,不再转发给其他反射器,从而避免了循环。

如果集群标识符列表中不包含自己的标识符,则路由反射器会将自己的集群标识符添加到Cluster_List属性的末尾,并将该更新后的路由信息发送给其他客户端路由器和反射器。

在转发路由信息时,路由反射器还需要更新AS_Path属性,以便其他路由器能够正确地了解路由信息的路径。通常,反射器会将自己的AS号添加到AS_Path属性中。

10 优选Router_ID最小的路由

恢复初始配置,观察AR3的BGP初始路由信息。

[AR3-bgp]dis bgp routing-table

 BGP Local router ID is 3.3.3.3

 Status codes: * - valid, > - best, d - damped,

               h - history,  i - internal, s - suppressed, S - Stale

               Origin : i - IGP, e - EGP, ? - incomplete

 Total Number of Routes: 2

      Network            NextHop        MED        LocPrf    PrefVal Path/Ogn

 *>i  66.66.66.66/32     2.2.2.2         0          100        0      100i

 * i                     4.4.4.4         0          100        0      300i

[AR3-bgp]dis bgp routing-table  66.66.66.66

 BGP local router ID : 3.3.3.3

 Local AS number : 200

 Paths:   2 available, 1 best, 1 select

 BGP routing table entry information of 66.66.66.66/32:

 From: 2.2.2.2 (2.2.2.2)

 Route Duration: 00h16m40s  

 Relay IP Nexthop: 10.1.23.2

 Relay IP Out-Interface: GigabitEthernet0/0/0

 Original nexthop: 2.2.2.2

 Qos information : 0x0

 AS-path 100, origin igp, MED 0, localpref 100, pref-val 0, valid, internal, bes

t, select, pre 255, IGP cost 1

 Not advertised to any peer yet

 BGP routing table entry information of 66.66.66.66/32:

 From: 4.4.4.4 (4.4.4.4)

 Route Duration: 00h16m40s  

 Relay IP Nexthop: 10.1.34.4

 Relay IP Out-Interface: GigabitEthernet0/0/1

 Original nexthop: 4.4.4.4

 Qos information : 0x0

 AS-path 300, origin igp, MED 0, localpref 100, pref-val 0, valid, internal, pre

 255, IGP cost 1, not preferred for router ID

 Not advertised to any peer yet

如果前面9条规则都匹配不上,默认会比较到Router_ID的大小,所以选择了Router_ID较小的2.2.2.2的路由。

但是,在比较该条规则下,还有一个潜在的规则:如果路由中携带有Originator_ID,则先比较Originator_ID,再比较Router_ID,同样,具有最小的Originator_ID值的路由为最优。

测试Originator_ID属性:

在第9条规则的测试图中,在Cluster_ID的上一行可以看到一条Originator_ID记录:

[AR3-bgp]dis bgp peer verbose  | in Remote router

BGP version 4, Remote router ID 2.2.2.2

BGP version 4, Remote router ID 4.4.4.4

测试方法:

1、保持AS200中的配置不变,将AR1和AR5改到AS200下,IGP使用OSPF,并宣告各自的loopback0地址和接口地址段。

2、AR1与AR2设置为IBGP;AR4与AR5设置为IBGP。

2、将AR2设置为RR,AR1为AR2的客户端;

3、将AR4设置为RR,AR5为AR2的客户端;

经过上述的变更后,AR3上会学习到来自反射器AR2和AR4的路由,但是优选了来自对等体2.2.2.2的路由,因为其Originator_ID属性值较小,但此时好像也很难辨别究竟是不是Originator_ID选举规则生效。

From:X.X.X.X (Y.Y.Y.Y) 不都是Router_ID的值,X是建立对等体时使用的地址,Y是对等体的Router_ID。

Original nexthop: 是该路由的下一条地址,因为在AR1、AR5上配置了peer X.X.X.X next-hop-local,所以显示的是该路由下一跳的回环接口地址(基于回环接口建立的IBGP)。

Originator_ID 其实就是对应对等体的Router_ID,当经过RR后会携带有Originator_ID属性,该属性映射到Router_ID。

在AR1的BGP视图下取消配置BGP的Router_ID,再次查看AR3的BGP路由表信息:

可以看到,此时来自反射器AR4的路由变为最优,因为Originator_ID属性值比来自反射器AR2的值小,提示信息依旧是显示不是最优的Router_ID值。

将AR5的BGP Router_ID也取消,再次查看AR3的BGP路由表信息:

11 优选具有最小IP地址的对等体通告的路由

更改拓扑信息:

在AR5上宣告66.66.66.66/32 都处于同一AS200,AR5和AR2设置为IBGP,AR5和AR4设置为IBGP。将AR2和AR4设置为RR,且AR5分别是他们的客户端。

经过上述的变更后,AR3上会有两条路由,且前面10条选路规则也无法比较出最优路由,此时会选择具有较小IP地址的对等体(2.2.2.2)的路由:

10.1.23.2 < 10.1.34.4

  • 5
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值