stp和链路捆绑
 
 
一、 基本配置
Switch>en
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#hostname
Switch(config)#hostname sw14
sw14(config)#no ip domain-lookup
sw14(config)#line con 0
sw14(config-line)#logging synchronous
sw14(config-line)#no login
sw14(config-line)#line vty 0 4
R5>en
R5#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R5(config)#hostname r4
r4(config)#no ip domain-lookup
r4(config)#no ip routing
r4(config)#line con 0
r4(config-line)#logging s
r4(config-line)#logging synchronous
r4(config-line)#no login
r4(config-line)#end
 
三台交换机
 
 
 

如图连接交换机,查看未配置优先级时的默认优先级
sw14#show spanning-tree
 
VLAN0001
 Spanning tree enabled protocol ieee
 Root ID    Priority    32769
             Address     0011.2194.f600
             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     0012.7f7d.11c0
             Hello Time   2 sec Max Age 20 sec Forward Delay 15 sec
             Aging Time 300
 
Interface        Role Sts Cost      Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Fa0/1            Root FWD 19        128.1    P2p
Fa0/2            Desg FWD 19        128.2    P2p
 
 
 
 
sw15#show spanning-tree
 
VLAN0001
 Spanning tree enabled protocol ieee
 Root ID    Priority    32769
             Address     0011.2194.f600
             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     0011.2194.f600
             Hello Time   2 sec Max Age 20 sec Forward Delay 15 sec
             Aging Time 300
 
Interface        Role Sts Cost      Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Fa0/1            Desg FWD 19        128.1    P2p
Fa0/2            Desg FWD 19        128.2    P2p
 
 
sw16#show spanning-tree
 
VLAN0001
 Spanning tree enabled protocol ieee
 Root ID    Priority    32769
             Address     0011.2194.f600
             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     0018.b997.df00
             Hello Time   2 sec Max Age 20 sec Forward Delay 15 sec
             Aging Time 300
 
Interface        Role Sts Cost      Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Fa0/1            Root FWD 19        128.1    P2p
Fa0/2            Altn BLK 19        128.2    P2p
 
 
 
默认根网桥是 sw15
 
Sw16 f0/2 端口阻塞
 
直接拓扑变更
输入命令 debug spanning-tree events
sw16 f0/1shutdown
 
 
01:08:34: STP: VLAN0001 Fa0/2 -> listening
01:08:49: STP: VLAN0001 Fa0/2 -> learning //时间间隔是15s
01:09:04: STP: VLAN0001 Fa0/2 -> forwarding//时间间隔是15s
 
间接拓扑变更
 
 
sw5 f0/1shutdown
 
01:19:05: STP: VLAN0001 heard root 32769-0012.7f7d.11c0 on Fa0/2
sw16#
01:19:07: STP: VLAN0001 heard root 32769-0012.7f7d.11c0 on Fa0/2
01:19:07: STP: VLAN0001 Fa0/1 -> forwarding
sw16#
01:19:09: STP: VLAN0001 heard root 32769-0012.7f7d.11c0 on Fa0/2
sw16#
01:19:11: STP: VLAN0001 heard root 32769-0012.7f7d.11c0 on Fa0/2
sw16#
01:19:13: STP: VLAN0001 heard root 32769-0012.7f7d.11c0 on Fa0/2
sw16#
01:19:15: STP: VLAN0001 heard root 32769-0012.7f7d.11c0 on Fa0/2
sw16#
01:19:17: STP: VLAN0001 heard root 32769-0012.7f7d.11c0 on Fa0/2
sw16#
01:19:19: STP: VLAN0001 heard root 32769-0012.7f7d.11c0 on Fa0/2
sw16#
01:19:21: STP: VLAN0001 heard root 32769-0012.7f7d.11c0 on Fa0/2
sw16#
01:19:23: STP: VLAN0001 heard root 32769-0012.7f7d.11c0 on Fa0/2
01:19:23: STP: VLAN0001 Fa0/2 -> listening//时间间隔是20s
sw16#
01:19:24: STP: VLAN0001 Topology Change rcvd on Fa0/2
01:19:24: STP: VLAN0001 sent Topology Change Notice on Fa0/1
sw16#
01:19:38: STP: VLAN0001 Fa0/2 -> learning//时间间隔是15s
sw16#
01:19:53: STP: VLAN0001 sent Topology Change Notice on Fa0/1
01:19:53: STP: VLAN0001 Fa0/2 -> forwarding//时间间隔是15
 
二层链路捆绑配置 以太通道
sw14(config)#interface range fastEthernet0/1 -2
sw14(config-if-range)#switchport mode trunk
sw14(config-if-range)#channel-group 2 mode on
 
 
w14#show etherchannel summ
sw14#show etherchannel summary
Flags: D - down        P - in port-channel
        I - stand-alone s - suspended
        H - Hot-standby (LACP only)
        R - Layer3      S - Layer2
        u - unsuitable for bundling
        U - in use      f - failed to allocate aggregator
        d - default port
 
