配置BGP权重 配置BGP权重
2010-01-30 16:38:01
 标签:bgp config weight    [推送到技术圈]

版权声明:原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 、作者信息和本声明。否则将追究法律责任。http://supercisco.blog.51cto.com/672109/272375
         今天针对BGP的权重做了个实验。目的也就是当本地出口路由器有多条外出自治系统的链路时,应用权重(Weight)属性能够决定数据流从本地路由器哪条出口链路流出本地自治系统。但这个是cisco私有的属性。由于本地优先级针对本地AS属性。MED属性却是不同的AS,MED不作比较。所以cisco私有的权重属性也是重要的属性,并且在cisco路由器中优先级是排名第一的。好的。下面就看一下拓扑图:
 
一、拓扑图:
配置BGP权重
 
二、实验分析:
1、根据BGP路由选择决策过程 对于特定的目的地,BGP只选择一条最佳路径。但<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

如果到达目标有多条路径,则将会依据以下这些策略进行路径选择:

A、选权重最高的路由(cisco私有属性,只在当前本地路由器有效)

B、选择本地优先级最高的路由(注:只用于本地AS内部)

C、选择当前路由器的通告过的路由

D、选择AS路径最短的路由

E、选择源头编码最小的路径(依次为IGP<EGP<Incomplete)

F、选择MED值最小的路径

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

H、选择经过最近的IGP邻居的路径

I、对于EBGP路径,选择最老的路由

J、选邻居BGP路由器ID最小的路由

K、选择邻居IP地址最小的路由

 
2、那么依次配置各台路由器IP地址和BGP协议之后,查看R1BGP和路由表:
 
R1#sh ip route
………………

Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP

       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area

       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2

       E1 - OSPF external type 1, E2 - OSPF external type 2

       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2

       ia - IS-IS inter area, * - candidate default, U - per-user static route

       o - ODR, P - periodic downloaded static route

 

Gateway of last resort is not set

 

C    192.168.4.0/24 is directly connected, FastEthernet0/0

C    192.168.1.0/24 is directly connected, Serial1/1

B    192.168.2.0/24 [20/0] via 192.168.1.2, 00:09:18

B    192.168.3.0/24 [20/0] via 192.168.4.1, 00:09:11

     150.150.0.0/24 is subnetted, 1 subnets

B       150.150.1.0 [20/0] via 192.168.1.2, 00:09:18

R1#sh ip bgp

BGP table version is 7, local router ID is 192.168.4.2
………………

   Network          Next Hop            Metric LocPrf Weight Path

*  150.150.1.0/24   192.168.4.1                            0 64515 64514 i

*>                  192.168.1.2                            0 64513 64514 i

*  192.168.1.0      192.168.1.2              0             0 64513 i

*>                  0.0.0.0                  0         32768 i

*  192.168.2.0      192.168.4.1                            0 64515 64514 i

*>                  192.168.1.2              0             0 64513 i

*> 192.168.3.0      192.168.4.1              0             0 64515 i

*                   192.168.1.2                            0 64513 64514 i

*  192.168.4.0      192.168.4.1              0             0 64515 i

*>                  0.0.0.0                  0         32768 i

 
3、查看一下R1BGP邻居表:
 
R1#sh ip bgp neighbors

BGP neighbor is 192.168.1.2,  remote AS 64513, external link

  BGP version 4, remote router ID 192.168.2.1

  BGP state = Established, up for 00:53:38
………………

BGP neighbor is 192.168.4.1,  remote AS 64515, external link

  BGP version 4, remote router ID 192.168.4.1

  BGP state = Established, up for 00:54:23

 
4、由于R2router-id并且优先通告给R1。所以R1选择R2作为下一跳到达150.150.1.0/24,R1R4之间是快速以太网链路,所以R1选错了下一跳,并且由于本地优先级针对本地AS属性, MED属性却是不同邻居ASMED不作比较。那么下面我们通过cisco 私有的BGP的权重属性来解决R1150.150.1.0/24路径选择问题。
三、实验步骤:
1、在R1上分别指定两个邻居的权重,让R1优先选择权重大的链路走:
 
