欢迎光临散文网 会员登陆 & 注册

乾颐堂安德CCIEv5.0实验指南:STP中通过Port-priority完成Vlan间流量的负载均衡

2020-03-18 11:08 作者:乾颐堂  | 我要投稿

第39章 通过Port-priority完成Vlan间流量的负载均衡

39.1 理论基础

在交换网络中,通常在汇聚层会做主根和备份根完成冗余。假设两台设备分别为SW1和SW2,而网络中有两个VLAN,vlan10和vlan 100,很多时候会把SW1做为vlan10的主根,同时作为vlan100的备份根(secondary root),相反的SW2做为vlan100的主根,作为vlan10 的备份根。

本文档讲述的是在两条trunk链路上应用port-priority对不同vlan的流量做负载的情况,即端口优先级的用法

让我们讲回生成树,当我们的根已经确定下来的时候,非根交换机通过两条trunk链路连接到根,在非根交换机上有且只有一个根端口,如何选举:选出一条到达根的最小开销的链路(但此时两条trunk链路cost同为19);接下来通过最小的发送者的Bridge ID(2字节优先级+6字节的MAC地址组成)选举,但是此时发送者是同一台交换机,Bridge ID相同,无法选出;

最后最小的Port ID(由端口优先级+Port ID组成)优选,这将是我们研究的内容。需要注意的是分为默认的发送者的端口ID以及根设备上收到的端口ID(见上一章生成树操作部分)

不得不说的是,这是RS CCIE考试中经常遇到的题目之一

其在MST模式下的命令格式如下

spanning-tree   mst instance_id port-priority priority

本实验演示vlan中的配置命令

39.2 拓扑描述

SW1和SW2之间Trunk链路,Sw1为两个VLAN的根,两个Vlan:Vlan 10和Vlan 100

图39-1 修改STP参数

39.3 实验步骤

39.3.1 完成Vlan和Trunk的配置

在Sw1和Sw2上分别做如下配置

SW2(config)#vlan   10

SW2(config-vlan)#vlan

SW2(config-vlan)#vlan   100

SW2(config)#int   range f0/5 - 6

SW2(config-if-range)#   switchport trunk encapsulation dot1q

SW2(config-if-range)#   switchport mode trunk

 

SW2#show interfaces trunk

 

Port        Mode             Encapsulation  Status        Native vlan

Fa0/5       on               802.1q         trunking      1

Fa0/6       on               802.1q         trunking      1

 

Port        Vlans allowed on trunk

Fa0/5       1-4094

Fa0/6       1-4094

 

把SW1和SW2的10口划入Vlan 100

SW2(config)#int f0/10

SW2(config-if)#switchport mode access

SW2(config-if)#switchport access vlan 100

验证:

SW2#show vlan brief

 

VLAN Name                             Status    Ports

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

1    default                          active    Fa0/1, Fa0/3, Fa0/4, Fa0/7

                                                Fa0/8, Fa0/9, Fa0/11, Fa0/12

                                                Fa0/13, Fa0/14, Fa0/15, Fa0/16

                                                Fa0/17, Fa0/18, Fa0/19, Fa0/20

                                                Fa0/21, Fa0/22, Fa0/23, Fa0/24

                                                Gi0/1, Gi0/2

10   VLAN0010                         active   

100  VLAN0100                         active    Fa0/10

39.3.2 把SW1配置成为Vlan10和vlan100的根

来看默认的情况

SW1(config)#spanning-tree   vlan 100 priority 0

SW1(config)#spanning-tree   vlan 10 priority 0

 

两台路由器上在相应接口配置地址

验证:

R1#ping 10.1.1.2

 

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 10.1.1.2, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/4 ms

最主要的是验证生成树的情况:

SW1#  sh spanning-tree vlan 100

 

VLAN0100

  Spanning tree enabled protocol ieee

  Root ID    Priority    100

             Address     9caf.ca47.8c00

             This bridge is the root

             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec

 

  Bridge ID  Priority    100    (priority 0 sys-id-ext 100)

             Address     9caf.ca47.8c00

             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec

             Aging Time  15  sec

 

Interface           Role Sts Cost      Prio.Nbr Type

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

Fa0/5               Desg FWD 19        128.7    P2p ---sw1是根交换机,所以其接口都为转发状态

Fa0/6               Desg FWD 19        128.8    P2p

Fa0/10              Desg FWD 19        128.12   P2p

 

查看SW2的情况:

SW2#sh spanning-tree vlan 100

 

VLAN0100

  Spanning tree enabled protocol ieee

  Root ID    Priority    100

             Address     9caf.ca47.8c00

             Cost        19

             Port        5 (FastEthernet0/5)

             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec

 

  Bridge ID  Priority    32868  (priority 32768 sys-id-ext 100)

             Address     0016.9dd7.5180

             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec

             Aging Time 15

 