Number of channel-groups in use: 1
Number of aggregators:           1
 
Group Port-channel Protocol    Ports
------+-------------+-----------+-----------------------------------------------
2      Po2(SU)          -        Fa0/1(Pd)   Fa0/2(P)
 
 
 
 
sw15(config)#interface Range FastEthernet0/1 -2
w15(config-if-range)#Switchport mode trunk
sw15(config-if-range)#channel
sw15(config-if-range)#channel-GROUp 2 mode on
Creating a port-channel interface Port-channel 2
 
sw15#show etherchannel summary
Flags: D - down        P - in port-channel
        I - stand-alone s - suspended
        H - Hot-standby (LACP only)
        R - Layer3      S - Layer2
        u - unsuitable for bundling
        U - in use      f - failed to allocate aggregator
        d - default port
 
Number of channel-groups in use: 1
Number of aggregators:           1
 
Group Port-channel Protocol    Ports
------+-------------+-----------+-----------------------------------------------
2      Po2(SD)          -        Fa0/1(D)    Fa0/2(D) 
 
Stp 配置
优先级配置,选跟网桥和备份网桥
sw14(config)#spanning-tree vlan 1 priority 0
 
sw15(config)#spanning-tree vlan 1 priority 4096
sw15(config)#interface fastethernet 0/3
sw15(config-if)#spanning-tree portfast
sw15(config-if)#no shutdown
sw15(config-if)#end
 
sw16(config)#interface fastethernet 0/3
sw16(config-if)#spanning-tree portfast
sw16(config-if)#no shutdown
 
没有在连接交换机的端口配置 trunk 所以没有生成树
sw14#show spanning-tree
No spanning tree instance exists.
配置 trunk
sw14#show spanning-tree
 
VLAN0001
 Spanning tree enabled protocol ieee
 Root ID    Priority    1
             Address     0012.7f7d.11c0
             This bridge is the root
             Hello Time   2 sec Max Age 20 sec Forward Delay 15 sec
 
 Bridge ID Priority    1      (priority 0 sys-id-ext 1)
             Address     0012.7f7d.11c0
             Hello Time   2 sec Max Age 20 sec Forward Delay 15 sec
             Aging Time 300
 
Interface        Role Sts Cost      Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Fa0/5            Desg FWD 19        128.5    P2p //接口:指定,状态:转发。原因: 
                                                 // This bridge is the root
Po2              Desg FWD 12        128.65   P2p //接口:指定,状态:转发。原因: 
                                                 // This bridge is the root
 
 
sw15#show spanning-tree
 
VLAN0001
 Spanning tree enabled protocol ieee
 Root ID    Priority    1
             Address     0012.7f7d.11c0
             Cost        12
             Port        65 (Port-channel2)
             Hello Time   2 sec Max Age 20 sec Forward Delay 15 sec
 
 Bridge ID Priority    4097   (priority 4096 sys-id-ext 1)
             Address     0011.2194.f600
             Hello Time   2 sec Max Age 20 sec Forward Delay 15 sec
             Aging Time 300
 
Interface        Role Sts Cost      Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Fa0/3            Desg FWD 19        128.3    P2p //接口:指定;状态:转发;原因:
Fa0/4            Desg FWD 19        128.4    P2p
Po2              Root FWD 12        128.65   P2p
 
 
sw16#show spanning-tree
 
VLAN0001
 Spanning tree enabled protocol ieee
 Root ID    Priority    1
             Address     0012.7f7d.11c0
             Cost        19
             Port        7 (FastEthernet0/7)
             Hello Time   2 sec Max Age 20 sec Forward Delay 15 sec
 
 Bridge ID Priority    32769 (priority 32768 sys-id-ext 1)
             Address     0018.b997.df00
             Hello Time   2 sec Max Age 20 sec Forward Delay 15 sec
             Aging Time 300
 
Interface        Role Sts Cost      Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Fa0/2            Altn BLK 19        128.2    P2p //接口:阻塞状态:阻塞原因
Fa0/3            Desg FWD 100       128.3   Edge Shr
Fa0/7            Root FWD 19        128.7    P2p
 
 
分析二层数据包走向
查看 pc mac 地址
 
r4#show arp
Protocol Address          Age (min) Hardware Addr   Type   Interface
Internet 192.168.1.1             -   0010.7b81.6f57 ARPA   Ethernet1
r6#show arp
Protocol Address          Age (min) Hardware Addr   Type   Interface
Internet 192.168.1.2             -   000d.28f1.0161 ARPA   FastEthernet0/1
 
