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

VLAN综合实验二

一.实验拓扑:

二.实验需求:

1.内网Ip地址使用172.16.0.0/分配                                 
2.sw1和SW2之间互为备份                               
3.VRRP/STP/VLAN/Eth-trunk均使用
4.所有Pc均通过DHCP获取IP地址
5.ISP只能配置IP地址
6.所有电脑可以正常访问IsP路由器环回

三.实验步骤---思路

1.首先,IP 地址规划要确保使用 172.16.0.0/12,需要合理分配子网。例如,VLAN2 和 VLAN3 可以使用 172.16.2.0/24 和 172.16.3.0/24。AR1 与 SW1、SW2 的连接可能需要单独的子网,比如 172.16.0.0/30 和 172.16.0.4/30。

2.然后,VLAN 划分方面,SW3 和 SW4 的 PC 接口需要分别加入 VLAN2 和 VLAN3。交换机间的连接使用 Trunk,并配置 Eth-trunk 聚合链路,提高带宽和冗余。

3.VRRP 配置在 SW1 和 SW2 的 VLAN 接口上,设置虚拟 IP 作为默认网关,优先级不同以实现主备切换。STP 启用 MSTP,防止环路,同时配置区域和实例。

4.DHCP 服务在 SW1 上配置,为 VLAN2 和 VLAN3 提供地址池。AR1 配置接口 IP 和环回地址,设置静态路由指向内网。SW1 和 SW2 配置默认路由指向 AR1。

5.测试部分需要验证 IP 获取、连通性、冗余切换和 STP 功能。需要确保所有步骤的代码正确,设备名称和接口名称准确,特别是 SW3 和 SW4 的连接。

6.最后,检查所有配置是否每一个条件,确保没有遗漏。例如,ISp 只能配置 IP 地址,所以不需要其他复杂配置。冗余链路和 Eth-trunk 的配置要正确,避免环路。

三.实验步骤---配置

1.创建VLAN

  • 在 SW1、SW2、SW3、SW4 上创建 VLAN2 和 VLAN3。
[SW1]vlan batch 2 3  // 在 SW1 上批量创建 VLAN2 和 VLAN3
[SW2]vlan batch 2 3
[SW3]vlan batch 2 3
[SW4]vlan batch 2 3

2.Eth - trunk 配置

  • 在 SW1 和 SW2 上创建 Eth - trunk 接口,并将它们之间互联的物理接口加入其中,实现链路聚合。
[SW1]interface Eth-Trunk 1
[SW1-Eth-Trunk1]mode lacp-static
[SW1-Eth-Trunk1]trunkport GigabitEthernet0/0/1 to GigabitEthernet0/0/2
[SW1-Eth-Trunk1]port link-type trunk
[SW1-Eth-Trunk1]port trunk allow-pass vlan 2 3

[SW2]interface Eth-Trunk 1
[SW2-Eth-Trunk1]mode lacp-static
[SW2-Eth-Trunk1]trunkport GigabitEthernet0/0/1 to GigabitEthernet0/0/2
[SW2-Eth-Trunk1]port link-type trunk
[SW2-Eth-Trunk1]port trunk allow-pass vlan 2 3    

3. VLAN 配置

  • 将连接 PC1 和 PC3 的接口设置为 access 模式并加入 VLAN2;将连接 PC2 和 PC4 的接口设置为 access 模式并加入 VLAN3。
SW3:
interface GigabitEthernet0/0/1  // PC1接口
port link-type access
port default vlan 2
interface GigabitEthernet0/0/2  // PC2接口
port link-type access
port default vlan 3

SW4:
interface GigabitEthernet0/0/1  // PC3接口
port link-type access
port default vlan 2
interface GigabitEthernet0/0/2  // PC4接口
port link-type access
port default vlan 3
  • 把交换机之间互联的接口设置为 trunk 模式,允许 VLAN2 和 VLAN3 的数据通过。
SW1:
interface GigabitEthernet0/0/3  // 连接SW3
port link-type trunk
port trunk allow-pass vlan 2 3
interface GigabitEthernet0/0/4  // 连接SW4
port link-type trunk
port trunk allow-pass vlan 2 3

SW2:
interface GigabitEthernet0/0/4  // 连接SW3
port link-type trunk
port trunk allow-pass vlan 2 3
interface GigabitEthernet0/0/3  // 连接SW4
port link-type trunk
port trunk allow-pass vlan 2 3

