当前位置: 首页 > news >正文

思科Packet Tracer 7.4 生成树协议(STP)配置与安全防护上机讲义

思科Packet Tracer 7.4 生成树协议(STP)配置与安全防护上机讲义

一、实验目的

  1. 理解STP/RSTP工作原理及网络环路危害
  2. 掌握交换机基础IP配置与管理
  3. 熟练配置RSTP并手动指定根桥
  4. 掌握BPDU Guard、Root Guard安全防护配置
  5. 验证STP状态及攻击防护效果

二、实验环境

  • 软件:Cisco Packet Tracer 7.4
  • 设备:3台Cisco 2960交换机(命名A、B、C)、1台PC(攻击测试用)
  • 拓扑:交换机A为主根桥,连接交换机B、C;交换机B、C互连形成冗余环网

三、IP规划

  • 交换机A:VLAN1 IP 192.168.1.1/24
  • 交换机B:VLAN1 IP 192.168.1.2/24
  • 交换机C:VLAN1 IP 192.168.1.3/24

四、基础配置(三台交换机通用,仅主机名/IP不同)

4.1 交换机A基础配置

# 进入特权模式Switch>enable Switch#configure terminal# 配置主机名Switch(config)#hostname A# 配置管理VLAN1接口IPA(config)#interface Vlan1A(config-if)#ip address 192.168.1.1 255.255.255.0A(config-if)#no shutdownA(config-if)#exit# 关闭多余端口(可选,增强稳定性)A(config)#interface range FastEthernet0/1-24A(config-if-range)#shutdownA(config-if-range)#exit# 保存配置A#write memory# 或A#copy running-config startup-config

4.2 交换机B基础配置

Switch>enable Switch#configure terminalSwitch(config)#hostname BB(config)#interface Vlan1B(config-if)#ip address 192.168.1.2 255.255.255.0B(config-if)#no shutdownB(config-if)#exitB(config)#interface range FastEthernet0/1-24B(config-if-range)#shutdownB(config-if-range)#exitB#write memory

4.3 交换机C基础配置

Switch>enable Switch#configure terminalSwitch(config)#hostname CC(config)#interface Vlan1C(config-if)#ip address 192.168.1.3 255.255.255.0C(config-if)#no shutdownC(config-if)#exitC(config)#interface range FastEthernet0/1-24C(config-if-range)#shutdownC(config-if-range)#exitC#write memory

五、RSTP配置(快速生成树协议)

5.1 交换机A(主根桥,优先级最高)

# 全局启用STPA(config)#spanning-tree# 切换为RSTP模式(默认PVST,RSTP收敛更快)A(config)#spanning-tree mode rapid-pvst# 设置优先级为4096(根桥优先级必须为4096倍数,数值越小优先级越高)A(config)#spanning-tree vlan 1 priority 4096

5.2 交换机B、C(默认优先级,备用桥)

# 交换机B配置B(config)#spanning-treeB(config)#spanning-tree mode rapid-pvst# 交换机C配置C(config)#spanning-treeC(config)#spanning-tree mode rapid-pvst

六、STP安全防护配置

6.1 BPDU Guard配置(接入端口防伪造BPDU攻击)

作用:接入端口启用PortFast+BPDU Guard,收到BPDU直接关闭端口

# 交换机A(所有接入端口,此处以Fa0/1-20为例)A(config)#interface range FastEthernet0/1-20A(config-if-range)#spanning-tree portfastA(config-if-range)#spanning-tree bpduguard enableA(config-if-range)#no shutdown# 交换机BB(config)#interface range FastEthernet0/1-20B(config-if-range)#spanning-tree portfastB(config-if-range)#spanning-tree bpduguard enableB(config-if-range)#no shutdown# 交换机CC(config)#interface range FastEthernet0/1-20C(config-if-range)#spanning-tree portfastC(config-if-range)#spanning-tree bpduguard enableC(config-if-range)#no shutdown

