实验
拓扑
配置
正常情况下
命令
S1配置
1
2
3
4
5
6
7<Huawei>
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sys S1
[S1]stp mode stp
Info: This operation may take a few seconds. Please wait for a moment...done.
[S1]
S2配置
1
2
3
4
5
6
7<Huawei>
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sys S1
[S1]stp mode stp
Info: This operation may take a few seconds. Please wait for a moment...done.
[S1]
S3配置
1
2
3
4
5
6
7<Huawei>
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sys S3
[S3]stp mode stp
Info: This operation may take a few seconds. Please wait for a moment...done.
[S3]
S4配置
1
2
3
4
5
6<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sys S4
[S4]stp mode stp
Info: This operation may take a few seconds. Please wait for a moment...done.
[S4]
验证
S1为非根交换,1口是跟端口RP,2口是阻塞端口AP
1
2
3
4
5[S1]dis stp br
MSTID Port Role STP State Protection
0 GigabitEthernet0/0/1 ROOT FORWARDING NONE
0 GigabitEthernet0/0/2 ALTE DISCARDING NONE
[S1]
S2为跟交换,1口、2口都是指定端口DP
1
2
3
4
5[S2]dis stp brief
MSTID Port Role STP State Protection
0 GigabitEthernet0/0/1 DESI FORWARDING NONE
0 GigabitEthernet0/0/2 DESI FORWARDING NONE
[S2]
S3为非根交换,1口、3口、4口为指定端口DP,2口为跟端口
1
2
3
4
5
6
7[S3]dis stp brief
MSTID Port Role STP State Protection
0 GigabitEthernet0/0/1 DESI FORWARDING NONE
0 GigabitEthernet0/0/2 ROOT FORWARDING NONE
0 GigabitEthernet0/0/3 DESI FORWARDING NONE
0 GigabitEthernet0/0/4 DESI FORWARDING NONE
[S3]
S4为非根端口,1口为跟端口RP,2口为阻塞端口AP
1
2
3
4
5[S4]dis stp brief
MSTID Port Role STP State Protection
0 GigabitEthernet0/0/1 ROOT FORWARDING NONE
0 GigabitEthernet0/0/2 ALTE DISCARDING NONE
[S4]
按要求
将S1配置为根交换机
原理
跟交换机的选举是通过BID的优先级值、BID的MAC地址、PID的比较实现
命令
1
2
3[S1]stp priority 0
#或者
[S1]stp root primary
验证
将S2配置为备根交换机
原理
将S2的优先级的值修改我比S1大,但是比S3、S4小,缺省值是32768
命令
1
2
3[S2]stp priority 4096
# 或者
[S2]stp root secondary
验证
将S3的2口配置为阻塞端口(阻塞端口与指点端口之间对比)
原理
阻塞端口比较的是端口发送BPDU报文时,RPC值、端口BID的优先级值+MAC地址、端口PID的值
命令
1
2
3
4<S3>sys
Enter system view, return user view with Ctrl+Z.
[S3]int g0/0/1
[S3-GigabitEthernet0/0/1]stp cost 220000
验证
1
2
3
4
5
6
7
8
9[S3]dis stp brief
MSTID Port Role STP State Protection
0 GigabitEthernet0/0/1 ROOT FORWARDING NONE
# 2口的端口为阻塞端口
0 GigabitEthernet0/0/2 ALTE DISCARDING NONE
0 GigabitEthernet0/0/3 DESI DISCARDING NONE
0 GigabitEthernet0/0/4 DESI DISCARDING NONE
[S3]
将S4的1口配置为阻塞端口(阻塞端口与根端口进行对比)
原理
阻塞端口比较的是端口发送BPDU报文时,RPC值、端口BID的优先级值+MAC地址、端口PID的值
由于SW3的1口的开销值修改了,那么SW4交换到根交换的RPC值、BID的值都一致, 且SW4涉及确定根端口,所以需要看对端的PID-即SW3交换3口的PID
命令
1
2
3
4<S3>sys
Enter system view, return user view with Ctrl+Z.
[S3]int g0/0/3
[S3-GigabitEthernet0/0/3]stp port priority 144
验证
1
2
3
4
5[S4]dis stp brief
MSTID Port Role STP State Protection
0 GigabitEthernet0/0/1 ALTE DISCARDING NONE
0 GigabitEthernet0/0/2 ROOT DISCARDING NONE
[S4]
配置
图表
命令 | 备注 |
---|---|
stp mode {stp | mstp | rstp} | 配置STP模式,缺省是MSTP |
stp priority 4096 | 配置BID的优先级值,0~61440 都是4096倍数 |
stp root primary / secondary | 配置BID,自动修改BID的优先级值,指定主/备根交换机 |
stp pathcost-standard {dot1q-1998 | dot1q | legacy} |
配置路径开销值的标准 |
开销标准 | legacy:cost=1 802.1d标准:cost=1 802.1t标准:cost=1~200000000,默认 |
stp cost 10 | 修改STP开销 |
stp port priority 144 | 修改PID优先级的值,都是16的倍数 |
display stp [brief] | 显示STP配置信息和参数 |
display stp int g0/0/1 | 显示端口STP详细信息 |