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

MSTP+VRRP三层架构综合实验

一、实验目的

  1. 掌握VLAN、VRRP、STP和Eth-Trunk的基本配置方法。

  2. 实现内网与外网的通信,并确保网络的高可用性和冗余性。

  3. 理解DHCP、OSPF和NAT在网络中的应用。

二、实验环境

 

  1. 网络拓扑:如图所示,包含两台三层交换机(SW1、SW2)、两台二层交换机(SW3、SW4)、一台路由器(R1)、一台ISP路由器,以及四台PC。

  2. 设备配置

    • VLAN划分:VLAN2、VLAN3、VLAN10、VLAN20。

    • IP地址分配:内网使用172.16.0.0/16,外网使用12.0.0.0/24。

    • 冗余技术:VRRP用于网关冗余,STP用于环路保护,Eth-Trunk用于链路聚合。

三、需求分析

1. VLAN配置

  • 需求:内网IP地址使用172.16.0.0/16分配,所有PC通过DHCP获取IP地址。

  • 分析

    • VLAN用于隔离广播域,提高网络安全性。

    • VLAN2和VLAN3分别分配给不同的用户组,VLAN10和VLAN20用于连接三层交换机和路由器。

    • Access端口用于连接PC,Trunk端口用于交换机之间的通信。

2. 冗余与负载均衡

  • 需求:SW1和SW2之间互为备份,使用VRRP、STP和Eth-Trunk。

  • 分析

    • Eth-Trunk用于链路聚合,提高带宽和冗余性。

    • VRRP用于网关冗余,确保网络故障时的快速切换。

    • STP用于防止环路,优化流量。

3. DHCP服务

  • 需求:所有PC通过DHCP获取IP地址。

  • 分析

    • DHCP服务简化了IP地址管理,避免手动配置的错误。

    • 在SW1和SW2上配置DHCP,确保冗余性。

4. 路由与NAT

  • 需求:内外网通信,ISP只能配置IP地址。

  • 分析

    • OSPF用于内网路由,确保所有网段可达。

    • NAT用于将内网私有地址转换为公网地址,实现访问外网。

5. STP配置

  • 需求:配置STP,准备根桥。

  • 分析

    • MSTP用于优化VLAN流量,防止环路。

四、实验步骤

1. VLAN配置

二层交换机(SW3、SW4)
  • SW3配置

    [SW3]vlan batch 2 to 3
    [SW3-GigabitEthernet0/0/1]port link-type access
    [SW3-GigabitEthernet0/0/1]port default vlan 2
    [SW3-GigabitEthernet0/0/2]port link-type access
    [SW3-GigabitEthernet0/0/2]port default vlan 3
    [SW3]port-group group-member g0/0/3 g0/0/4
    [SW3-port-group]port link-type trunk
    [SW3-port-group]port trunk allow-pass vlan 2 3
  • SW4配置

    [SW4]vlan batch 2 to 3
    [SW4-GigabitEthernet0/0/1]port link-type access
    [SW4-GigabitEthernet0/0/1]port default vlan 2
    [SW4-GigabitEthernet0/0/2]port link-type access
    [SW4-GigabitEthernet0/0/2]port default vlan 3
    [SW4]port-group group-member g0/0/3 g0/0/4
    [SW4-port-group]port link-type trunk
    [SW4-port-group]port trunk allow-pass vlan 2 3
三层交换机(SW1、SW2)
  • SW1配置

    [SW1]vlan batch 2 3 10 20
    [SW1]int Eth-Trunk 0
    [SW1-Eth-Trunk0]port link-type trunk
    [SW1-Eth-Trunk0]port trunk allow-pass vlan 2 3
    [SW1]port-group group-member g0/0/3 to g0/0/4
    [SW1-port-group]port link-type trunk
    [SW1-port-group]port trunk allow-pass vlan 2 3
    [SW1]int g0/0/5
    [SW1-GigabitEthernet0/0/5]port link-type access
    [SW1-GigabitEthernet0/0/5]port default vlan 10
  • SW2配置

    [SW2]vlan batch 2 3 10 20
    [SW2]int Eth-Trunk 0
    [SW2-Eth-Trunk0]port link-type trunk
    [SW2-Eth-Trunk0]port trunk allow-pass vlan 2 3
    [SW2]port-group group-member g0/0/3 to g0/0/4
    [SW2-port-group]port link-type trunk
    [SW2-port-group]port trunk allow-pass vlan 2 3
    [SW2]int g0/0/5
    [SW2-GigabitEthernet0/0/5]port link-type access
    [SW2-GigabitEthernet0/0/5]port default vlan 20