6.2 Root Guard配置(互联端口防非法根桥抢占)

作用:交换机互联端口启用Root Guard,收到更高优先级BPDU直接阻塞端口

# 交换机A互联端口(Fa0/23连接B,Fa0/24连接C)A(config)#interface FastEthernet0/23A(config-if)#spanning-tree rootguardA(config-if)#no shutdownA(config)#interface FastEthernet0/24A(config-if)#spanning-tree rootguardA(config-if)#no shutdown# 交换机B互联端口(Fa0/23连接A,Fa0/24连接C)B(config)#interface FastEthernet0/23B(config-if)#spanning-tree rootguardB(config-if)#no shutdownB(config)#interface FastEthernet0/24B(config-if)#spanning-tree rootguardB(config-if)#no shutdown# 交换机C互联端口(Fa0/23连接A,Fa0/24连接B)C(config)#interface FastEthernet0/23C(config-if)#spanning-tree rootguardC(config-if)#no shutdownC(config)#interface FastEthernet0/24C(config-if)#spanning-tree rootguardC(config-if)#no shutdown

七、配置验证

7.1 查看STP状态(确认A为根桥)

# 交换机A查看A#show spanning-tree vlan 1# 关键输出:# Root ID 优先级4096,本地为根桥# 交换机B查看B#show spanning-tree vlan 1# 关键输出:# Root ID 指向交换机A,端口为根端口# 交换机C查看C#show spanning-tree vlan 1# 关键输出:# Root ID 指向交换机A,端口为根端口

7.2 查看端口安全配置

# 查看BPDU Guard状态A#show spanning-tree summary# 查看Root Guard状态A#show interface FastEthernet0/23 spanning-tree

八、STP攻击防护测试

8.1 测试BPDU Guard(伪造BPDU攻击)

  1. 将PC连接到交换机B的Fa0/1端口(已启用BPDU Guard)
  2. 在PC上安装攻击工具(如Yersinia),发送伪造高优先级BPDU
  3. 查看交换机B端口状态:
B#show interface FastEthernet0/1 status# 结果:端口自动变为"Err-disabled"(错误禁用),防护生效

8.2 测试Root Guard(非法根桥抢占)

  1. 新增一台交换机D,优先级设为0(高于交换机A)
  2. 将交换机D连接到交换机A的Fa0/23端口(已启用Root Guard)
  3. 查看交换机A端口状态:
A#show spanning-tree vlan 1# 结果:Fa0/23端口被阻塞,交换机A仍为根桥,防护生效

九、实验总结

  1. RSTP通过阻塞冗余端口解决环路,根桥选举由优先级+MAC决定
  2. BPDU Guard保护接入端口,防止终端伪造BPDU破坏拓扑
  3. Root Guard保护核心端口,防止非法设备抢占根桥
  4. 网络安全需基础配置+安全特性结合,提升稳定性

十、常见问题排查

  1. 端口Err-disabled:BPDU攻击触发,用shutdown+no shutdown恢复
  2. 根桥异常:检查优先级配置,确保主根桥优先级最小
  3. 端口Down:确认no shutdown配置,物理连接正常

“”"

Cisco Packet Tracer 7.4 上机讲义:STP/RSTP 配置与安全防护

一、实验目的

  1. 理解 STP/RSTP 作用:防止二层环路、实现冗余。
  2. 掌握交换机基础配置:主机名、管理 VLAN IP。
  3. 配置 RSTP,指定根桥,控制拓扑。
  4. 配置BPDU Guard、Root Guard,防御 STP 攻击。
  5. 验证 STP 状态与防护效果。

二、实验拓扑

  • 交换机:A、B、C(Cisco 2960)
  • 连接:
    • A ↔ B
    • A ↔ C
    • B ↔ C
  • 管理 IP:
    • A:192.168.1.1/24
    • B:192.168.1.2/24
    • C:192.168.1.3/24

三、基础配置(三台交换机)

交换机 A

