网络拓扑结构图:
现在的趋势是IT越来越成为一种不可停顿的服务,经常对网络的可靠性要求很高。因此要求系统的核心、网络骨干不存在单点故障,主要服务器、网络设备在部件、设备上都要求有冗余。在这种背景下,STP(spanning-tree protocol)协议得到了广泛的应用。STP协议是一个二层的链路治理协议,它在提供链路冗余的同时防止网络产生环路。假如服务器上安装两块网卡,形成一个AFT(或ALB)组,一块连接主交换机,另一块连接备份主交换机,二级交换机都采用双链路分别上联到主交换机和备份主交换机,那么当主交换机失效时,工作站仍可通过备份主交换机上的备份网卡访问,服务不至于中断。
尽管STP是一种分布式算法,它要求网络中交换机的全部支持,但在实际工作中往往出现只有主干交换机支持STP协议,而二级交换机不支持STP的情况。
在去年我的同事曾经做过两个案例:
第一个,主交换机为一台cisco 4006和一台cisco 4003,二级交换机为inter 410T(不可网管交换机,不支持STP协议)。
第二个,主交换机为两台inter 480T,二级交换机为inter 460T和inter 410T。
最近,我也碰到了同样的情况。主交换机为两台3com 3300,二级交换机为四台华为2026B(替换原来的HUB,也不知道是谁推荐的,这种交换机也不支持STP协议,甚至连IP也不能配,VLAN也只能在本地划分)。甲方希望能够做到链路冗余,尽管我极力反对,反复强调网络收敛时间很长,甚至导致广播风暴的产生,但他还是决定要做。后来我知道他这样做是有道理的,机房一共两个人,一个人(领导)长期不来,另一个人显然更愿意面对外面的MM而不是机房里的设备。
步骤如下:
1.营业部网络结构中心采用两台3com 3300作为主干交换机,确认二级交换机此时都为单线上联到主交换机,备份主交换机没有连接主交换机。将主交换机的STP优先级设为0X6000,将副主交换机的STP优先级设为0X7000
Login: admin //用admin用户登录
PassWord:
Menu options: --------------3Com SuperStack 3 Switch 3300---------------
bridge - Administer bridging/VLANS
ethernet - Administer Ethernet ports
feature - Administer system features
ip - Administer IP
logout - Logout of the Command Line Interface
snmp - Administer SNMP
system - Administer system-level functions
Type ? for help.
-----------------------------------Switch 3300 (1)----------------------
Select menu option: bri //选择bridge菜单
Menu options: --------------3Com SuperStack 3 Switch 3300---------------
agingTime - Set the bridge address aging time
display - Display bridge information
multicastFiltering - Administer multicast filtering
port - Administer bridge ports
stpForwardDelay - Set the bridge Spanning Tree forward delay
stpHelloTime - Set the bridge Spanning Tree hello timer
stpMaxAge - Set the bridge Spanning Tree maximum age
stpPriority - Set the Spanning Tree bridge Priority
stpState - Enable/Disable Spanning Tree on a bridge
vlan - Administer VLANs
Type "q" to return to the previous menu or ? for help.
-----------------------------------Switch 3300 (1)----------------------
Select menu option (bridge): dis //选择display菜单
stpState: disabled agingTime: 1800 //现在stp协议状态是disabled
Time since topology change: 0 hrs 0 mins 0 seconds
Topology Changes: 0
Bridge Identifier: 8000 00051a5e92f8
Designated Root: 0000 000000000000
maxAge: 0 bridgeMaxAge: 20
helloTime: 0 bridgeHelloTime: 2
forwardDelay: 0 bridgeFwdDelay: 15
holdTime: 1 rootCost: 0
rootPort: No Port priority: 0x8000 //此时STP缺省优先级为32768
Menu options: --------------[1m3Com SuperStack 3 Switch 3300[0m---------------
agingTime - Set the bridge address aging time
display - Display bridge information
multicastFiltering - Administer multicast filtering
port - Administer bridge ports
stpForwardDelay - Set the bridge Spanning Tree forward delay
stpHelloTime - Set the bridge Spanning Tree hello timer
stpMaxAge - Set the bridge Spanning Tree maximum age
stpPriority - Set the Spanning Tree bridge Priority
stpState - Enable/Disable Spanning Tree on a bridge
vlan - Administer VLANs
Type "q" to return to the previous menu or ? for help.
-----------------------------------[1mprimary3300 (1)[0m----------------------
Select menu option (bridge): stpsta //选择stpState菜单
Enter new value (disable, enable)[disable]: en //enable STP协议
Select menu option (bridge): dis //display状态
stpState: enabled agingTime: 1800
Time since topology change: 0 hrs 0 mins 6 seconds
Topology Changes: 0
Bridge Identifier: 8000 00051a612eb8
Designated Root: 8000 00051a612eb8
maxAge: 20 bridgeMaxAge: 20
helloTime: 2 bridgeHelloTime: 2
forwardDelay: 15 bridgeFwdDelay: 15
holdTime: 1 rootCost: 0
rootPort: No Port priority: 0x8000
Select menu option (bridge): stppri //选择stpPriority菜单
Enter new hexadecimal value (0x0-0xffff) [0x8000]: 0x6000 //将优先值设为十六进制的6000,这将导致该交换机成为根交换机
Select menu option (bridge): stpfor //选择stpForwardDelay菜单
Enter new value in seconds (4-30) [15]: 9 //想改变ForwardDelay值为9,但不成功
Failed to Set value due to dependencies
//forward值是一个端口从它的spanning-tree协议的学习和聆听状态转到转发状态所等待的秒数。
此举主要是考虑参照CISCO的手册,此时网络直径为3,即任意两终端结点之间的最大跳数,执行spanning-tree vlan 1 root primary diameter 3将导致以下3条语句的出现,这是自动优化的结果
spanning-tree vlan 1 priority 24576
spanning-tree vlan 1 forward-time 9
spanning-tree vlan 1 max-age 12
Select menu option (bridge): stpmax //选择stpMaxAge菜单
Enter new value (6-40) [20]: 12
//maximum-aging time值是交换机在拓扑变化时在接收spanning-tree配置信息之前所等待的秒数。
Select menu option (bridge): dis //display状态
stpState: enabled agingTime: 1800
Time since topology change: 0 hrs 4 mins 8 seconds
Topology Changes: 0
Bridge Identifier: 6000 00051a612eb8
Designated Root: 6000 00051a612eb8
maxAge: 12 bridgeMaxAge: 12
helloTime: 2 bridgeHelloTime: 2
forwardDelay: 15 bridgeFwdDelay: 15
holdTime: 1 rootCost: 0
rootPort: No Port priority: 0x6000
-----------------------------------[1mprimary3300 (1)[0m----------------------
Select menu option (bridge): stpmax //为了稳妥起见,maxujum-aging time还是用缺省的20
Enter new value (6-40) [12]: 20
Select menu option (bridge): dis //再display状态
stpState: enabled agingTime: 1800
Time since topology change: 0 hrs 6 mins 2 seconds
Topology Changes: 0
Bridge Identifier: 6000 00051a612eb8
Designated Root: 6000 00051a612eb8
maxAge: 20 bridgeMaxAge: 20
helloTime: 2 bridgeHelloTime: 2
forwardDelay: 15 bridgeFwdDelay: 15
holdTime: 1 rootCost: 0
rootPort: No Port priority: 0x6000
-------------------------------------------------------------------------
elect menu option (bridge): dis //将备份主交换机也按照上述步骤设置STP优先级为ox7000
stpState: enabled agingTime: 1800
Time since topology change: 0 hrs 0 mins 42 seconds
Topology Changes: 0
Bridge Identifier: 7000 00051a5e92f8
Designated Root: 7000 00051a5e92f8
maxAge: 20 bridgeMaxAge: 20
helloTime: 2 bridgeHelloTime: 2
forwardDelay: 15 bridgeFwdDelay: 15
holdTime: 1 rootCost: 0
rootPort: No Port priority: 0x7000
---------------------------------------------------------------------------
2.连接冗余链路,调整备份主交换机上级联端口费用,使之处于转发状态。
Login: admin //用admin用户登录备份主交换机
Password:
Menu options: --------------[1m3Com SuperStack 3 Switch 3300[0m---------------
bridge - Administer bridging/VLANS
ethernet - Administer Ethernet ports
feature - Administer system features
ip - Administer IP
logout - Logout of the Command Line Interface
snmp - Administer SNMP
system - Administer system-level functions
Type ? for help.
----------------------------------[1msecondary3300 (1)[0m---------------------
Select menu option: bri //选择bridge菜单
Menu options: --------------[1m3Com SuperStack 3 Switch 3300[0m---------------
agingTime - Set the bridge address aging time
display - Display bridge information
multicastFiltering - Administer multicast filtering
port - Administer bridge ports
stpForwardDelay - Set the bridge Spanning Tree forward delay
stpHelloTime - Set the bridge Spanning Tree hello timer
stpMaxAge - Set the bridge Spanning Tree maximum age
stpPriority - Set the Spanning Tree bridge Priority
stpState - Enable/Disable Spanning Tree on a bridge
vlan - Administer VLANs
Type "q" to return to the previous menu or ? for help.
----------------------------------[1msecondary3300 (1)[0m---------------------
Select menu option (bridge): port //选择port菜单
Menu options: --------------[1m3Com SuperStack 3 Switch 3300[0m---------------
address - Administer bridge addresses
detail - Display detail information
stpCost - Set the Spanning Tree path cost
stpFastStart - Enable/Disable Fast Start per port
summary - Display summary information
vltMode - Enable/Disable VLT tagging on a port
Type "q" to return to the previous menu or ? for help.
----------------------------------[1msecondary3300 (1)[0m---------------------
Select menu option (bridge/port): summ //选择summary菜单
Select bridge port (1-24,all) [all]: all //查看所有端口STP状态
Port stpState fwdTransitions stpCost
--------------------------------------------------------------------
1 Disabled 1 18
2 Disabled 0 19
3 Disabled 0 19
4 Disabled 0 19
5 Disabled 0 19
6 Disabled 0 19
7 Disabled 0 19
8 Disabled 0 19
9 Disabled 0 19
10 Disabled 0 19
11 Disabled 0 19
12 Disabled 0 19
13 Disabled 0 19
14 Disabled 0 19
15 Disabled 0 19
16 Disabled 0 19
17 Disabled 0 19
18 Disabled 0 19
19 Disabled 0 19
20 Forwarding 1 18
21 Blocking 0 18
Enter
22 Blocking 0 18
23 Blocking 0 18
24 Blocking 0 18
-------------------------------------------------------------
此时端口是这样连接的,主交换机20-23口依次连接下面4台华为2026B的第23口,备份主交换机20-23口依次连接下面4台华为2026B的第24口,主交换机和备份主交换机之间都在第24口用一根反线级联。可以看到第20口处于转发状态,大致因为STP优先级都为ox7000,且端口费用都为18(百兆全双工),因此选取MAC地址最低的端口处于转发状态。将备份主交换机第20端口断开,可以看到第21端口处于转发状态了,如下所示。
----------------------------------[1msecondary3300 (1)[0m---------------------
Select menu option (bridge/port): summ
Select bridge port (1-24,all) [all]: all
Port stpState fwdTransitions stpCost
--------------------------------------------------------------------
1 Disabled 1 18
2 Disabled 0 19
3 Disabled 0 19
4 Disabled 0 19
5 Disabled 0 19
6 Disabled 0 19
7 Disabled 0 19
8 Disabled 0 19
9 Disabled 0 19
10 Disabled 0 19
11 Disabled 0 19
12 Disabled 0 19
13 Disabled 0 19
14 Disabled 0 19
15 Disabled 0 19
16 Disabled 0 19
17 Disabled 0 19
18 Disabled 0 19
19 Disabled 0 19
20 Disabled 1 18
21 Forwarding 1 18
Enter
22 Blocking 0 18
23 Blocking 0 18
24 Blocking 0 18
-------------------------------------------------------------------
将第20端口连上,再调整第24端口费用,可以看到第24端口处于learning状态。
Select menu option (bridge/port):
Menu options: --------------[1m3Com SuperStack 3 Switch 3300[0m---------------
address - Administer bridge addresses
detail - Display detail information
stpCost - Set the Spanning Tree path cost
stpFastStart - Enable/Disable Fast Start per port
summary - Display summary information
vltMode - Enable/Disable VLT tagging on a port
Type "q" to return to the previous menu or ? for help.
----------------------------------[1msecondary3300 (1)[0m---------------------
Select menu option (bridge/port): stpcost //选择stpcost菜单
Select bridge port (1-24): 24 //选择第24端口
Enter new value (1-65535) [18]: 12 //调整端口费用为12
Select menu option (bridge/port):
Menu options: --------------[1m3Com SuperStack 3 Switch 3300[0m---------------
address - Administer bridge addresses
detail - Display detail information
stpCost - Set the Spanning Tree path cost
stpFastStart - Enable/Disable Fast Start per port
summary - Display summary information
vltMode - Enable/Disable VLT tagging on a port
Type "q" to return to the previous menu or ? for help.
----------------------------------[1msecondary3300 (1)[0m---------------------
Select menu option (bridge/port): summ
Select bridge port (1-24,all) [all]:
Port stpState fwdTransitions stpCost
--------------------------------------------------------------------
1 Disabled 1 18
2 Disabled 0 19
3 Disabled 0 19
4 Disabled 0 19
5 Disabled 0 19
6 Disabled 0 19
7 Disabled 0 19
8 Disabled 0 19
9 Disabled 0 19
10 Disabled 0 19
11 Disabled 0 19
12 Disabled 0 19
13 Disabled 0 19
14 Disabled 0 19
15 Disabled 0 19
16 Disabled 0 19
17 Disabled 0 19
18 Disabled 0 19
19 Disabled 0 19
20 Blocking 1 18
21 Blocking 1 18
Enter
22 Blocking 0 18
23 Blocking 0 18
24 Learning 1 12 //处于learning状态
Select menu option (bridge/port): summ
Select bridge port (1-24,all) [all]: all
Port stpState fwdTransitions stpCost
--------------------------------------------------------------------
1 Disabled 1 18
2 Disabled 0 19
3 Disabled 0 19
4 Disabled 0 19
5 Disabled 0 19
6 Disabled 0 19
7 Disabled 0 19
8 Disabled 0 19
9 Disabled 0 19
10 Disabled 0 19
11 Disabled 0 19
12 Disabled 0 19
13 Disabled 0 19
14 Disabled 0 19
15 Disabled 0 19
16 Disabled 0 19
17 Disabled 0 19
18 Disabled 0 19
19 Disabled 0 19
20 Blocking 1 18
21 Blocking 1 18
Enter
22 Blocking 0 18
23 Blocking 0 18
24 Forwarding 2 12 //收敛后,处于forwarding状态
----------------------------------[1msecondary3300 (1)[0m---------------------
Select menu option (bridge): dis //查看备份主交换机STP状态
stpState: enabled agingTime: 1800
Time since topology change: 0 hrs 0 mins 47 seconds
Topology Changes: 5
Bridge Identifier: 7000 00051a5e92f8
Designated Root: 6000 00051a612eb8
maxAge: 20 bridgeMaxAge: 20
helloTime: 2 bridgeHelloTime: 2
forwardDelay: 15 bridgeFwdDelay: 15
holdTime: 1 rootCost: 12
rootPort: 24 priority: 0x7000
---------------------------------------------------------------------------------
Select menu option (bridge/port): summ //查看主交换机STP端口状态
Select bridge port (1-24,all) [all]: all
Port stpState fwdTransitions stpCost
--------------------------------------------------------------------
1 Disabled 0 19
2 Disabled 0 19
3 Disabled 0 19
4 Disabled 0 19
5 Disabled 0 19
6 Disabled 0 19
7 Disabled 0 19
8 Disabled 0 19
9 Disabled 0 19
10 Disabled 0 19
11 Disabled 0 19
12 Disabled 0 19
13 Disabled 0 19
14 Disabled 0 19
15 Disabled 0 19
16 Disabled 0 19
17 Disabled 0 19
18 Disabled 0 19
19 Disabled 0 19
20 Forwarding 1 18
21 Forwarding 1 18
Enter
22 Forwarding 1 18
23 Forwarding 1 18
24 Forwarding 2 18
-----------------------------------[1mprimary3300 (1)[0m----------------------
Select menu option (bridge): dis //查看主交换机STP状态
stpState: enabled agingTime: 1800
Time since topology change: 0 hrs 1 mins 42 seconds
Topology Changes: 6
Bridge Identifier: 6000 00051a612eb8
Designated Root: 6000 00051a612eb8
maxAge: 20 bridgeMaxAge: 20
helloTime: 2 bridgeHelloTime: 2
forwardDelay: 15 bridgeFwdDelay: 15
holdTime: 1 rootCost: 0
rootPort: No Port priority: 0x6000
-----------------------------------------------------------------------------
3.将直接连接终端的端口设为stpfaststart状态(相当于CISCO的portfast)
Menu options: --------------3Com SuperStack 3 Switch 3300---------------
address - Administer bridge addresses
detail - Display detail information
stpCost - Set the Spanning Tree path cost
stpFastStart - Enable/Disable Fast Start per port
summary - Display summary information
vltMode - Enable/Disable VLT tagging on a port
Type "q" to return to the previous menu or ? for help.
-----------------------------------primary3300 (1)----------------------
Select menu option (bridge/port): stpfa //选择stpfaststart菜单
Select bridge port (1-24) [1]: 1 //选择端口1
Enter new value (disabled,enabled) [disabled]: enable
再继续把主交换机和备份主交换机的所有直接连接终端工作站的端口都设为stpfaststart状态。
-----------------------------------------------------------------------------------------------
至此,设置完成。将主交换机电源拨掉,ping 服务器备份网卡,大约经过43秒恢复连通,相比起来收敛时间较长。(我的经验是全CISCO网络启用标准STP协议(相对于RSTP而言)和uplinkfast功能需时4-5秒,全3com网络的resilient links功能几乎是瞬时)不过这也是很好解释的,forward time 15秒加上maximum-aging time 20秒都需要35秒时间。将主交换机电源重新插上,大致需要相同时间恢复。反复试了两次,没有出现产生环路的情况。
要害在于理论上stp协议是一种分布式算法,它要求网络中交换机的全部支持。在二级交换机不支持STP的情况,它扮演的角色是什么?