当前位置:   article > 正文

eNSP RSTP实验

rstp实验

实验拓扑图

实验目的和需求

  1. 通过配置指定根交换机和备份根交换机、开启root-protection和tc-protection、将边缘端口设为不参与生成树计算的端口等实验操作,加强RSTP网络的稳定性和安全性,防止网络拓扑变化和BPDU攻击等问题。

  1. SW1作为指定根交换机,并开启root-protection(根保护)功能和tc-protection(防拓扑变化报文攻击的保护功能),为了防止其他交换机来破坏现稳定的网络环境。

  1. SW2作为备份根交换机,SW3开启BPDU保护功能,其他不参与选举的接口设为边缘端口,端口便不再参与生成树计算,从而帮助加快网络拓扑的收敛时间以及加强网络的稳定性。

注意

  • 端口需要配合BPDU保护功能使用,以防止收到其他交换机发送BPDU而导致端口被关闭或失去边缘属性

实验步骤

  1. 先配置SW1。


<code class="language-plaintext hljs">stp mode rstp
stp root primary 
stp tc-protection threshold 2
#
interface GigabitEthernet0/0/3
 stp root-protection</code>
  1. 配置SW2。


<code class="language-plaintext hljs">stp mode rstp
stp root secondary
#
interface GigabitEthernet0/0/3
 stp edged-port enable</code>
  1. 配置SW3。


<code class="language-plaintext hljs">stp edged-port default
stp mode rstp
stp bpdu-protection</code>
  1. 配置SW5,模拟SW5想要抢占指定交换机的场景。


<code class="language-plaintext hljs">stp root primary</code>

SW3的BPDU保护功能有效,GigabitEthernet0/0/4端口进入了Error-Down状态,防止了恶意攻击。

  1. 加一台SW4,模拟SW4来破坏现稳定的网络环境。


<code class="language-plaintext hljs">[SW3-GigabitEthernet0/0/4]
Mar 18 2023 15:42:23-08:00 SW3 %%01PHY/1/PHY(l)[0]:    GigabitEthernet0/0/4: change status to up
Mar 18 2023 15:42:23-08:00 SW3 %%01MSTP/4/BPDU_PROTECTION(l)[1]:This edged-port GigabitEthernet0/0/4 that enabled BPDU-Protection will be shutdown, because it received BPDU packet!
Mar 18 2023 15:42:24-08:00 SW3 %%01PHY/1/PHY(l)[2]:    GigabitEthernet0/0/4: change status to down
Mar 18 2023 15:42:30-08:00 SW3 DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25.191.3.1 configurations have been changed. The current change number is 1, the change loop count is 0, and the maximum number of records is 4095.</code>

收到BPDU时,接口进入down状态

在RSTP网络中,正常情况下,边缘端口不会收到RST BPDU,启用了BPDU保护功能后,如果有人伪造RST BPDU恶意攻击交换机,边缘端口将被Error-Down。
配置完成后,可以在任意视图下执行命令 display stp active ,根据回显中BPDU-Protection字段查看BPDU保护功能的使能状态。
配置BPDU保护功能后,如果希望边缘端口收到BPDU报文后恢复Up状态,可通过手工恢复或自动恢复两种方式实现。
  1. 查看SW1中各个端口的角色和状态。


<code class="language-plaintext hljs">[SW1]dis 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      ROOT</code>

结果:SW1的指定根交换机身份没有被抢占

  1. 查看SW2中各个端口的角色和状态


<code class="language-plaintext hljs">[SW2]dis stp brief 
 MSTID  Port                        Role  STP State     Protection
   0    GigabitEthernet0/0/1        ROOT  FORWARDING      NONE
   0    GigabitEthernet0/0/2        DESI  FORWARDING      NONE
   0    GigabitEthernet0/0/3        DESI  FORWARDING      NONE</code>
  1. 查看SW3中各个端口的角色和状态


<code class="language-plaintext hljs">[SW3]DIS STP brief 
 MSTID  Port                        Role  STP State     Protection
   0    GigabitEthernet0/0/1        ROOT  FORWARDING      NONE
   0    GigabitEthernet0/0/2        ALTE  DISCARDING      NONE
   0    GigabitEthernet0/0/3        DESI  FORWARDING      BPDU</code>
  1. 测试实验结果

配置pc的ip地址

假设SW2上的GigabitEthernet 0/0/2接口故障


<code class="language-plaintext hljs">[SW2]int GigabitEthernet 0/0/2
[SW2-GigabitEthernet0/0/2]shut    
[SW2-GigabitEthernet0/0/2]shutdown 
[SW2-GigabitEthernet0/0/2]
Mar 18 2023 16:01:22-08:00 SW2 %%01PHY/1/PHY(l)[0]:    GigabitEthernet0/0/2: cha
nge status to down
Mar 18 2023 16:01:23-08:00 SW2 DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25
.191.3.1 configurations have been changed. The current change number is 1, the c
hange loop count is 0, and the maximum number of records is 4095.</code>

pc还能ping通,可以说rstp实现了毫秒级切换

  1. 总结

  • RSTP可以快速收敛,通过使用Proposal/Agreement机制和同步机制,可以实现端口状态的快速切换,避免等待计时器超时。

  • RSTP简化了端口状态,只有Discarding、Learning和Forwarding三种状态,取消了Listening和Blocking状态。

  • RSTP增加了端口角色,除了根端口和指定端口外,还有Alternate端口和Backup端口作为备份路径。

  • RSTP引入了边缘端口的概念,边缘端口是与用户终端设备直接连接的指定端口,不参与生成树计算,可以直接进入Forwarding状态。

  • RSTP提供了保护功能,如根保护、BPDU保护和环路保护等,可以防止生成树拓扑被破坏或形成环路。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/weixin_40725706/article/detail/315745
推荐阅读
相关标签
  

闽ICP备14008679号