实验八生成树配置实验1【实验名称】生成树协议STP【实验目的】理解生成树协议STP的配置及原理。【背景描述】某学校为了开展计算机教学和网络办公,建立了一个计算机教室和一个校办公区,这两处的计算机网络通过两台交换机互连组成内部校园网,为了提高网络的可靠性,网络管理员用2条链路将交换机互连,现要在交换机上做适当配置,使网络避免环路。本实验以2台S2126G交换机为例,2台交换机分别命名为SwitchA,SwitchB。PC1与PC2在同一个网段,假设IP地址分别为192.168.0.137,192.168.0.136,网络掩码为255.255.255.0。【实现功能】使网络在有冗余链路的情况下避免环路的产生,避免广播风暴等。【实验拓扑】SwitchAPC1PC2SwitchBF0/3F0/1F0/1F0/2F0/2F0/3【实验设备】S2126G(2台)【实验步骤】第一步:在每台交换机上开启生成树协议.例如对SwitchA做如下配置:SwitchA#configureterminal!进入全局配置模式SwitchA(config)#spanning-tree!开启生成树协议SwitchA(config)#end验证测试:验证生成树协议已经开启SwitchA#showspanning-tree!显示交换机生成树的状态StpVersion:MSTPSysStpStatus:EnabledBaseNumPorts:24MaxAge:20HelloTime:2ForwardDelay:15BridgeMaxAge:20BridgeHelloTime:2BridgeForwardDelay:15MaxHops:20TxHoldCount:3PathCostMethod:LongBPDUGuard:DisabledBPDUFilter:Disabled######MST0vlansmapped:AllBridgeAddr:00d0.f8ef.9e89Priority:32768TimeSinceTopologyChange:0d:0h:0m:8sTopologyChanges:0DesignatedRoot:800000D0F8EF9D09RootCost:200000RootPort:Fa0/1CistRegionRoot:800000D0F8EF9E89CistPathCost:0SwitchA#showspanning-treeinterfacefastthernet0/1!显示交换机接口fastthernet0/1的状态PortAdminPortfast:DisabledPortOperPortfast:DisabledPortAdminLinkType:autoPortOperLinkType:point-to-pointPortBPDUGuard:DisabledPortBPDUFilter:Disabled######MST0vlansmapped:AllPortState:forwarding!显示接口fastthernet0/1处于转发(forwarding)状态PortPriority:128PortDesignatedRoot:800000D0F8EF9D09PortDesignatedCost:0PortDesignatedBridge:800000D0F8EF9D09PortDesignatedPort:8001PortForwardTransitions:1PortAdminPathCost:0PortOperPathCost:200000PortRole:rootPort第二步:设置生成树模式SwitchA(config)#spanning-treemodestp!设置生成树模式为STP(802.1D)验证测试:验证生成树协模式为802.1DSwitchA#showspanning-treeStpVersion:STPSysStpStatus:EnabledBaseNumPorts:24MaxAge:20HelloTime:2ForwardDelay:15BridgeMaxAge:20BridgeHelloTime:2BridgeForwardDelay:15MaxHops:20TxHoldCount:3PathCostMethod:LongBPDUGuard:DisabledBPDUFilter:DisabledBridgeAddr:00d0.f8ef.9e89Priority:32768TimeSinceTopologyChange:0d:0h:7m:0sTopologyChanges:0DesignatedRoot:800000D0F8EF9D09RootCost:200000RootPort:Fa0/1第三步:设置交换机的优先级SwitchA(config)#spanning-treepriority4096!设置交换机SwitchA的优先级为4096,数值最小的交换机为根交换机(也称根桥),交换机SwitchB的优先级采用默认优先级(32768),因此SwitchA将成为根交换机。验证测试:验证交换机SwitchA的优先级SwitchA#showspanning-treeStpVersion:STPSysStpStatus:EnabledBaseNumPorts:24MaxAge:20HelloTime:2ForwardDelay:15BridgeMaxAge:20BridgeHelloTime:2BridgeForwardDelay:15MaxHops:20TxHoldCount:3PathCostMethod:LongBPDUGuard:DisabledBPDUFilter:DisabledBridgeAddr:00d0.f8ef.9e89Priority:4096TimeSinceTopologyChange:0d:0h:0m:0sTopologyChanges:26DesignatedRoot:100000D0F8EF9E89RootCost:0RootPort:0第四步:综合验证测试1.验证交换机SwitchB的端口F0/1和F0/2的状态SwitchB#showspanning-treeinterfacefastEthernet0/1!显示SwitchB的端口fastthernet0/1的状态PortAdminPortfast:DisabledPortOperPortfast:DisabledPortAdminLinkType:autoPortOperLinkType:point-to-pointPortBPDUGuard:DisabledPortBPDUFilter:DisabledPortState:forwarding!SwitchB的端口fastthernet0/1处于转发(forwarding)状态PortPriority:128PortDesignatedRoot:200000D0F8EF9E89PortDesignatedCost:0PortDesignatedBridge:200000D0F8EF9E89PortDesignatedPort:8002PortForwardTransitions:22PortAdminPathCost:0PortOperPathCost:200000PortRole:rootPortSwitchB#showspanning-treeinterfacefastEthernet0/2!显示SwitchB的端口fastthernet0/2的状态PortAdminPortfast:DisabledPortOperPortfast:DisabledPortAdminLinkType:autoPortOperLinkType:point-to-pointPortBPDUGuard:DisabledPortBPDUFilter:DisabledPortState:discarding!SwitchB的端口fastthernet0/2处于阻塞(discarding)状态PortPriority:128PortDesignatedRoot:200000D0F8EF9E89PortDesignatedCost:200000PortDesignatedBridge:800000D0F8EF9D09PortDesignatedPort:8002PortForwardTransitions:39PortAdminPathCost:0PortOperPathCost:200000PortRole:alternatePort2.验证网络拓扑发生变化时,ping的丢包情况C:\ping192.168.0.136–t!从主机PC1pingPC2(用连续ping),然后拔掉SwitchA与SwitchB的端口F0/1之间的连线,观察丢包情况。显示结果如下:以上结果显示丢包数为30个。3.验证网络拓扑发生变化时,交换机SwitchB的端口2的状态变化,并观察生成树的收敛时间SwitchB#showspanning-treeinterfacefastEthernet0/2!显示SwitchB的端口fastthernet0/2的状态PortAdminPortfast:DisabledPortOperPortfast:DisabledPortAdminLinkType:autoPortOperLinkType:point-to-pointPortBPDUGuard:DisabledPortBPDUFilter:DisabledPortState:forwarding!SwitchB的端口fastthernet0/2转变为转发(forwarding)状态,转换时间大约32秒PortPriority:128PortDesignatedRoot:200000D0F8EF9E89PortDesignatedCost:200000PortDesignatedBridge:800000D0F8EF9D09PortDesignatedPort:8002PortForwardTransitions:40PortAdminPathCost:0PortOperPathCost:200000PortRole:rootPortSwitchB#showspanning-treeinterfacefastEthernet0/2!显示SwitchB的端口fastthernet0/2的状态2003-04-2723:27:24@5-LINKUPDOWN:Fa0/2changedstatetoup2003-04-2723:27:53@4-TOPOCHANGE:TopologyischangedPortAdminPortfast:DisabledPortOperPortfast:DisabledPortAdminLinkType:autoPortOperLinkType:point-to-pointPortBPDUGuard:DisabledPortBPDUFilter:DisabledPortState:discarding!SwitchB的端口fastthernet0/2转变为阻塞(discarding)状态,转换时间大约31秒PortPriority:128PortDesignatedRoot:200000D0F8EF9E89PortDesignatedCost:200000PortDesignatedBridge:800000D0F8EF9D09PortDesignatedPort:8002PortForwardTransitions:40PortAdminPathCost:0PortOperPathCost:200000PortRole:alternatePort【注意事项】锐捷交换机缺省是关闭spanning-tree的,因此,如果网络在物理上存在环路,则必须手工开启spanning-tree