VLAN和Trunk实验

news/2025/3/17 18:24:40/

VLAN和Trunk实验

实验拓扑

在这里插入图片描述

实验需求

1.按照图示给所有路由器(此处充当pc机)配置IP地址

2.SW1和SW2上分别创建vlan10和vlan20,要求R1和R3属于vlan10,R2和R4属于vlan20

3.SW1和SW2相连的接口配置类型为trunk类型,允许vlan10和vlan20通过

4.测试效果,同一vlan的路由器可以互通,不同vlan的路由器无法互通

实验步骤

1.路由器配置IP地址
在R1上
<H3C>system-view 
System View: return to User View with Ctrl+Z.
[H3C]sysname R1
[R1]int g0/0
[R1-GigabitEthernet0/0]ip address 192.168.1.1 24
[R1-GigabitEthernet0/0]display ip interface brief 
*down: administratively down
(s): spoofing  (l): loopback
Interface           Physical Protocol IP address/Mask    VPN instance Description  
GE0/0               up       up       192.168.1.1/24     --           --
GE0/1               down     down     --                 --           --
GE0/2               down     down     --                 --           --
GE5/0               down     down     --                 --           --
GE5/1               down     down     --                 --           --
GE6/0               down     down     --                 --           --
GE6/1               down     down     --                 --           --
Ser1/0              down     down     --                 --           --
Ser2/0              down     down     --                 --           --
Ser3/0              down     down     --                 --           --
Ser4/0              down     down     --                 --           --
[R1-GigabitEthernet0/0]在R2上
<H3C>system-view 
System View: return to User View with Ctrl+Z.
[H3C]sysname R2
[R2]int g0/0
[R2-GigabitEthernet0/0]ip address 192.168.1.2 24
[R2-GigabitEthernet0/0]display ip interface brief 
*down: administratively down
(s): spoofing  (l): loopback
Interface           Physical Protocol IP address/Mask    VPN instance Description  
GE0/0               up       up       192.168.1.2/24     --           --
GE0/1               down     down     --                 --           --
GE0/2               down     down     --                 --           --
GE5/0               down     down     --                 --           --
GE5/1               down     down     --                 --           --
GE6/0               down     down     --                 --           --
GE6/1               down     down     --                 --           --
Ser1/0              down     down     --                 --           --
Ser2/0              down     down     --                 --           --
Ser3/0              down     down     --                 --           --
Ser4/0              down     down     --                 --           --
[R2-GigabitEthernet0/0]在R3上
<H3C>system-view 
System View: return to User View with Ctrl+Z.
[H3C]sysname R3
[R3]int g0/0
[R3-GigabitEthernet0/0]ip address 192.168.1.3 24
[R3-GigabitEthernet0/0]display ip interface brief 
*down: administratively down
(s): spoofing  (l): loopback
Interface           Physical Protocol IP address/Mask    VPN instance Description  
GE0/0               up       up       192.168.1.3/24     --           --
GE0/1               down     down     --                 --           --
GE0/2               down     down     --                 --           --
GE5/0               down     down     --                 --           --
GE5/1               down     down     --                 --           --
GE6/0               down     down     --                 --           --
GE6/1               down     down     --                 --           --
Ser1/0              down     down     --                 --           --
Ser2/0              down     down     --                 --           --
Ser3/0              down     down     --                 --           --
Ser4/0              down     down     --                 --           --
[R3-GigabitEthernet0/0]在R4上
<H3C>system-view 
System View: return to User View with Ctrl+Z.
[H3C]sysname R4
[R4]int g0/0
[R4-GigabitEthernet0/0]ip address 192.168.1.4 24
[R4-GigabitEthernet0/0]display ip interface brief 
*down: administratively down
(s): spoofing  (l): loopback
Interface           Physical Protocol IP address/Mask    VPN instance Description  
GE0/0               up       up       192.168.1.4/24     --           --
GE0/1               down     down     --                 --           --
GE0/2               down     down     --                 --           --
GE5/0               down     down     --                 --           --
GE5/1               down     down     --                 --           --
GE6/0               down     down     --                 --           --
GE6/1               down     down     --                 --           --
Ser1/0              down     down     --                 --           --
Ser2/0              down     down     --                 --           --
Ser3/0              down     down     --                 --           --
Ser4/0              down     down     --                 --           --
[R4-GigabitEthernet0/0]
2.测试四台路由器是否互通
在R1上测试
[R1]ping 192.168.1.2
Ping 192.168.1.2 (192.168.1.2): 56 data bytes, press CTRL+C to break
56 bytes from 192.168.1.2: icmp_seq=0 ttl=255 time=1.322 ms
56 bytes from 192.168.1.2: icmp_seq=1 ttl=255 time=0.704 ms
56 bytes from 192.168.1.2: icmp_seq=2 ttl=255 time=0.649 ms
56 bytes from 192.168.1.2: icmp_seq=3 ttl=255 time=0.407 ms
56 bytes from 192.168.1.2: icmp_seq=4 ttl=255 time=0.492 ms--- Ping statistics for 192.168.1.2 ---
5 packet(s) transmitted, 5 packet(s) received, 0.0% packet loss
round-trip min/avg/max/std-dev = 0.407/0.715/1.322/0.322 ms
[R1]%Mar 13 15:33:42:421 2025 R1 PING/6/PING_STATISTICS: Ping statistics for 192.168.1.2: 5 packet(s) transmitted, 5 packet(s) received, 0.0% packet loss, round-trip min/avg/max/std-dev = 0.407/0.715/1.322/0.322 ms.[R1]ping 192.168.1.3
Ping 192.168.1.3 (192.168.1.3): 56 data bytes, press CTRL+C to break
56 bytes from 192.168.1.3: icmp_seq=0 ttl=255 time=2.937 ms
56 bytes from 192.168.1.3: icmp_seq=1 ttl=255 time=1.287 ms
56 bytes from 192.168.1.3: icmp_seq=2 ttl=255 time=1.324 ms
56 bytes from 192.168.1.3: icmp_seq=3 ttl=255 time=0.909 ms
56 bytes from 192.168.1.3: icmp_seq=4 ttl=255 time=1.273 ms--- Ping statistics for 192.168.1.3 ---
5 packet(s) transmitted, 5 packet(s) received, 0.0% packet loss
round-trip min/avg/max/std-dev = 0.909/1.546/2.937/0.712 ms
[R1]%Mar 13 15:33:46:677 2025 R1 PING/6/PING_STATISTICS: Ping statistics for 192.168.1.3: 5 packet(s) transmitted, 5 packet(s) received, 0.0% packet loss, round-trip min/avg/max/std-dev = 0.909/1.546/2.937/0.712 ms.[R1]ping 192.168.1.4
Ping 192.168.1.4 (192.168.1.4): 56 data bytes, press CTRL+C to break
56 bytes from 192.168.1.4: icmp_seq=0 ttl=255 time=2.350 ms
56 bytes from 192.168.1.4: icmp_seq=1 ttl=255 time=1.049 ms
56 bytes from 192.168.1.4: icmp_seq=2 ttl=255 time=1.099 ms
56 bytes from 192.168.1.4: icmp_seq=3 ttl=255 time=1.308 ms
56 bytes from 192.168.1.4: icmp_seq=4 ttl=255 time=1.046 ms--- Ping statistics for 192.168.1.4 ---
5 packet(s) transmitted, 5 packet(s) received, 0.0% packet loss
round-trip min/avg/max/std-dev = 1.046/1.370/2.350/0.499 ms
[R1]%Mar 13 15:33:50:508 2025 R1 PING/6/PING_STATISTICS: Ping statistics for 192.168.1.4: 5 packet(s) transmitted, 5 packet(s) received, 0.0% packet loss, round-trip min/avg/max/std-dev = 1.046/1.370/2.350/0.499 ms.
3.在交换机SW1和SW2上分别创建vlan10和vlan20,SW1和SW2都把g1/0/1接口加入vlan10,g1/0/2接口加入vlan20
在SW1上
<H3C>system-view 
System View: return to User View with Ctrl+Z.
[H3C]sysname SW1
[SW1]vlan 10
[SW1-vlan10]port g1/0/1
[SW1-vlan10]qu
[SW1]vlan 20
[SW1-vlan20]port g1/0/2
[SW1-vlan20]qu
[SW1]在SW2上
<H3C>system-view 
System View: return to User View with Ctrl+Z.
[H3C]sysname SW2
[SW2]vlan 10
[SW2-vlan10]port g1/0/1
[SW2-vlan10]qu
[SW2]vlan 20
[SW2-vlan20]port g1/0/2
[SW2-vlan20]qu
[SW2]
4.SW1和SW2的g1/0/3接口都配置为trunk,允许vlan10和vlan20通过
在SW1上把g1/0/3接口配置为Trunk类型,并允许vlan10和vlan20通过
[SW1]int g1/0/3
[SW1-GigabitEthernet1/0/3]port link-type trunk        		//将接口类型改为trunk
[SW1-GigabitEthernet1/0/3]port trunk permit vlan 10 20 		//放行vlan10和vlan20
[SW1-GigabitEthernet1/0/3]display this						//查看当前接口下配置信息
#
interface GigabitEthernet1/0/3port link-mode bridgeport link-type trunkport trunk permit vlan 1 10 20combo enable fiber
#
return
[SW1-GigabitEthernet1/0/3]在SW2上把g1/0/3接口配置为Trunk类型,并允许vlan10和vlan20通过
[SW2]int g1/0/3
[SW2-GigabitEthernet1/0/3]port link-type trunk
[SW2-GigabitEthernet1/0/3]port trunk permit vlan 10 20
[SW2-GigabitEthernet1/0/3]display this
#
interface GigabitEthernet1/0/3port link-mode bridgeport link-type trunkport trunk permit vlan 1 10 20combo enable fiber
#
return
[SW2-GigabitEthernet1/0/3]
5.测试结果,R1可以PING通R3,但无法PING通R2和R4
在R1上pingR2
[R1]ping 192.168.1.2
Ping 192.168.1.2 (192.168.1.2): 56 data bytes, press CTRL+C to break
Request time out
Request time out
Request time out
Request time out
Request time out--- Ping statistics for 192.168.1.2 ---
5 packet(s) transmitted, 0 packet(s) received, 100.0% packet loss
[R1]%Mar 13 15:44:47:912 2025 R1 PING/6/PING_STATISTICS: Ping statistics for 192.168.1.2: 5 packet(s) transmitted, 0 packet(s) received, 100.0% packet loss.在R1上pingR3
[R1]ping 192.168.1.3
Ping 192.168.1.3 (192.168.1.3): 56 data bytes, press CTRL+C to break
56 bytes from 192.168.1.3: icmp_seq=0 ttl=255 time=1.053 ms
56 bytes from 192.168.1.3: icmp_seq=1 ttl=255 time=0.615 ms
56 bytes from 192.168.1.3: icmp_seq=2 ttl=255 time=1.157 ms
56 bytes from 192.168.1.3: icmp_seq=3 ttl=255 time=1.041 ms
56 bytes from 192.168.1.3: icmp_seq=4 ttl=255 time=1.410 ms--- Ping statistics for 192.168.1.3 ---
5 packet(s) transmitted, 5 packet(s) received, 0.0% packet loss
round-trip min/avg/max/std-dev = 0.615/1.055/1.410/0.257 ms
[R1]%Mar 13 15:45:13:276 2025 R1 PING/6/PING_STATISTICS: Ping statistics for 192.168.1.3: 5 packet(s) transmitted, 5 packet(s) received, 0.0% packet loss, round-trip min/avg/max/std-dev = 0.615/1.055/1.410/0.257 ms.在R1上pingR4
[R1]ping 192.168.1.4
Ping 192.168.1.4 (192.168.1.4): 56 data bytes, press CTRL+C to break
Request time out
Request time out
Request time out
Request time out
Request time out--- Ping statistics for 192.168.1.4 ---
5 packet(s) transmitted, 0 packet(s) received, 100.0% packet loss
[R1]%Mar 13 15:45:46:526 2025 R1 PING/6/PING_STATISTICS: Ping statistics for 192.168.1.4: 5 packet(s) transmitted, 0 packet(s) received, 100.0% packet loss.