Interface           Role Sts Cost      Prio.Nbr Type

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

Fa0/5               Root FWD 19        128.5    P2p

Fa0/6               Altn BLK 19        128.6    P2p---就像我们前边分析的一样,根据cost(19)和BID无法选出根端口,此时的情况是由于默认情况下6口的port id大于5口的端口ID ,也就是说现在VLAN100的流量经过的是F0/5

 Fa0/10              Desg FWD 19        128.10   P2p Edge

如果此时VLAN10也有流量的话,其实也是经过f0/5的,我们查看spanning的情况:

 

SW2#sh spanning-tree vlan 10

 

VLAN0010

  Spanning tree enabled protocol ieee

  Root ID    Priority    10

             Address     9caf.ca47.8c00

             Cost        19

             Port        5 (FastEthernet0/5)

             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec

 

  Bridge ID  Priority    32778  (priority 32768 sys-id-ext 10)

             Address     0016.9dd7.5180

             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec

             Aging Time 300

Interface           Role Sts Cost      Prio.Nbr Type

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

Fa0/5               Root FWD 19        128.5    P2p

Fa0/6               Altn BLK 19        128.6    P2p

39.3.3 通过修改Cost值或者port-priority可以做到Vlan间的负载均衡

不过两者的不同之处是port-priority在根上修改来影响,端口的Cost在非根上修改,这一点我们在上一章讲解STP对比过程时的最后一步提及

SW1(config)#int   f0/6

SW1(config-if)#spanning-tree   vlan 100 port-priority ?

  <0-240>  port priority in increments of 16

对端口优先级来说,默认是128,越小越优先

SW1(config-if)#spanning-tree   vlan 100 port-priority 0

我们针对vlan100修改了优先级0,那么此时f0/6会由阻塞变为转发

 

 

SW2#sh spanning-tree vlan 100

 

Interface           Role Sts Cost      Prio.Nbr Type

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

Fa0/5               Altn BLK 19        128.5    P2p

Fa0/6               Root FWD 19        128.6    P2p

Fa0/10              Desg FWD 19        128.10   P2p Edge

我们在具体的查看一下SW1:

SW1#sh spanning-tree interface f0/6 detail

 Port 8 (FastEthernet0/6) of VLAN0010 is designated forwarding

   Port path cost 19, Port priority 128, Port Identifier 128.8.

   Designated root has priority 10, address 9caf.ca47.8c00

   Designated bridge has priority 10, address 9caf.ca47.8c00

   Designated port id is 128.8, designated path cost 0

   Timers: message age 0, forward delay 0, hold 0

   Number of transitions to forwarding state: 2

   Link type is point-to-point by default

   BPDU: sent 533, received 153

 

 Port 8 (FastEthernet0/6) of VLAN0100 is designated forwarding

   Port path cost 19, Port priority 0, Port Identifier   0.8.

   Designated root has priority 100, address 9caf.ca47.8c00

   Designated bridge has priority 100, address 9caf.ca47.8c00

   Designated port id is 0.8, designated path cost 0

   Timers: message age 0, forward delay 0, hold 0

   Number of transitions to forwarding state: 1

   Link type is point-to-point by default

   BPDU: sent 476, received 2

此时如果有Vlan10 的流量,那么是经过5口转发的:

SW2#sh spanning-tree vlan 10

Interface           Role Sts Cost      Prio.Nbr Type

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

Fa0/5               Root FWD 19        128.5    P2p

Fa0/6               Altn BLK 19        128.6    P2p

 

自然也可以通过修改非根设备的cost来做到这种效果,我们演示一下vlan10的情况:

SW2(config-if)#int   f0/6

SW2(config-if)#   spanning-tree vlan 10 cost 1---自然我们要把cost改小,那么将优选该接口

 

SW2#show spanning-tree vlan 10

 

VLAN0010

  Spanning tree enabled protocol ieee

  Root ID    Priority    10

             Address     9caf.ca47.8c00

             Cost        1

             Port        6 (FastEthernet0/6)

             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec

 

  Bridge ID  Priority    32778  (priority 32768 sys-id-ext 10)

             Address     0016.9dd7.5180

             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec

             Aging Time 300

 

Interface           Role Sts Cost      Prio.Nbr Type

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

Fa0/5               Altn BLK 19        128.5    P2p

Fa0/6               Root FWD 1         128.6    P2p

实验完成

乾颐堂安德CCIEv5.0实验指南:STP中通过Port-priority完成Vlan间流量的负载均衡的评论 (共 条)

分享到微博请遵守国家法律