如下图为某小型企业网络结构图 默认要求阻塞交换机S2与S1之间的链路以免发生环路,当核心交换机S1与S2或S3之间出现链路故障时又能从S2和S3连通到核心交换机S1. 默认要求阻塞S2的GE0/0/2端口
自学华为生成树(STP)配置示例
9 }% N1 R; ?/ s0 o; c9 M具体配置 [s1]stp mode stp [s1]stp enable [s1]stp root primary #设置为根交换机 或 [s1]stp priority ? INTEGER<0-61440> Bridge priority, in steps of 4096 #数值越小越能称为根交换机 ----------------------- dis cu # sysname s1 # vlan batch 10 20 200 # stp mode stp stp instance 0 root primary #设置为根交换机 interface Vlanif1 # interface Vlanif10 ip address 192.168.10.254 255.255.255.0 # interface Vlanif20 ip address 192.168.20.254 255.255.255.0 # interface Vlanif200 ip address 192.168.200.254 255.255.255.0 # interface MEth0/0/1 # interface GigabitEthernet0/0/1 port link-type trunk port trunk allow-pass vlan 2 to 4094 # interface GigabitEthernet0/0/2 port link-type trunk port trunk allow-pass vlan 2 to 4094 # interface GigabitEthernet0/0/23 port link-type access port default vlan 200 # interface GigabitEthernet0/0/24 port link-type access # return -------------- display stp -------[CIST Global Info][Mode STP]------- CIST Bridge :0 .4c1f-cc0c-7730 # 0表示根交换机 Config Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20 Active Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20 CIST Root/ERPC :0 .4c1f-cc0c-7730 / 0 CIST RegRoot/IRPC :0 .4c1f-cc0c-7730 / 0 CIST RootPortId :0.0 BPDU-Protection :Disabled CIST Root Type :Primary root TC or TCN received :10 TC count per hello :0 STP Converge Mode :Normal Time since last TC :0 days 0h:23m:15s Number of TC :18 Last TC occurred :GigabitEthernet0/0/2 ------------------------- display stp brief MSTID Port Role STP State Protection 0 GigabitEthernet0/0/1 DESI FORWARDING NONE 0 GigabitEthernet0/0/2 DESI FORWARDING NONE 0 GigabitEthernet0/0/3 DESI FORWARDING NONE 0 GigabitEthernet0/0/23 DESI FORWARDING NONE ========================== / m, g4 k9 z( E: m+ @9 t4 ?
[s3]stp mode stp [s3]stp enable [s3-GigabitEthernet0/0/1]stp cost 1 #设置端口开销值 数值越小越能称为根端口,越大越可能成为阻塞端口 [s3-GigabitEthernet0/0/2]stp cost 20000000 #7为0 [s3]stp root secondary #设置为备份交换机 ---------- dis cu # sysname s3 # vlan batch 10 20 # stp mode stp stp instance 0 root secondary #备份交换机 # interface Vlanif1 # interface MEth0/0/1 # interface Ethernet0/0/22 port link-type access port default vlan 20 # interface GigabitEthernet0/0/1 port link-type trunk port trunk allow-pass vlan 2 to 4094 stp instance 0 cost 1 # interface GigabitEthernet0/0/2 port link-type trunk port trunk allow-pass vlan 2 to 4094 stp instance 0 cost 20000000 #7位0 # return ---------------------- display stp -------[CIST Global Info][Mode STP]------- CIST Bridge :4096 .4c1f-cc6a-9c8e # 4096 表示备份交换机 Config Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20 Active Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20 CIST Root/ERPC :0 .4c1f-cc0c-7730 / 1 CIST RegRoot/IRPC :4096 .4c1f-cc6a-9c8e / 0 CIST RootPortId :128.23 BPDU-Protection :Disabled CIST Root Type :Secondary root TC or TCN received :80 TC count per hello :0 STP Converge Mode :Normal Time since last TC :0 days 0h:26m:9s Number of TC :18 Last TC occurred :GigabitEthernet0/0/1 ---------------------- display stp brief MSTID Port Role STP State Protection 0 Ethernet0/0/22 DESI FORWARDING NONE # DESI 表示指定端口 0 GigabitEthernet0/0/1 ROOT FORWARDING NONE # root 表示根端口 0 GigabitEthernet0/0/2 DESI FORWARDING NONE ============================ [s2]stp mode stp [s2]stp enable [s2-GigabitEthernet0/0/2]stp cost 200000000 #8位0 [s2-GigabitEthernet0/0/1]stp cost 1 ----------------- [s2]dis cu # sysname s2 # vlan batch 10 20 # stp mode stp # interface Vlanif1 # interface Ethernet0/0/22 port link-type access port default vlan 10 # interface GigabitEthernet0/0/1 port link-type trunk port trunk allow-pass vlan 2 to 4094 stp instance 0 cost 1 # interface GigabitEthernet0/0/2 port link-type trunk port trunk allow-pass vlan 2 to 4094 stp instance 0 cost 200000000 # 8位0 # return [s2] -------------- [s2] dis stp -------[CIST Global Info][Mode STP]------- CIST Bridge :32768.4c1f-ccb2-e471 Config Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20 Active Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20 CIST Root/ERPC :0 .4c1f-cc0c-7730 / 1 CIST RegRoot/IRPC :32768.4c1f-ccb2-e471 / 0 CIST RootPortId :128.23 BPDU-Protection :Disabled TC or TCN received :139 TC count per hello :0 STP Converge Mode :Normal Time since last TC :0 days 0h:34m:35s Number of TC :16 Last TC occurred :GigabitEthernet0/0/1 ---------------- [s2]dis stp br MSTID Port Role STP State Protection 0 Ethernet0/0/22 DESI FORWARDING NONE 0 GigabitEthernet0/0/1 ROOT FORWARDING NONE 0 GigabitEthernet0/0/2 ALTE DISCARDING NONE # DISCARDING关闭表示已经阻塞
; t9 L- e' r, {7 |------------- 现在假如核心交换机S1与S3之间出现故障,用[s3-GigabitEthernet0/0/1]shutdown 模拟。
% }6 A! }: @* c. z
8 e2 }$ {4 V$ P7 @/ W- h& S7 a: P4 k现在来看STP状态) f9 x2 E2 b3 T7 W
[s3]dis stp br MSTID Port Role STP State Protection 0 Ethernet0/0/22 DESI FORWARDING NONE 0 GigabitEthernet0/0/2 ROOT FORWARDING NONE #已经切换为根端口 ----------------- [s2]dis st br MSTID Port Role STP State Protection 0 Ethernet0/0/22 DESI FORWARDING NONE 0 GigabitEthernet0/0/1 ROOT FORWARDING NONE 0 GigabitEthernet0/0/2 DESI FORWARDING NONE #以及从阻塞状态切换为转发状态 --------------
自学华为生成树(STP)配置示例
* I$ M7 }" F+ l- q, T+ _( q' z ]- k& D
|