SW3:
interface GigabitEthernet0/0/3  // 连接SW1
port link-type trunk
port trunk allow-pass vlan 2 3
interface GigabitEthernet0/0/4  // 连接SW2
port link-type trunk
port trunk allow-pass vlan 2 3

SW4:
interface GigabitEthernet0/0/4  // 连接SW1
port link-type trunk
port trunk allow-pass vlan 2 3
interface GigabitEthernet0/0/3  // 连接SW2
port link-type trunk
port trunk allow-pass vlan 2 3

4. STP 配置

  • 在 SW1、SW2、SW3、SW4 上启用 STP 协议,选择合适的生成树模式( MSTP),防止网络中出现环路。
[SW1]stp mode mstp
[SW1]stp region-configuration
[SW1-mst-region]region-name STP-REGION
[SW1-mst-region]revision-level 1
[SW1-mst-region]instance 1 vlan 2
[SW1-mst-region]instance 2 vlan 3
[SW1-mst-region]active region-configuration

[SW2]stp mode mstp
[SW2]stp region-configuration
[SW2-mst-region]region-name STP-REGION
[SW2-mst-region]revision-level 1
[SW2-mst-region]instance 1 vlan 2
[SW2-mst-region]instance 2 vlan 3
[SW2-mst-region]active region-configuration

[SW3]stp mode mstp
[SW3]stp region-configuration
[SW3-mst-region]region-name STP-REGION
[SW3-mst-region]revision-level 1
[SW3-mst-region]instance 1 vlan 2
[SW3-mst-region]instance 2 vlan 3
[SW3-mst-region]active region-configuration

[SW4]stp mode mstp
[SW4]stp region-configuration
[SW4-mst-region]region-name STP-REGION
[SW4-mst-region]revision-level 1
[SW4-mst-region]instance 1 vlan 2
[SW4-mst-region]instance 2 vlan 3
[SW4-mst-region]active region-configuration    

  • 交换机1做组1的主根,做组2的备份根。交换机2做组2的主根,做组1的备份根

[sw1]stp instance 1 root primary     
[sw1]stp instance 2 root secondary    
 
[sw2]stp instance 1 root secondary 
[sw2]stp instance 2 root primary 

5.SVI配置

  •  SW1 和 SW2 上为 VLAN 2 和 VLAN 3 创建 SVI 接口,并配置 IP 地址
[SW1]interface Vlanif 2
[SW1-Vlanif2]ip address 172.16.2.1 255.255.255.0

[SW1]interface Vlanif 3
[SW1-Vlanif3]ip address 172.16.3.1 255.255.255.0

[SW2]interface Vlanif 2
[SW2-Vlanif2]ip address 172.16.2.2 255.255.255.0

[SW2]interface Vlanif 3
[SW2-Vlanif3]ip address 172.16.3.2 255.255.255.0

6.VRRP 配置

  • 分别为 Vlanif2 和 Vlanif3 配置 VRRP,设置虚拟 IP 地址,同时为 SW1 和 SW2 分配不同优先级,实现主备冗余。
[SW1]interface Vlanif 2
[SW1-Vlanif2]vrrp vrid 1 virtual-ip 172.16.2.254
[SW1-Vlanif2]vrrp vrid 1 priority 110
[SW1-Vlanif2]vrrp vrid 1 track int g0/0/1 reduced 11
[SW1-Vlanif2]dhcp select relay
[SW1-Vlanif2]dhcp relay server-ip 172.16.0.1

[SW1]interface Vlanif 3
[SW1-Vlanif3]vrrp vrid 2 virtual-ip 172.16.3.254
[SW1-Vlanif3]dhcp select relay
[SW1-Vlanif3]dhcp relay server-ip 172.16.0.1

[SW2]interface Vlanif 2
[SW2-Vlanif2]vrrp vrid 1 virtual-ip 172.16.2.254
[SW2-Vlanif2]dhcp select relay
[SW2-Vlanif2]dhcp relay server-ip 172.16.0.1

[SW2]interface Vlanif 3
[SW2-Vlanif3]vrrp vrid 2 virtual-ip 172.16.3.254
[SW2-Vlanif3]vrrp vrid 2 priority 110
[SW2-Vlanif3]vrrp vrid 2 track int g0/0/1 reduced 11
[SW2-Vlanif3]dhcp select relay
[SW2-Vlanif3]dhcp relay server-ip 172.16.0.1    