实验效果成功实现


http://www.ppmy.cn/news/1579870.html

相关文章

重生之我在学Vue--第13天 Vue 3 单元测试实战指南

重生之我在学Vue–第13天 Vue 3 单元测试实战指南 文章目录 重生之我在学Vue--第13天 Vue 3 单元测试实战指南前言一、测试环境搭建1.1 测试框架配置1.2 测试文件结构 二、组件测试实战2.1 基础渲染测试2.2 事件触发测试2.3 异步操作测试 三、Pinia Store测试3.1 Store初始化配…

IMA+DeepSeekR1+本地知识库撰写NOIP2008普及组T3【传球游戏】题解

目录 一、提问词 二、DeepSeekR1回复 题目描述 解题思路 实现代码 代码说明 三、说明 【IMADeepSeekR1本地知识库】撰写NOIP2008普及组复赛题解系列 1、IMADeepSeekR1本地知识库撰写NOIP2008普及组T1【ISBN 号码】题解-CSDN博客 2、IMADeepSeekR1本地知识库撰写NOIP200…

学习MDA规范_9.CORBA(公共对象请求代理架构)‌

‌CORBA&#xff08;公共对象请求代理架构&#xff09;‌ 是一种标准化的中间件技术&#xff0c;核心目标是实现跨编程语言、操作系统和硬件平台的分布式系统互操作。其核心价值在于‌语言无关性‌&#xff08;支持多种编程语言的对象交互&#xff09;、‌系统无关性‌&#xf…