2. Eth-Trunk配置

  • SW1配置

    [SW1]int Eth-Trunk 0
    [SW1-Eth-Trunk0]trunkport g0/0/1 g0/0/2
  • SW2配置

    [SW2]int Eth-Trunk 0
    [SW2-Eth-Trunk0]trunkport g0/0/1 g0/0/2

3. VLAN接口IP配置

  • SW1配置

    [SW1]int Vlanif 2
    [SW1-Vlanif2]ip address 172.16.0.1 255.255.255.192
    [SW1]int Vlanif 3
    [SW1-Vlanif3]ip address 172.16.0.65 255.255.255.192
    [SW1]int Vlanif 10
    [SW1-Vlanif10]ip address 172.16.0.129 255.255.255.192
  • SW2配置

    [SW2]int Vlanif 2
    [SW2-Vlanif2]ip address 172.16.0.2 255.255.255.192
    [SW2]int Vlanif 3
    [SW2-Vlanif3]ip address 172.16.0.66 255.255.255.192
    [SW2]int Vlanif 20
    [SW2-Vlanif20]ip address 172.16.0.193 255.255.255.192

 

4. 路由器配置

  • R1配置

    [R1-GigabitEthernet0/0/1]ip address 172.16.0.130 255.255.255.192
    [R1-GigabitEthernet0/0/2]ip address 172.16.0.194 255.255.255.192
    [R1-GigabitEthernet0/0/0]ip address 12.0.0.1 255.255.255.0
  • ISP配置

    [ISP-GigabitEthernet0/0/0]ip address 12.0.0.2 255.255.255.0
    [ISP-LoopBack0]ip address 2.2.2.2 255.255.255.0

 5. STP配置

  • SW1配置

    [SW1]stp enable
    [SW1]stp mode mstp
    [SW1]stp region-configuration
    [SW1-mst-region]region-name aa
    [SW1-mst-region]instance 1 vlan 2
    [SW1-mst-region]instance 2 vlan 3
    [SW1-mst-region]active region-configuration
    [SW1]stp instance 1 root primary
    [SW1]stp instance 2 root secondary
  • SW2配置

    [SW2]stp enable
    [SW2]stp mode mstp
    [SW2]stp region-configuration
    [SW2-mst-region]region-name aa
    [SW2-mst-region]instance 1 vlan 2
    [SW2-mst-region]instance 2 vlan 3
    [SW2-mst-region]active region-configuration
    [SW2]stp instance 1 root secondary
    [SW2]stp instance 2 root primary
  • SW3和SW4配置

    [SW3]stp enable
    [SW3]stp mode mstp
    [SW3]stp region-configuration
    [SW3-mst-region]region-name aa
    [SW3-mst-region]instance 1 vlan 2
    [SW3-mst-region]instance 2 vlan 3
    [SW3-mst-region]active region-configuration
    [SW3]port-group group-member GigabitEthernet 0/0/1 to 0/0/2
    [SW3-port-group]stp edged-port enable
    [SW3]stp bpdu-protection

dis stp brief 查看 sw1和sw2

 

6. VRRP配置

  • SW1配置

    [SW1-Vlanif2]vrrp vrid 1 virtual-ip 172.16.0.62
    [SW1-Vlanif2]vrrp vrid 1 priority 120
    [SW1-Vlanif2]vrrp vrid 1 track interface g0/0/5 reduced 30
    [SW1-Vlanif3]vrrp vrid 2 virtual-ip 172.16.0.126
  • SW2配置

    [SW2-Vlanif2]vrrp vrid 1 virtual-ip 172.16.0.62
    [SW2-Vlanif3]vrrp vrid 2 virtual-ip 172.16.0.126
    [SW2-Vlanif3]vrrp vrid 2 priority 120
    [SW2-Vlanif3]vrrp vrid 2 track interface Vlanif 20 reduced 30

 dis vrrp brief查看

7. DHCP配置

  • SW1配置

    [SW1]dhcp enable
    [SW1]ip pool vlan2
    [SW1-ip-pool-vlan2]network 172.16.0.0 mask 255.255.255.192
    [SW1-ip-pool-lan2]gateway-list 172.16.0.62
    [SW1]int Vlanif 2
    [SW1-Vlanif2]dhcp select global
    [SW1]ip pool vlan3
    [SW1-ip-pool-vlan3]network 172.16.0.64 mask 255.255.255.192
    [SW1-ip-pool-vlan3]gateway-list 172.16.0.126
    [SW1]int Vlanif 3
    [SW1-Vlanif3]dhcp select global
  • SW2配置

    [SW2]dhcp enable
    [SW2]ip pool vlan2
    [SW2-ip-pool-vlan2]network 172.16.0.0 mask 255.255.255.192
    [SW2-ip-pool-vlan2]gateway-list 172.16.0.62
    [SW2]int Vlanif 2
    [SW2-Vlanif2]dhcp select global
    [SW2]ip pool vlan3
    [SW2-ip-pool-vlan3]network 172.16.0.64 mask 255.255.255.192
    [SW2-ip-pool-vlan3]gateway-list 172.16.0.126
    [SW2]int Vlanif 3
    [SW2-Vlanif3]dhcp select global

