资源描述
案例四 快速生成树解决环路问题
【背景描述】
某学校为了开展计算机教学和网络办公,建立了一个计算机教室和一个校办公区,这两处的计算机网络通过两台交换机互连组成内部校园网,为了提高网络的可靠性,网络管理员用2条链路将交换机互连,现要在交换机上做适当的配置,使网络避免环路。
【实现功能】
使网络有冗余链路的情况下避免环路的产生,避免广播风暴等。
【使用设备】
设备类型
设备名称
设备数量
交换机
Switch
2
路由器
三层交换机
双绞线
4
计算机
pc
2
【案例拓扑】
【实现步骤】
步骤1 交换机A的基本配置
Switch>en
Switch#configure terminal
Switch(config)#hostname SwitchA
SwitchA(config)#vlan 10
SwitchA(config-vlan)#name slaes
SwitchA(config-vlan)#exit
SwitchA(config)#interface fastEthernet 0/3
SwitchA(config-if)#switchport access vlan 10
SwitchA(config-if)#exit
SwitchA(config)#interface range fastEthernet 0/1-2
SwitchA(config-if-range)#switchport mode trunk
SwitchA(config-if-range)#exit
步骤2 交换机B的基本配置
Switch>en
Switch#configure terminal
Switch(config)#hostname SwitchB
SwitchB(config)#vlan 10
SwitchB(config-vlan)#name slaes
SwitchB(config-vlan)#exit
SwitchB(config)#interface fastEthernet 0/3
SwitchB(config-if)#switchport access vlan 10
SwitchB(config-if)#exit
SwitchB(config)#interface range fastEthernet 0/1-2
SwitchB(config-if-range)#switchport mode trunk
SwitchB(config-if-range)#exit
步骤3 配置快速生成树协议
SwitchA#configure terminal !进入全局配置模式
SwitchA(config)#spanning-tree !开启生成树协议
SwitchA(config)#spanning-tree mode rstp !指定生成树协议类型为RSTP
SwitchB#configure terminal !进入全局配置模式
SwitchB(config)#spanning-tree !开启生成树协议
SwitchB(config)#spanning-tree mode rstp !指定生成树协议类型为RSTP
验证测试:验证快速生成树协议已经开启
SwitchA#show spanning-tree !查看生成树的配置信
StpVersion : RSTP !生成树协议的版本
SysStpStatus : Enabled !生成树协议的运行状态,disable为关闭状态
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.f8bc.9835
Priority : 32768 !查看交换机的优先级
TimeSinceTopologyChange : 0d:0h:1m:53s
TopologyChanges : 0
DesignatedRoot : 800000D0F8BC9835
RootCost : 0 !交换机到达根交换机的开销,0代表交换机为根
RootPort : 0 !查看交换机上的根端口,0代表交换机为根
SwitchB#show spanning-tree !查看交换机B生成树的配置信息
StpVersion : RSTP !生成树协议的版本
SysStpStatus : Enabled
BaseNumPorts : 24 !生成树协议的运行状态,disable为关闭状态
MaxAge : 20
HelloTime : 2
ForwardDelay : 15
BridgeMaxAge : 20
BridgeHelloTime : 2
BridgeForwardDelay : 15
MaxHops : 20
TxHoldCount : 3
PathCostMethod : Long
BPDUGuard : Disabled
BPDUFilter : Disabled
BridgeAddr : 00d0.f8bf.fbbb
Priority : 32768 !查看交换机的优先级
TimeSinceTopologyChange : 0d:0h:2m:34s
TopologyChanges : 0
DesignatedRoot : 800000D0F8BC9835
RootCost : 200000 !交换机到达根交换机的开销
RootPort : Fa0/1 !查看交换机上的根端口
注:通过查看两台交换机的生成树信息发现,SwitchA为根交换机,SwitchB Fa0/1为根端口。
步骤4.设置交换机的优先级,指定SwitchB为根交换机
SwitchB(config)#spanning-tree priority 4096 !设置交换机优先级为4096
SwitchB(config)#^Z
验证测试:验证交换机SwitchB的优先级
SwitchB#show spanning-tree
StpVersion : RSTP
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.f8bf.fbbb
Priority : 4096 !查看交换机的优先级
TimeSinceTopologyChange : 0d:0h:17m:3s
TopologyChanges : 0
DesignatedRoot : 100000D0F8BFFBBB
RootCost : 0
RootPort : 0
SwitchA#show spanning-tree !查看交换机A生成树的配置信息
StpVersion : RSTP !生成树协议的版本
SysStpStatus : Enabled !生成树协议的运行状态,disable为关闭状态
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.f8bc.9835
Priority : 32768 !查看交换机的优先级
TimeSinceTopologyChange : 0d:0h:17m:19s
TopologyChanges : 0
DesignatedRoot : 100000D0F8BFFBBB
RootCost : 200000 !交换机到达根交换机的开销,0代表交换机为根
RootPort : Fa0/1 !查看交换机上的根端口,0代表交换机为根
验证测试:A.验证交换机SwitchA的端口1和端口2的状态。
SwitchA#show spanning-tree interface fastEthernet 0/1
!显示SwitchA端口fastEthernet 0/1的状态
PortAdminPortfast : Disabled
PortOperPortfast : Disabled
PortAdminLinkType : auto
PortOperLinkType : point-to-point
PortBPDUGuard: Disabled
PortBPDUFilter: Disabled
PortState : forwarding
!SwitchA的端口fastEthernet 0/1处于(forwarding)状态
PortPriority : 128
PortDesignatedRoot : 100000D0F8BFFBBB
PortDesignatedCost : 0
PortDesignatedBridge : 100000D0F8BFFBBB
PortDesignatedPort : 8001
PortForwardTransitions : 2
PortAdminPathCost : 0
PortOperPathCost : 200000
PortRole : rootPort !查看端口角色为根端口
SwitchA#show spanning-tree interface fastEthernet 0/2
!显示SwitchA端口fastEthernet 0/2的状态
PortAdminPortfast : Disabled
PortOperPortfast : Disabled
PortAdminLinkType : auto
PortOperLinkType : point-to-point
PortBPDUGuard: Disabled
PortBPDUFilter: Disabled
PortState : discarding
!SwitchA的端口fastEthernet 0/2处于(discarding)状态
PortPriority : 128
PortDesignatedRoot : 100000D0F8BFFBBB
PortDesignatedCost : 0
PortDesignatedBridge : 100000D0F8BFFBBB
PortDesignatedPort : 8002
PortForwardTransitions : 1
PortAdminPathCost : 0
PortOperPathCost : 200000
PortRole : alternatePort !SwitchA的F0/2端口为根端口的替换端口
验证测试:B.如果SwitchB与SwitchA的端口F0/1之间的链路DOWN掉,验证交换机SwitchA的端口2的状态,并观察状态转发时间。
SwitchA#show spanning-tree interface fastEthernet 0/2
PortAdminPortfast : Disabled
PortOperPortfast : Disabled
PortAdminLinkType : auto
PortOperLinkType : point-to-point
PortBPDUGuard: Disabled
PortBPDUFilter: Disabled
PortState : forwarding
!SwitchA的端口fastEthernet 0/2从阻塞(discarding)状态转换到转发(forwarding)状态,说明生成树协议此时采用了原先处理阻塞状态的冗余链路状态转换时间大约2秒
PortPriority : 128
PortDesignatedRoot : 100000D0F8BFFBBB
PortDesignatedCost : 0
PortDesignatedBridge : 100000D0F8BFFBBB
PortDesignatedPort : 8002
PortForwardTransitions : 2
PortAdminPathCost : 0
PortOperPathCost : 200000
PortRole : rootPort
验证测试:C.如果SwitchB与SwitchA之间的一条链路DOWN掉(如拔掉网线),验证交换机PC1与PC2仍能互相ping 通,并观察ping 的丢包情况。
以下为从PC1 ping PC2的结果(注:PC1的IP 地址为192.168.0.137,PC2的IP 地址为192.168.0.136).
C:\Documents and Settings\Administrator>ping 192.168.0.137
Pinging 192.168.0.137 with 32 bytes of data:
Reply from 192.168.0.137: bytes=32 time<1ms TTL=64
Reply from 192.168.0.137: bytes=32 time<1ms TTL=64
Reply from 192.168.0.137: bytes=32 time<1ms TTL=64
Reply from 192.168.0.137: bytes=32 time<1ms TTL=64
Ping statistics for 192.168.0.137:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 0ms, Average = 0ms
C:\Documents and Settings\Administrator>ping 192.168.0.137 -t !从主机PC1 ping PC2(用连续ping ),然后拔掉SwitchB与SwitchA的端口F0/1之间的连线,观察丢包情况
Pinging 192.168.0.137 with 32 bytes of data:
Reply from 192.168.0.137: bytes=32 time<1ms TTL=64
Reply from 192.168.0.137: bytes=32 time<1ms TTL=64
Reply from 192.168.0.137: bytes=32 time<1ms TTL=64
Reply from 192.168.0.137: bytes=32 time<1ms TTL=64
Reply from 192.168.0.137: bytes=32 time<1ms TTL=64
Reply from 192.168.0.137: bytes=32 time<1ms TTL=64
Reply from 192.168.0.137: bytes=32 time<1ms TTL=64
Reply from 192.168.0.137: bytes=32 time<1ms TTL=64
Reply from 192.168.0.137: bytes=32 time<1ms TTL=64
Reply from 192.168.0.137: bytes=32 time<1ms TTL=64
Reply from 192.168.0.137: bytes=32 time<1ms TTL=64
Reply from 192.168.0.137: bytes=32 time<1ms TTL=64
Reply from 192.168.0.137: bytes=32 time<1ms TTL=64
Reply from 192.168.0.137: bytes=32 time<1ms TTL=64
Reply from 192.168.0.137: bytes=32 time<1ms TTL=64
Reply from 192.168.0.137: bytes=32 time<1ms TTL=64
Reply from 192.168.0.137: bytes=32 time<1ms TTL=64
Reply from 192.168.0.137: bytes=32 time<1ms TTL=64
Request timed out.
Reply from 192.168.0.137: bytes=32 time<1ms TTL=64
Reply from 192.168.0.137: bytes=32 time<1ms TTL=64
Reply from 192.168.0.137: bytes=32 time<1ms TTL=64
Reply from 192.168.0.137: bytes=32 time<1ms TTL=64
Reply from 192.168.0.137: bytes=32 time<1ms TTL=64
Reply from 192.168.0.137: bytes=32 time<1ms TTL=64
Reply from 192.168.0.137: bytes=32 time<1ms TTL=64
Reply from 192.168.0.137: bytes=32 time<1ms TTL=64
Reply from 192.168.0.137: bytes=32 time<1ms TTL=64
Reply from 192.168.0.137: bytes=32 time<1ms TTL=64
Reply from 192.168.0.137: bytes=32 time<1ms TTL=64
以上结果显示丢包数为一个。
参考配置
SwitchA#show run !交换机SwitchA的全部配置
System software version : 1.61(2) Build Aug 31 2005 Release
Building configuration...
Current configuration : 291 bytes
!
version 1.0
!
hostname SwitchA
vlan 1
!
vlan 10
name slaes
!
spanning-tree mode rstp
spanning-tree
interface fastEthernet 0/1
switchport mode trunk
!
interface fastEthernet 0/2
switchport mode trunk
!
interface fastEthernet 0/3
switchport access vlan 10
!
end
SwitchB#show running-config !交换机SwitchB的全部配置
System software version : 1.61(2) Build Aug 31 2005 Release
Building configuration...
Current configuration : 328 bytes
!
version 1.0
!
hostname SwitchB
vlan 1
!
vlan 10
name slaes
!
spanning-tree mode rstp
spanning-tree
spanning-tree mst 0 priority 4096
interface fastEthernet 0/1
switchport mode trunk
!
interface fastEthernet 0/2
switchport mode trunk
!
interface fastEthernet 0/3
switchport access vlan 10
!
end
【注意事项】
1、锐捷交换机缺省是关闭spanning-tree 的,如果网络在物理上存在环路,则必须手工开启spanning-tree 。
2、锐捷全系列的交换机默认为MSTP协议,在配置时注意生成树协议的版本。
展开阅读全文