打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
BGP weight属性


先了解一下weight属性的一些概念。
1 weight属性是cisco的私有属性,是一种选路属性,用来选择一条最优路径。
2 weight属性只对本地路由器有效。该属性不会被传递。
3 weight值的取值范围是0-65535。对于本路由器产生的路由,weight的默认值=32768;对于所有学到的路由,weight的默认值=0。
4 对于到同一目的地的多条路径来说,weight值越高的路径越优先

配置BGP
RTA#sh run | b r b
router bgp 100
no synchronization
neighbor 12.0.0.1 remote-as 4
neighbor 23.0.0.3 remote-as 300
no auto-summary

RTE#sh run | b r b
router bgp 4
no synchronization
network 175.10.0.0       /将该网络宣告进BGP中。
neighbor 12.0.0.2 remote-as 100
neighbor 14.0.0.4 remote-as 200
no auto-summary

RTB#sh run | b r b
router bgp 200
no synchronization
neighbor 14.0.0.1 remote-as 4
neighbor 34.0.0.3 remote-as 300
no auto-summary

RTC#sh run | b r b
router bgp 300
no synchronization
neighbor 23.0.0.2 remote-as 100
neighbor 34.0.0.4 remote-as 200
no auto-summary

在RTC上进行查看
RTC#sh ip bgp
   Network          Next Hop            Metric LocPrf Weight Path
*  175.10.0.0         34.0.0.4                               0 200 4 i
*>                  23.0.0.2                               0 100 4 i
这时可以看到RTC选择RTA作为到达目标的下一跳。现在要做的就是在RTC上修改weight值,让RTC选择RTB作为到达目标的下一跳。

在RTC上直接修改weight值
RTC(config)#router bgp 300
RTC(config-router)#neighbor 23.0.0.2 weight 100
RTC(config-router)#neighbor 34.0.0.4 weight 200
将RTB发来的路由的weight值修改的大于RTA的。
RTC#sh ip bgp
   Network          Next Hop            Metric LocPrf Weight Path
*  175.10.0.0         23.0.0.2                             100 100 4 i
*>                  34.0.0.4                             200 200 4 i
这时可以看到RTC现在选择RTB作为下一跳到达目标网络 175.10.0.0

RTC#sh ip route
     34.0.0.0/24 is subnetted, 1 subnets
C       34.0.0.0 is directly connected, Serial2/2
B    175.10.0.0/16 [20/0] via 34.0.0.4, 00:11:24
     23.0.0.0/24 is subnetted, 1 subnets
C       23.0.0.0 is directly connected, Serial2/1
查看路由表也可以看到,RTC到达175.10.0.0网络的下一跳是34.0.0.4(RTB)
这也证明了到同一目标网络的多条路径,weight值越大,则该路径越优先
   
也可以用AS列表和route-map来修改weight。
首先建立一个AS列表
RTC(config)#ip as-path access-list 1 permit ^100
这条语句的含义是匹配所有AS路径 的字符串开始是100的路由条目。

然后建立route-map
RTC(config)#route-map WEIGHT permit 10
RTC(config-route-map)#match as-path 1  /匹配AS列表1
RTC(config-route-map)#set weight 100   /设定weight=100
这条语句的意义是将匹配上AS列表1的路由的weight设为100
RTC(config)#route-map WEIGHT permit 20
RTC(config-route-map)#set weight 200
这条语句的意义是所有其它的路由的weight设为200

最后在BGP进程中调用该route-map
RTC(config)#router bgp 300
RTC(config-router)#neighbor 23.0.0.2 route-map WEIGHT in
RTC(config-router)#neighbor 34.0.0.4 route-map WEIGHT in

RTC#sh ip bgp
   Network          Next Hop            Metric LocPrf Weight Path
*> 175.10.0.0         34.0.0.4                             200 200 4 i
*                   23.0.0.2                             100 100 4 i
可以看到这时RTC选择了RTB作为到达目标网络的下一跳,因为这条路由的weight值比较大。


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u1/36438/showart_302312.html
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
BGP路由协议详解(完整篇) - 张选波博客 - 51CTO技术博客
BGP用户培训材料
38个BGP实验汇总
BGP 地址族分析
企业BGP网络规划案例(一)
BGP配置示例 - 51CTO.COM
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服