STP及其优化
实验拓扑图:
R1Core1Core2ED-SW
实验步骤:
1. 设置SW1,SW2,SW3主机名分别为Core1,Core2, ED-SW
2. 把Core1与Core2间的两条链路绑定成etherchannel2,并设置成Trunk mode
Core1:
interface range fa0/23 - 24
switchport trunk encapsulation dot1q //支持ISL及dot1Q的交换机必须设置trunk的封装
协议。低端的C2950,C2960,C2918只支持dot1Q,无此命令。 switch mode trunk //接口设置为Trunk模式。
channel-group 2 mode on //接口加入Creating a port-channel interface Port-channel 2
//系统提示自动创建 switchport trunk encapsulation dot1q switchport mode trunk Core2:
interface range fa0/23 - 24
switchport trunk encapsulation dot1q switch mode trunk channel-group 2 mode on
Creating a port-channel interface Port-channel 2 interface Port-channel2
switchport trunk encapsulation dot1q switchport mode trunk
Etherchannel2。
port-channel2。
interface Port-channel2 // Port-channel2接口配置必须同物理接口一致。
3. 验证etherchannel设置
Core1#sh etherchannel summary //显示etherchannel的详细信息 Flags: D - down P - in port-channel I - stand-alone s - suspended H - Hot-standby (LACP only) R - Layer3 S - Layer2
U - in use f - failed to allocate aggregator u - unsuitable for bundling w - waiting to be aggregated d - default port
Number of channel-groups in use: 1 //目前已经建好Number of aggregators: 1
Group Port-channel Protocol Ports
------+-------------+-----------+-----------------------------------------------
2 Po2(SU) - fa0/23(P) fa0/24(P) // S - Layer2 U - in use P - in port-channel
1个etherchannel。
4. Core1,Core2,ED-SW间的所有链路均设置成Trunk
ED-SW:
int range f0/23 – 24 no shutdown
switchport mode trunk Core1: int f0/21
switch trunk encap dot1q switch mode trunk Core2: int f0/21
switch trunk encap dot1q switch mode trunk
5. 验证etherchannel设置
Core2#show interface trunk
Port Mode Encapsulation Status Native vlan
Fa0/21 on 802.1q trunking 1 // F0/21,TrunkPo2 on 802.1q trunking 1
Port Vlans allowed on trunk
Fa0/21 1-4094 //此Trunk允许所有的vlan流量通过。 Po2 1-4094
Port Vlans allowed and active in management domain
Fa0/21 1 //此交换域只有vlan 1是活动的vlan。因为现在无其他vlan
Po2 1
Port Vlans in spanning tree forwarding state and not pruned Fa0/21 1 //Vlan没有被vtp修剪
Po2 1
模式为ON,封装为802.1q,目前已经形成Trunking,native vlan为vlan 1。
6. 添加vlan1-10,奇数vlan生成树根选择Core1,偶数vlan生成树根选择Core2
Core1,Core2,ED-SW:
vlan 2 //添加vlan 2
name testvlan2 //命名vlan 2为testvlan2 vlan 3
name testvlan3 vlan 4
name testvlan4 vlan 5
name testvlan5 vlan 6
name testvlan6 vlan 7
name testvlan7 vlan 8
name testvlan8 vlan 9
name testvlan9 vlan 10
name testvlan10
7. 验证新添加的vlan
Core1#sh vlan brief // Vlan
VLAN Name Status Ports
--------------------------------------------- ------------------------------- 1 default active Fa0/1, Fa0/2, Fa0/3, Fa0/4 Fa0/5, Fa0/6, Fa0/7, Fa0/8 Fa0/9, Fa0/10, Fa0/11, Fa0/12 Fa0/13, Fa0/14, Fa0/15, Fa0/16 Fa0/17, Fa0/18, Fa0/19, Fa0/20 Fa0/22, Gi0/1, Gi0/2
//这些端口默认划分到vlan1,注意Fa0/21,23,24不在这里,因为这3个端口做成了Trunk
2 testvlan2 active ――――部分输出忽略――――――
9 testvlan9 active 10 testvlan10 active
1002 fddi-default act/unsup //这些为特殊vlan,现在基本不用 1003 token-ring-default act/unsup
标号列,vlan名字,状态,及对应端口
8. 验证新添加的vlan
Core1#sh spanning-tree VLAN0001
Spanning tree enabled protocol ieee //Spanning-tree为ieee标准 Root ID Priority 32769 //此交换机
vlan 1的优先级=默认32728+vlan
的标号,则vlan2为32768+2,其他vlan类似。 Address 000d.65dc.8800 //交换机MAC
This bridge is the root //此交换机已经成为valn1的root,默认情
况一台交换机成为所有vlan的root
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 32769 (priority 32768 sys-id-ext 1) Address 000d.65dc.8800
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec Aging Time 300
Interface Role Sts Cost Prio.Nbr Type
---------------- ---- --- --------- -------- -------------------------------- Fa0/4 Desg FWD 19 128.4 P2p
Fa0/21 Desg FWD 19 128.21 P2p // F0/21
为指定端口,处于转发
状态,STP Cost为19
Po2 Desg FWD 12 128.65 P2p
VLAN0002
Spanning tree enabled protocol ieee Root ID Priority 32770
Address 000d.65dc.8800 This bridge is the root
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 32770 (priority 32768 sys-id-ext 2) Address 000d.65dc.8800
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec Aging Time 300
Interface Role Sts Cost Prio.Nbr Type
---------------- ---- --- --------- -------- -------------------------------- Fa0/21 Desg FWD 19 128.21 P2p Po2 Desg FWD 12 128.65 P2p