7. DHCP 配置

  • 为 VLAN2 和 VLAN3 分别创建 DHCP 地址池,指定网段、网关和 DNS 服务器地址,使 PC 能自动获取 IP 地址。
# 开启 DHCP 服务
[SW1] dhcp enable
# 创建 VLAN 2 的 DHCP 地址池
[SW1] ip pool vlan2_pool
# 配置可分配的 IP 地址范围
[SW1-ip-pool-vlan2_pool] network 172.16.2.0 mask 255.255.255.0
# 配置网关地址
[SW1-ip-pool-vlan2_pool] gateway-list 172.16.2.254
# 配置 DNS 服务器地址
[SW1-ip-pool-vlan2_pool] dns-list 8.8.8.8
# 创建 VLAN 3 的 DHCP 地址池
[SW1] ip pool vlan3_pool
# 配置可分配的 IP 地址范围
[SW1-ip-pool-vlan3_pool] network 172.16.3.0 mask 255.255.255.0
# 配置网关地址
[SW1-ip-pool-vlan3_pool] gateway-list 172.16.3.254
# 配置 DNS 服务器地址
[SW1-ip-pool-vlan3_pool] dns-list 8.8.8.8
# 进入 VLAN 2 的接口视图
[SW1] interface Vlanif 2
# 开启 DHCP 功能并选择全局地址池分配方式
[SW1-Vlanif2] dhcp select global
# 进入 VLAN 3 的接口视图
[SW1] interface Vlanif 3
# 开启 DHCP 功能并选择全局地址池分配方式
[SW1-Vlanif3] dhcp select global


# 开启 DHCP 服务
[SW2] dhcp enable
# 创建 VLAN 2 的 DHCP 地址池
[SW2] ip pool vlan2_pool
# 配置可分配的 IP 地址范围
[SW2-ip-pool-vlan2_pool] network 172.16.2.0 mask 255.255.255.0
# 配置网关地址
[SW2-ip-pool-vlan2_pool] gateway-list 172.16.2.254
# 配置 DNS 服务器地址
[SW2-ip-pool-vlan2_pool] dns-list 8.8.8.8
# 创建 VLAN 3 的 DHCP 地址池
[SW2] ip pool vlan3_pool
# 配置可分配的 IP 地址范围
[SW2-ip-pool-vlan3_pool] network 172.16.3.0 mask 255.255.255.0
# 配置网关地址
[SW2-ip-pool-vlan3_pool] gateway-list 172.16.3.254
# 配置 DNS 服务器地址
[SW2-ip-pool-vlan3_pool] dns-list 8.8.8.8
# 进入 VLAN 2 的接口视图
[SW2] interface Vlanif 2
# 开启 DHCP 功能并选择全局地址池分配方式
[SW2-Vlanif2] dhcp select global
# 进入 VLAN 3 的接口视图
[SW2] interface Vlanif 3
# 开启 DHCP 功能并选择全局地址池分配方式
[SW2-Vlanif3] dhcp select global

8. AR1 路由器配置

  • 为 AR1 与 SW1、SW2 连接的接口以及环回接口配置 IP 地址。
# 进入 GigabitEthernet0/0/0 接口配置模式,连接 ISP
[R1] interface GigabitEthernet0/0/0
# 配置 IP 地址 12.1.1.1,子网掩码 255.255.255.0
[R1-GigabitEthernet0/0/0] ip address 12.1.1.1 24
# 进入 GigabitEthernet0/0/1 接口配置模式,连接 SW1
[R1] interface GigabitEthernet0/0/1
# 配置 IP 地址 172.16.0.1,子网掩码 255.255.255.0
[R1-GigabitEthernet0/0/1] ip address 172.16.0.1 24
# 进入 GigabitEthernet2/0/0 接口配置模式,连接 SW2
[R1] interface GigabitEthernet2/0/0
# 配置 IP 地址 172.16.1.1,子网掩码 255.255.255.0
[R1-GigabitEthernet2/0/0] ip address 172.16.1.1 24

# 进入 GigabitEthernet0/0/0 接口配置模式,连接 R1
[ISP] interface GigabitEthernet0/0/0
# 配置 IP 地址 12.1.1.2,子网掩码 255.255.255.0
[ISP-GigabitEthernet0/0/0] ip address 12.1.1.2 24
# 进入 LoopBack0 接口配置模式
[ISP] interface LoopBack0
# 配置 IP 地址 6.6.6.6,子网掩码 255.255.255.0
[ISP-LoopBack0] ip address 6.6.6.6 24