基于Python+Flask+MySQL+HTML的爬取豆瓣电影top-250数据并进行可视化的数据可视化平台

FlaskMySQLHTML 项目采用前后端分离技术&#xff0c;包含完整的前端&#xff0c;以flask作为后端 Pyecharts、jieba进行前端图表展示 通过MySQL收集格列数据 通过Pyecharts制作数据图表 这是博主b站发布的详细讲解&#xff0c;感兴趣的可以去观看&#xff1a;【Python爬虫可…

conda的基本使用及pycharm里设置conda环境

创建conda环境 conda create --name your_env_name python3.8 把your_env_name换成实际的conda环境名称&#xff0c;python后边的根据自己的需要&#xff0c;选择python的版本。 激活conda环境 conda activate your_env_name 安装相关的包、库 conda install package_name …

《基于深度学习的高分卫星图像配准模型研发与应用》开题报告

目录 1. 选题的背景和意义 1.1 选题的背景 1.2 国内外研究现状 1.3 发展趋势 2&#xff0e;研究的基本内容 2.1 主要研究内容 &#xff08;1&#xff09;训练与测试数据集构建 &#xff08;2&#xff09;基于深度学习的高精度卫星影像配准模型 &#xff08;3&#xff0…

自动驾驶之心视觉语言导航!VLN算法与实战课程

课程地址 自动驾驶之心具身智能VLA算法与实战教程 自动驾驶之心视觉语言导航&#xff01;VLN算法与实战课程 自动驾驶之心Occupancy数据生成与模型实战教程 自动驾驶之心面向科研落地的3DGS全栈实战教程 自动驾驶之心面向自动驾驶的C实战教程(视频 答疑) 自动驾驶之心单目3D与单…

LLMs之CoD:《Chain of Draft: Thinking Faster by Writing Less》翻译与解读

LLMs之CoD&#xff1a;《Chain of Draft: Thinking Faster by Writing Less》翻译与解读 导读&#xff1a;这篇论文的核心是提出了一种名为“Chain of Draft”&#xff08;CoD&#xff0c;草稿链&#xff09;的新型提示策略&#xff0c;用于改进大型语言模型&#xff08;LLMs&a…