Switch>enable Switch#configure terminal Switch(config)#hostname A A(config)#interface Vlan1 A(config-if)#ip address 192.168.1.1 255.255.255.0 A(config-if)#no shutdown A(config-if)#exit A#write memory

交换机 B

Switch>enable Switch#configure terminal Switch(config)#hostname B B(config)#interface Vlan1 B(config-if)#ip address 192.168.1.2 255.255.255.0 B(config-if)#no shutdown B(config-if)#exit B#write memory ### 6.2 查看保护功能

show spanning-tree summary
show interface Fa0/23 spanning-tree

## 七、攻击测试(演示) ### 7.1 BPDU Guard PC 接入交换机接入端口,发送伪造 BPDU: - 端口进入 **Err-disabled**,环路阻断。 ### 7.2 Root Guard 接一台优先级更低的交换机到互联端口: - 端口被阻塞,**根桥保持为 A**。 ## 八、实验报告要求 1. 拓扑图、IP 规划 2. 完整配置 3. `show spanning-tree` 截图 4. 安全防护测试现象记录 5. 总结:RSTP、BPDU Guard、Root Guard 的作用 ---
http://www.jsqmd.com/news/856640/

相关文章:

  • 告别手动!用J-Flash批处理脚本+USB-HUB,实现多Jlink同时烧录STM32(附完整脚本)
  • 深入解析Cosmos IBC:跨链通信的核心标准、实战应用与未来展望
  • 从‘动物叫’到‘电机转’:我的Codesys面向对象编程踩坑实录与避坑指南
  • MXM-ACMA模块化GPU:AI边缘计算的高性能可升级解决方案
  • NISP的社会价值和高含金量!
  • CANape标定窗口被锁?三步排查工程配置陷阱
  • csp信奥赛C++高频考点专项训练之前缀和差分 --【一维前缀和】:“非常男女”计划
  • SEO数据可视化:用Python做让老板眼前一亮的报告
  • 别再为买硬件发愁了!手把手教你用Control Expert V15.0搭建M340/M580仿真环境(附ModbusTCP通信测试)
  • 深入解析ERC-20:代币标准的基石、演进与未来布局
  • MuleRun助力MakerChip-FPGA在线编程模拟仿真操练
  • 揭秘三亚兴嘉装饰到底怎么样
  • AI客流统计如何实现99%准确率?从3D视觉到ReID去重解析
  • 别再死磕论文了!用PyTorch复现StyleGAN,从代码层面理解风格混合与解耦
  • HMI实现多协议转OPC UA:低成本方案的技术原理与工程实践
  • Vivado IP核避坑指南:Distributed Memory Generator里COE文件初始化与复位信号的那些‘坑’
  • 2026年阿里云OpenClaw/Hermes Agent配置Token Plan新手友好流程
  • 当UART遇上EtherCAT:在STM32F401RE上实现实时调试与通信的平衡术
  • 模型替换易,工作流锁定难!AI 锁定效应转移,企业决策何去何从?
  • 零 Python 依赖!用 JavaCV + ONNX Runtime 把 YOLO 塞进生产环境
  • 从点检到全生命周期:设备管理体系能解决哪些场景痛点?一套设备管理体系的实战应用
  • tars 环境安装及开发部署
  • JiuwenSwarm Agent Swarm 测评体验:数据清洗 Agent 团队,让“脏数据”无处可藏
  • 2026商标律所怎么选?关键标准与实力机构参考 - 品牌排行榜
  • 一文总结C++运算符的使用方法
  • 2026年必看!10款降AI率工具大测评:教你AI降AI与免费降低AI率 - 降AI实验室
  • 手把手教你用STC89C52和DS1302做一个带按键调节的电子时钟(附完整代码)
  • Seraphine:如何通过智能战绩查询和BP辅助提升英雄联盟竞技体验
  • 【工业相机】大恒万兆网相机原生RS232串口调试|无需转换板、直连通信、最简接线教程(实测)
  • M10050 模组 陶瓷天线一体