实验9 生成树协议STP
- 格式:doc
- 大小:126.50 KB
- 文档页数:5
实验九 生成树协议STP(IEEE 802.1d)的配置
实验名称:
生成树协议STP(IEEE 802.1d)的配置。
实验目的:
理解生成树协议STP的配置及原理。
技术原理:
生成树协议(spanning-tree),作用是在交换网络中提供冗余备份链路,并解决交换网络中的环路问题。是利用SPA(生成树算法),在存在交换环路的网络中生成一个没有环路的树型网络,运用该算法将交换网络冗余的备份链路逻辑上断开,当主链路有问题时能自动切换到备份链路,保证数据的正常转发。
生成树协议的工作过程:
1、选举Bridge ID最小的为根交换机(RootBridge)
2、所有非根交换机选择一条到达根交换机的最短路径
3、所有非根交换机产生一个根端口
4、每个LAN确定指定端口
5、将所有根端口和指定端口设为转发状态
6、将其他端口设为阻塞状态
实现功能:
使网络在有冗余链路的情况下避免环路的产生,避免广播风暴等。
实验设备:
S2126G二台,PC二台,直连线四根。
实验拓朴:
实验步骤:
1.交换机1的基本配置。(创建vlan 10,并把端口0/5划分到vlan 10)
Switch>enable 14
Switch# configure terminal
Switch(config)#hostname switch1
Switch1(config)#vlan 10
Switch1(config-vlan)# name test10
Switch1(config-vlan)# exit
Switch1(config)# int fa 0/5
Switch1(config-if)#switchport access vlan 10
Switch1(config-if)# exit
Switch1(config)#interface range fastethernet 0/1-2 !进入接口0/1和0/2
Switch1(config-if-range)#switchport mode trunk
2.交换机2的基本配置。(创建vlan 10,并把端口0/5划分到vlan 10)
Switch>enable 14
Switch# configure terminal
Switch(config)#hostname switch2
Switch2(config)#vlan 10
Switch2(config-vlan)# name test10
Switch2(config-vlan)# exit
Switch2(config)# int fa 0/5
Switch2(config-if)#switchport access vlan 10
Switch2(config-if)# exit
Switch2(config)#interface range fastethernet 0/1-2 !进入接口0/1和0/2
Switch2(config-if-range)#switchport mode trunk
3.配置生成树协议
Switch1#conf t F0/1
F0/5
NIC F0/5
NIC F0/2 F0/1
F0/2 Switch1(config)#spanning-tree !开启生成树协议。
Switch1(config)#spanning-tree mode stp ! 指定生成树协议的类型为STP。
Switch2#conf t
Switch2(config)#spanning-tree !开启生成树协议。
Switch2(config)#spanning-tree mode stp ! 指定生成树协议的类型为STP。
Switch1#show spanning-tree !查看生成树的配置信息。
StpVersion : STP
SysStpStatus : Enabled
BaseNumPorts : 24
MaxAge : 20
HelloTime : 2
ForwardDelay : 15
BridgeMaxAge : 20
BridgeHelloTime : 2
BridgeForwardDelay : 15
MaxHops : 20
TxHoldCount : 3
PathCostMethod : Long
BPDUGuard : Disabled
BPDUFilter : Disabled
BridgeAddr : 00d0.f88c.404c
Priority : 32768
TimeSinceTopologyChange : 0d:0h:14m:3s
TopologyChanges : 0
DesignatedRoot : 800000D0F88C404C
RootCost : 0
RootPort : 0
4. 设置交换机的优先级,指定switch1为根交换机。
Switch1(config)#spanning-tree priority 4096
5. 查看switch2的端口1和端口2的状态。
说明:Switch1与switch2的fa0/1和fa0/2连线前显示如下:
PortAdminPortfast : Disabled
PortOperPortfast : Disabled
PortAdminLinkType : auto
PortOperLinkType : point-to-point
PortBPDUGuard: Disabled
PortBPDUFilter: Disabled
PortState : discarding
PortPriority : 128
PortDesignatedRoot : 0000000000000000
PortDesignatedCost : 0
PortDesignatedBridge : 0000000000000000 PortDesignatedPort : 0000
PortForwardTransitions : 0
PortAdminPathCost : 0
PortOperPathCost : 0
PortRole : disabledPort
Switch2#show spanning-tree interface fa 0/1 ! fa 0/1是转发(forwording)状态。(根端口)
PortAdminPortfast : Disabled
PortOperPortfast : Disabled
PortAdminLinkType : auto
PortOperLinkType : point-to-point
PortBPDUGuard: Disabled
PortBPDUFilter: Disabled
PortState : forwarding
PortPriority : 128
PortDesignatedRoot : 100000D0F87C051D
PortDesignatedCost : 0
PortDesignatedBridge : 100000D0F87C051D
PortDesignatedPort : 8001
PortForwardTransitions : 1
PortAdminPathCost : 0
PortOperPathCost : 200000
PortRole : rootPort
Switch2#show spanning-tree interface fa 0/2 !fa 0/2是阻塞(discarding)状态。(替换端口)
PortAdminPortfast : Disabled
PortOperPortfast : Disabled
PortAdminLinkType : auto
PortOperLinkType : point-to-point
PortBPDUGuard: Disabled
PortBPDUFilter: Disabled
PortState : discarding
PortPriority : 128
PortDesignatedRoot : 100000D0F87C051D
PortDesignatedCost : 0
PortDesignatedBridge : 100000D0F87C051D
PortDesignatedPort : 8002
PortForwardTransitions : 0
PortAdminPathCost : 0
PortOperPathCost : 200000
PortRole : alternatePort
Switch1#show spanning-tree interface fa 0/1 !
Switch1与switch2连线后显示如下:
PortAdminPortfast : Disabled PortOperPortfast : Disabled
PortAdminLinkType : auto
PortOperLinkType : point-to-point
PortBPDUGuard: Disabled
PortBPDUFilter: Disabled
PortState : forwarding
PortPriority : 128
PortDesignatedRoot : 100000D0F87C051D
PortDesignatedCost : 0
PortDesignatedBridge : 100000D0F87C051D
PortDesignatedPort : 8001
PortForwardTransitions : 1
PortAdminPathCost : 0
PortOperPathCost : 200000
PortRole : designatedPort
Switch1#show spanning-tree interface fa 0/2
PortAdminPortfast : Disabled
PortOperPortfast : Disabled
PortAdminLinkType : auto
PortOperLinkType : point-to-point
PortBPDUGuard: Disabled
PortBPDUFilter: Disabled
PortState : forwarding
PortPriority : 128
PortDesignatedRoot : 100000D0F87C051D
PortDesignatedCost : 0
PortDesignatedBridge : 100000D0F87C051D