BGP always-compared-med实验

 




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


 

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

沙地云杉

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值