BGP always-compared-med实验

来源:互联网 发布:淘宝网络授权书 编辑:程序博客网 时间:2024/05/16 01:51

 




1.实验目的

(1)默认情况下,从不同AS得到同一个NLRI的信息,会忽略MED值。必须开启BGPalways-compared-med命令,才会进行比较。

(2)在至同一个NLRI有多个路径的情况下,BGP路由的优选顺序为local-pref、AS-PATH长度、origin、MED值、neighbortype、IGP metric。在上述依然等价的情况下,再比较RID、neighbor ID。

2.实验结果

(1)默认情况下,未开启BGPalways-compared-med。在如图所示的拓扑中,R4在BGP进程中以network的方式发布环回地址4.4.4.4。

在不手动配置BGPRouter ID的情况下,BGP进程采取与OSPF相同的方式,在双up的环回接口中,选择地址最大的作为自己的RID。但修改RID,只在进程重启的情况下生效,即具有不可抢占性。如表1所示,根据实验目的(2)中说明的优选顺序,R1优选从R2处获取的4.4.4.4 BGP路由,比较依据为R2拥有较低的RID。为R2配置换回接口2,配置地址为22.2.2.2,使用clear ip bgp *命令,使之生效。再在R1上观察4.4.4.4 BGP路由情况,优选R3,因为相比有较低的RID。

但必须注意,在EBGP路由情况下,只是在同时获取的情况下进行比较,否则原有路由优先。如R1优选从R3获取4.4.4.4 BGP路由,此时即便R2加入,有较低的RID,仍然不会发生变化。如表2所示,先关闭R1和R2的BGP邻居,使R1优选从R3获取4.4.4.4 BGP路由。再激活R1和R2的BGP邻居,此时优选顺序并不发生改变。


 

表1 BGP路由情况(1)

R1#sh ip bgp 4.4.4.4

BGP routing table entry for 4.4.4.4/32, version 2

Paths: (2 available, best #2, table default)

  Advertised to update-groups:

     4        

  Refresh Epoch 2

  3 4

    10.0.0.14 from 10.0.0.14 (3.3.3.3)

      Origin IGP, localpref 100, valid, external

      rx pathid: 0, tx pathid: 0

  Refresh Epoch 2

  2 4

    10.0.0.2 from 10.0.0.2 (2.2.2.2)

      Origin IGP, localpref 100, valid, external, best

      rx pathid: 0, tx pathid: 0x0

!!!!为R2配置换回接口2,配置地址为22.2.2.2,使用clear ip bgp *命令,使之生效。

!!!再在R1上观察4.4.4.4 BGP路由情况,优选R3,因为相比有较低的RID。

R1#sh ip bgp 4.4.4.4

BGP routing table entry for 4.4.4.4/32, version 3

Paths: (2 available, best #2, table default)

  Advertised to update-groups:

     4        

  Refresh Epoch 1

  2 4

    10.0.0.2 from 10.0.0.2 (22.2.2.2)

      Origin IGP, localpref 100, valid, external

      rx pathid: 0, tx pathid: 0

  Refresh Epoch 2

  3 4

    10.0.0.14 from 10.0.0.14 (3.3.3.3)

      Origin IGP, localpref 100, valid, external, best

      rx pathid: 0, tx pathid: 0x0


 

表2 BGP路由情况(2)

R1(config-router)#do sh ip bgp

BGP table version is 3, local router ID is 1.1.1.1

Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,

              r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,

              x best-external, a additional-path, c RIB-compressed,

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

RPKI validation codes: V valid, I invalid, N Not found

     Network          Next Hop            Metric LocPrf Weight Path

 *>  4.4.4.4/32       10.0.0.14                              0 3 4 i

!!!! 激活R1和R2的BGP邻居,此时优选顺序并不发生改变。

R1(config-router)#do sh ip bgp             

BGP table version is 3, local router ID is 1.1.1.1

Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,

              r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,

              x best-external, a additional-path, c RIB-compressed,

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

RPKI validation codes: V valid, I invalid, N Not found

     Network          Next Hop            Metric LocPrf Weight Path

 *   4.4.4.4/32       10.0.0.2                               0 2 4 i

 *>                   10.0.0.14                              0 3 4 i

(2)分别在R2和R3上使用route-map,其中R2对R1的MED值设置为100,R3对R1的MED值设置为50,在R1上使用clear ipbgp * soft命令(只使能策略而并不会使邻居状态发生变化)。

未开启BGPalways-compared-med命令时,即便经R3获取的路由具有较低的MED值,仍不改变优选情况,与表1一致。

开启BGPalways-compared-med命令时,在R1上观察4.4.4.4 BGP路由,优选MED值较小的R3。


 

表3 BGP路由情况(3)

R1(config-router)#do sh ip bgp    

BGP table version is 2, local router ID is 1.1.1.1

Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,

              r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,

              x best-external, a additional-path, c RIB-compressed,

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

RPKI validation codes: V valid, I invalid, N Not found

 

     Network          Next Hop            Metric LocPrf Weight Path

 *   4.4.4.4/32       10.0.0.14               50             0 3 4 i

 *>                   10.0.0.2              100             0 2 4 i

!!!!开启BGP always-compared-med命令,在R1上观察4.4.4.4 BGP路由,优选顺序发生变化,优选MED值较小的R3。

R1(config-router)#do sh ip bgp

BGP table version is 2, local router ID is 1.1.1.1

Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,

              r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,

              x best-external, a additional-path, c RIB-compressed,

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

RPKI validation codes: V valid, I invalid, N Not found

 

     Network          Next Hop            Metric LocPrf Weight Path

 *>  4.4.4.4/32       10.0.0.14              50             0 3 4 i

 *                    10.0.0.2               100             0 2 4 i


 

1 0
原创粉丝点击