R1(config)#router bgp 64512

R1(config-router)#nei 192.168.1.2 weight 50

R1(config-router)#nei 192.168.4.1 weight 100

 
2、软涮新一下BGP数据库,查看一下:
 
R1#clear ip bgp * soft

R1#sh ip bgp

   Network          Next Hop            Metric LocPrf Weight Path

*> 150.150.1.0/24   192.168.4.1                          100 64515 64514 i(现在选择R4了)

*                   192.168.1.2                           50 64513 64514 i

*  192.168.1.0      192.168.1.2              0            50 64513 i       (这条没错)

*>                  0.0.0.0                  0         32768 i

*> 192.168.2.0      192.168.4.1                          100 64515 64514 i(但这条路径就……)

*                   192.168.1.2              0            50 64513 i

*> 192.168.3.0      192.168.4.1              0           100 64515 i

*                   192.168.1.2                           50 64513 64514 i

*  192.168.4.0      192.168.4.1              0           100 64515 i

*>                  0.0.0.0                  0         32768 i (为避免环路,直连权重值为最大)

 
3、通过对R1指定邻居权重,R1150.150.1.0/24发现是选择了权重大的下一跳走,但却发现R1192.168.2.0/24也选择了权重大的R4链路作为下一跳。而没有选择直连链路走,看来我们只指定邻居权重这种方法是拆东墙补西墙。并不是很完美的。但如果用路由图调用设置权重就不一样了。这样可以针对目的地址设置权重,下面我们就把之前配置的权重no掉,并重新建一个route-map设置权重值。
 
R1(config)#router bgp 64512

R1(config-router)#no neighbor 192.168.1.2 weight 50
R1(config-router)#no neighbor 192.168.4.1 weight 100
R1(config)#access-list 10 per 150.150.1.0 0.0.0.255 (建立一个ACL

R1(config)#route-map set_weight per 10 (建立一个路由图名为set_weight

R1(config-route-map)#match ip add 10 (匹配ACL)

R1(config-route-map)#set weight 100 (针对route-map特定的目的网络设置权重值100

R1(config-route-map)#exit        

R1(config)#route-map set_weight per 20 (再建立一个空路由图以便其它路由都按默认方式转发)

 
四、验证实验:
 
R1#sh ip bgp

…………

   Network          Next Hop            Metric LocPrf Weight Path

*> 150.150.1.0/24   192.168.4.1                            0 64515 64514 i(下一跳为R4

*                   192.168.1.2                            0 64513 64514 i

*  192.168.1.0      192.168.1.2              0             0 64513 i

*>                  0.0.0.0                  0         32768 i

*  192.168.2.0      192.168.4.1                            0 64515 64514 i

*>                  192.168.1.2              0             0 64513 i  (下一跳为R2)

*> 192.168.3.0      192.168.4.1              0             0 64515 i

*                   192.168.1.2                            0 64513 64514 i

*  192.168.4.0      192.168.4.1              0             0 64515 i

*>                  0.0.0.0                  0         32768 i

R1#sh ip route

………………

C    192.168.4.0/24 is directly connected, FastEthernet0/0

C    192.168.1.0/24 is directly connected, Serial1/1

B    192.168.2.0/24 [20/0] via 192.168.1.2, 00:07:40

B    192.168.3.0/24 [20/0] via 192.168.4.1, 00:32:27

     150.150.0.0/24 is subnetted, 1 subnets

B       150.150.1.0 [20/0] via 192.168.4.1, 00:07:40

 

转载于:https://blog.51cto.com/lzozhuyk/272908

相关文章:

  • 2021-07-10
  • 2021-06-16
  • 2021-12-02
  • 2021-11-09
  • 2021-11-26
  • 2021-12-17
  • 2021-12-25
猜你喜欢
  • 2022-01-10
  • 2021-10-08
  • 2021-12-10
  • 2022-01-24
  • 2021-09-03
相关资源
相似解决方案