查看各PC获取的ip 

 

8. OSPF配置

  • R1配置

    [R1]ospf 1 router-id 1.1.1.1
    [R1-ospf-1]area 0
    [R1-ospf-1-area-0.0.0.0]network 172.16.0.128 0.0.0.63
    [R1-ospf-1-area-0.0.0.0]network 172.16.0.192 0.0.0.63
  • SW1配置

    [SW1]ospf 1 router-id 2.2.2.2
    [SW1-ospf-1]area 0
    [SW1-ospf-1-area-0.0.0.0]network 172.16.0.128 0.0.0.63
    [SW1-ospf-1-area-0.0.0.0]network 172.16.0.0 0.0.0.63
    [SW1-ospf-1-area-0.0.0.0]network 172.16.0.64 0.0.0.63
  • SW2配置

    [SW2]ospf 1 router-id 3.3.3.3
    [SW2-ospf-1]area 0
    [SW2-ospf-1-area-0.0.0.0]network 172.16.0.192 0.0.0.63
    [SW2-ospf-1-area-0.0.0.0]network 172.16.0.0 0.0.0.63
    [SW2-ospf-1-area-0.0.0.0]network 172.16.0.64 0.0.0.63

9. NAT配置

  • R1配置

    [R1]ip route-static 0.0.0.0 0 12.0.0.2
    [R1]acl 2000
    [R1-acl-basic-2000]rule permit source 172.16.0.0 0.0.0.255
    [R1]int g0/0/0
    [R1-GigabitEthernet0/0/0]nat outbound 2000
    [R1]ospf 1
    [R1-ospf-1]default-route-advertise

五、实验结果

  1. VLAN通信测试

    • 同一VLAN内的PC可以互相通信。

    • 不同VLAN的PC通过三层交换机可以互通。

  2. VRRP冗余测试

    • 关闭SW1的VLAN2接口,SW2自动接管虚拟IP,PC仍能正常访问网络。




  3. DHCP测试

    • 所有PC通过DHCP成功获取IP地址。(上面已展示)

  4. 内外网通信测试

    • 内网PC可以访问ISP的LoopBack地址(2.2.2.2)。
       

       

        

http://www.dtcms.com/a/98297.html

相关文章:

  • ABAP FPM
  • 污水处理厂人员定位方案-UWB免布线高精度定位
  • 2025“钉耙编程”中国大学生算法设计春季联赛(4)题解
  • 华为交换综合实验——VRRP、MSTP、Eth-trunk、NAT、DHCP等技术应用
  • 如何使用K8S快速部署测试环境
  • 蓝桥刷题note11(好数)
  • 【湖北工业大学2025年ACM校赛(同步赛)】题解
  • 【数据结构】[特殊字符] 并查集优化全解:从链式退化到近O(1)的性能飞跃 | 路径压缩与合并策略深度实战
  • Windows catime 番茄时钟-v1.0.5-开源简洁的 Windows 倒计时工具,支持番茄时钟功能
  • Enhanced PEC-YOLO:电力施工场景安全装备检测的轻量化算法解析
  • 树莓派超全系列文档--(12)如何使用raspi-config工具其一
  • 处理 Linux 信号:进程控制与异常管理的核心
  • JSP(实验):带验证码的用户登录
  • JavaScript基础知识初步掌握
  • 【免费】2007-2019年各省地方财政文化体育与传媒支出数据
  • 19839 Dijkstra求最短路1
  • kettle从入门到精通 第九十三课 ETL之kettle kettle 调用web service接口5种方法,一文彻底搞懂
  • c++学习系列----005.c++模板(类模板)
  • 人工智能在自然语言处理中的应用:从理论到实践的探索
  • 在一个scss文件中定义变量,在另一个scss文件中使用
  • 【Linux】——文件(上)
  • 缓存使用纪要
  • mcp 接freecad画齿轮
  • 《Python Web网站部署应知应会》No4:基于Flask的调用AI大模型的高性能博客网站的设计思路和实战(上)
  • 阅读分析Linux0.11 /boot/bootsect.s
  • 显示文献是几区的免费科研插件easyScholar
  • 基于盛科CTC7132交换机核心模块
  • SpringBoot (一) 自动配置原理
  • 字典翻转教学
  • 买卖股票的最佳时机(121)