sw16#show mac-address-table dynamic
          Mac Address Table
-------------------------------------------
 
Vlan    Mac Address       Type        Ports
----    -----------       --------    -----
   1    0012.7f7d.11c5    DYNAMIC     Fa0/7
Total Mac Addresses for this criterion: 1
 
sw16#show mac-address-table dynamic
          Mac Address Table
-------------------------------------------
 
Vlan    Mac Address       Type        Ports
----    -----------       --------    -----
   1    000d.28f1.0161    DYNAMIC     Fa0/7
   1    0010.7b81.6f57    DYNAMIC     Fa0/4
   1    0011.2194.f602    DYNAMIC     Fa0/7
   1    0012.7f7d.11c5    DYNAMIC     Fa0/7
Total Mac Addresses for this criterion: 4
 
通过交换机 sw16 mac 地址表,发现去往 pc2 的数据包是从 f0/7 接口出去的
 
 
Stp 的切换
 
未切换前
 
sw16#show spanning-tree
 
VLAN0001
sw15#show spanning-tree
 
VLAN0001
 Spanning tree enabled protocol ieee
 Root ID    Priority    1
             Address     0012.7f7d.11c0
             Cost        19
             Port        65 (Port-channel2)
             Hello Time   2 sec Max Age 20 sec Forward Delay 15 sec
 
 Bridge ID Priority    4097   (priority 4096 sys-id-ext 1)
             Address     0011.2194.f600
             Hello Time   2 sec Max Age 20 sec Forward Delay 15 sec
             Aging Time 300
 
Interface        Role Sts Cost      Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Fa0/3            Desg FWD 19        128.3    P2p
Fa0/4            Desg FWD 19        128.4    Edge P2p
Po2              Root FWD 19        128.65   P2p
pc1 上连续 ping192.168.1.2 repeat 100000
r4#ping 192.168.1.2 repeat 100000
 
Type escape sequence to abort.
Sending 100000, 100-byte ICMP Echos to 192.168.1.2, timeout is 2 seconds:
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 
sw16 上将 f0/7shutdown 查看生成树的切换变化
 
sw16#show spanning-tree
 
VLAN0001
 Spanning tree enabled protocol ieee
 Root ID    Priority    1
             Address     0012.7f7d.11c0
             Cost        38
             Port        2 (FastEthernet0/2)
             Hello Time   2 sec Max Age 20 sec Forward Delay 15 sec
 
 Bridge ID Priority    32769 (priority 32768 sys-id-ext 1)
             Address     0018.b997.df00
             Hello Time   2 sec Max Age 20 sec Forward Delay 15 sec
             Aging Time 15
 
Interface        Role Sts Cost      Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Fa0/2            Root LIS 19        128.2    P2p //侦听状态
Fa0/4            Desg FWD 100       128.4    Shr
 
 
 
sw16#show spanning-tree
 
VLAN0001
 Spanning tree enabled protocol ieee
 Root ID    Priority    1
             Address     0012.7f7d.11c0
             Cost        19
             Port        6 (FastEthernet0/6)
             Hello Time   2 sec Max Age 20 sec Forward Delay 15 sec
 
 Bridge ID Priority    32769 (priority 32768 sys-id-ext 1)
             Address     0018.b997.df00
             Hello Time   2 sec Max Age 20 sec Forward Delay 15 sec
             Aging Time 300
 
Interface        Role Sts Cost      Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Fa0/2            Altn BLK 19        128.2    P2p //阻塞状态
Fa0/4            Desg FWD 100       128.4    Edge Shr
Fa0/6            Root FWD 19        128.6    P2p
 
f0/6shutdown 之后
r4#ping 192.168.1.2 repeat 100000
Type escape sequence to abort.
Sending 100000, 100-byte ICMP Echos to 192.168.1.2, timeout is 2 seconds:
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!................!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Success rate is 99 percent (16538/16554), round-trip min/avg/max = 1/3/56 ms
丢失 16 个数据包,时间为 32s
Sw16#debug spanning-tree evevts
04:14:54: STP: VLAN0001 Fa0/2 -> listening
04:15:09: STP: VLAN0001 Fa0/2 -> learning   //间隔15s
04:15:24: STP: VLAN0001 Fa0/2 -> forwarding  //间隔15s
 
 
 
sw16#show mac-address-table dynamic
          Mac Address Table
-------------------------------------------
 
Vlan    Mac Address       Type        Ports
----    -----------       --------    -----
 All    000d.28f1.0161    DYNAMIC     Fa0/6
  1    000d.28f1.0161    DYNAMIC     Fa0/2
   1    0010.7b81.6f57    DYNAMIC     Fa0/4
   1    0011.2194.f603    DYNAMIC     Fa0/2
Total Mac Addresses for this criterion: 4