# 创建 VLAN 4
[SW1] vlan 4
# 进入 VLAN 4 的 SVI 接口配置模式
[SW1] interface Vlanif 4
# 配置 IP 地址 172.16.0.2,子网掩码 255.255.255.0
[SW1-Vlanif1] ip address 172.16.0.2 24
# 进入 GigabitEthernet0/0/5 接口配置模式,连接 R1
[SW1] interface GigabitEthernet0/0/5
# 设置接口类型为 access 模式
[SW1-GigabitEthernet0/0/5] port link-type access
# 将接口加入 VLAN 4
[SW1-GigabitEthernet0/0/5] port default vlan 4

# 创建 VLAN 4
[SW2] vlan 4
# 进入 VLAN 4 的 SVI 接口配置模式
[SW2] interface Vlanif 4
# 配置 IP 地址 172.16.1.2,子网掩码 255.255.255.0
[SW2-Vlanif1] ip address 172.16.1.2 24
# 进入 GigabitEthernet0/0/5 接口配置模式,连接 R1
[SW2] interface GigabitEthernet0/0/5
# 设置接口类型为 access 模式
[SW2-GigabitEthernet0/0/5] port link-type access
# 将接口加入 VLAN 4
[SW2-GigabitEthernet0/0/5] port default vlan 4


文章转载自:
http://baryta.elldm.cn
http://adenoacanthoma.elldm.cn
http://backlog.elldm.cn
http://charman.elldm.cn
http://barman.elldm.cn
http://balsamine.elldm.cn
http://avp.elldm.cn
http://adultness.elldm.cn
http://baneful.elldm.cn
http://blunderbuss.elldm.cn
http://agility.elldm.cn
http://abby.elldm.cn
http://bracing.elldm.cn
http://acclimation.elldm.cn
http://bonny.elldm.cn
http://candour.elldm.cn
http://antimacassar.elldm.cn
http://boots.elldm.cn
http://atheroma.elldm.cn
http://adulteration.elldm.cn
http://acidhead.elldm.cn
http://beesting.elldm.cn
http://catachrestial.elldm.cn
http://ambivert.elldm.cn
http://bulhorn.elldm.cn
http://brunet.elldm.cn
http://cannulation.elldm.cn
http://branchial.elldm.cn
http://backing.elldm.cn
http://brickkiln.elldm.cn
http://www.dtcms.com/a/98976.html

相关文章:

  • Dart的变量以及内建类型
  • Megatron-LM中的deepseek-v3实现
  • 深度学习在测距模型中的应用
  • Redis 源码硬核解析系列专题 - 第三篇:核心数据结构之字典(Dict)
  • 未来村庄智慧灯杆:点亮乡村智慧生活​
  • Python列表(三)
  • 【Linux】B站黑马程序视频学习笔记(一)
  • Python 的未来:在多元变革中持续领跑
  • 第一天 Linux驱动程序简介
  • 考研408第七章:查找总结
  • 如何将 Java 应用做成 EXE 的可执行软件
  • DeepSeek 助力 Vue3 开发:打造丝滑的表格(Table)之添加行拖拽排序功能示例9,TableView16_09 嵌套表格拖拽排序
  • Redis 实现分布式锁详解
  • torch不能使用cuda的解决方案
  • c++位运算总结
  • 使用Process子类创建进程
  • C++编程学习笔记:函数相关特性、引用与编译流程
  • TraeAI结合Proteus实现AI编程并仿真一个复杂工业物联网控制系统的开发(视频)
  • 力扣刷题494. 目标和
  • 【超详细教程】2025年3月最新Pytorch安装教程(同时讲解安装CPU和GPU版本)
  • Python3...(中国工信出版)读书笔记(1)python语言基础补充
  • 地下管线三维建模软件工具MagicPipe3D V3.6.1
  • Vue2 使用 v-if、v-else、v-else-if、v-show 以及 v-has 自定义指令实现条件渲染
  • [C++面试] 智能指针面试点(重点)续1
  • 飞书电子表格自建应用
  • JAVA反序列化深入学习(九):CommonsCollections7与CC链总结
  • 直接快速安装pytorch的cpu版本,在我的的 Python 3.8 + 虚拟环境 gdn 中安装
  • QT操作Word文档
  • The Rust Programming Language 学习 (七)
  • Windows 11系统下Kafka的详细安装与启动指南(JDK 1.8)