生成树STP配置 ------冗余的备份链路被自动激活

来源:互联网 发布:直播笑声软件下载 编辑:程序博客网 时间:2024/05/16 01:29

拓扑图如下:


配置交换机S1

Switch>en
Switch#show spanning-tree
VLAN0001
  Spanning tree enabled protocol ieee
  Root ID    Priority    32769
             Address     0002.1740.2CD7
             This bridge is the root
             Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec


  Bridge ID  Priority    32769  (priority 32768 sys-id-ext 1)
             Address     0002.1740.2CD7
             Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec
             Aging Time  20


Interface        Role Sts Cost      Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Fa0/1            Desg LRN 19        128.1    P2p
Fa0/2            Desg LRN 19        128.2    P2p
Fa0/24           Desg LRN 19        128.24   P2p


Switch#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Switch(config)#host S1
S1(config)#int fa0/24
S1(config-if)#switchport mode access
S1(config-if)#switchport access vlan 20    !---   没有事先创建VLAN 20,在使用的时候自动创建
% Access VLAN does not exist. Creating vlan 20
S1(config-if)#exit
S1(config)#int range fa0/1 - 2    !---    一次性将两个端口指定为 Trunk 端口
S1(config-if-range)#switchport mode access
S1(config-if-range)#switchport mode trunk
S1(config-if-range)#
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to down
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/2, changed state to down
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/2, changed state to up
S1(config-if-range)#exit
S1(config)#spanning-tree mode rapid-pvst
S1(config)#end
S1#
%SYS-5-CONFIG_I: Configured from console by console
S1#show spanning-tree
VLAN0001
  Spanning tree enabled protocol rstp
  Root ID    Priority    32769
             Address     0002.1740.2CD7
             This bridge is the root
             Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec


  Bridge ID  Priority    32769  (priority 32768 sys-id-ext 1)
             Address     0002.1740.2CD7
             Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec
             Aging Time  20


Interface        Role Sts Cost      Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Fa0/1            Desg LRN 19        128.1    P2p
Fa0/2            Desg LRN 19        128.2    P2p


VLAN0020
  Spanning tree enabled protocol rstp
  Root ID    Priority    32788
             Address     0002.1740.2CD7
             This bridge is the root
             Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec


  Bridge ID  Priority    32788  (priority 32768 sys-id-ext 20)
             Address     0002.1740.2CD7
             Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec
             Aging Time  20


Interface        Role Sts Cost      Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Fa0/1            Desg FWD 19        128.1    P2p
Fa0/2            Desg FWD 19        128.2    P2p
Fa0/24           Desg FWD 19        128.24   P2p


S1#






配置交换机S2
Switch>en
Switch#show spanning-tree
VLAN0001
  Spanning tree enabled protocol ieee
  Root ID    Priority    32769
             Address     0002.1740.2CD7
             Cost        19
             Port        1(FastEthernet0/1)
             Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec


  Bridge ID  Priority    32769  (priority 32768 sys-id-ext 1)
             Address     0002.4AB0.66E9
             Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec
             Aging Time  20


Interface        Role Sts Cost      Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Fa0/1            Root FWD 19        128.1    P2p
Fa0/2            Altn BLK 19        128.2    P2p
Fa0/24           Desg FWD 19        128.24   P2p


Switch#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Switch(config)#host S2
S2(config)#int fa0/24
S2(config-if)#switchport mode access
S2(config-if)#switchport access vlan 20  !---   没有事先创建VLAN 20,在使用的时候自动创建
% Access VLAN does not exist. Creating vlan 20
S2(config-if)#exit
S2(config)#int range fa0/1 - 2  !---    一次性将两个端口指定为 Trunk 端口
S2(config-if-range)#switchport mode access
S2(config-if-range)#switchport mode trunk
S2(config-if-range)#
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to down
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/2, changed state to down
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/2, changed state to up
S2(config-if-range)#exit
S2(config)#spanning-tree mode rapid-pvst
S2(config)#end
S2#
%SYS-5-CONFIG_I: Configured from console by console


S2#show spanning-tree
VLAN0001
  Spanning tree enabled protocol rstp
  Root ID    Priority    32769
             Address     0002.1740.2CD7
             Cost        19
             Port        1(FastEthernet0/1)
             Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec


  Bridge ID  Priority    32769  (priority 32768 sys-id-ext 1)
             Address     0002.4AB0.66E9
             Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec
             Aging Time  20


Interface        Role Sts Cost      Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Fa0/1            Root LRN 19        128.1    P2p
Fa0/2            Altn BLK 19        128.2    P2p


VLAN0020
  Spanning tree enabled protocol rstp
  Root ID    Priority    32788
             Address     0002.1740.2CD7
             Cost        19
             Port        1(FastEthernet0/1)
             Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec


  Bridge ID  Priority    32788  (priority 32768 sys-id-ext 20)
             Address     0002.4AB0.66E9
             Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec
             Aging Time  20


Interface        Role Sts Cost      Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Fa0/1            Root LRN 19        128.1    P2p
Fa0/2            Altn BLK 19        128.2    P2p
Fa0/24           Desg FWD 19        128.24   P2p


S2#


测试快速生成树配置

PC>ipconfig
FastEthernet0 Connection:(default port)
Link-local IPv6 Address.........: FE80::2E0:8FFF:FE77:2147
IP Address......................: 192.168.1.2
Subnet Mask.....................: 255.255.255.0
Default Gateway.................: 192.168.1.1
PC>ping -t 192.168.1.3  !--- 不间断地ping客户端PC2这台计算机------目的是持续传输信息
Pinging 192.168.1.3 with 32 bytes of data:
Reply from 192.168.1.3: bytes=32 time=1ms TTL=128
Reply from 192.168.1.3: bytes=32 time=0ms TTL=128
Reply from 192.168.1.3: bytes=32 time=0ms TTL=128
Reply from 192.168.1.3: bytes=32 time=1ms TTL=128
Reply from 192.168.1.3: bytes=32 time=0ms TTL=128
Reply from 192.168.1.3: bytes=32 time=0ms TTL=128
Reply from 192.168.1.3: bytes=32 time=0ms TTL=128
Reply from 192.168.1.3: bytes=32 time=0ms TTL=128
Reply from 192.168.1.3: bytes=32 time=0ms TTL=128
Reply from 192.168.1.3: bytes=32 time=1ms TTL=128
Reply from 192.168.1.3: bytes=32 time=0ms TTL=128
Reply from 192.168.1.3: bytes=32 time=0ms TTL=128
Reply from 192.168.1.3: bytes=32 time=0ms TTL=128
Request timed out.
Request timed out.
Request timed out.
Reply from 192.168.1.3: bytes=32 time=0ms TTL=128
Reply from 192.168.1.3: bytes=32 time=0ms TTL=128
Reply from 192.168.1.3: bytes=32 time=0ms TTL=128
Reply from 192.168.1.3: bytes=32 time=0ms TTL=128



回过头来关闭交换机S1正在通讯的端口fa0/1,人为地制造端口的“损坏”--------目的是让备份链路被自动激活,此时注意ping返回的结果。
S1#conf t
S1(config)#int fa0/1
S1(config-if)#shut  !--- 关闭正在通讯的链路,注意交换机自动启动备份链路。

此时的效果拓扑图如下:



实验结果表明其中一条冗余链路被自动阻塞作为备份链路,只有当活动链路失败时,备份链路才会被激活,从而恢复设备之间的连接,保证网络的畅通。


原创粉丝点击