计算机网络实验二 虚拟局域网.docx
《计算机网络实验二 虚拟局域网.docx》由会员分享,可在线阅读,更多相关《计算机网络实验二 虚拟局域网.docx(8页珍藏版)》请在冰豆网上搜索。
![计算机网络实验二 虚拟局域网.docx](https://file1.bdocx.com/fileroot1/2022-11/25/d3fb2dae-10bb-442f-a9a1-397081bdf34a/d3fb2dae-10bb-442f-a9a1-397081bdf34a1.gif)
计算机网络实验二虚拟局域网
实验二虚拟局域网
实验2.1
一、实验目的
理解PortVlan的配置。
二、实验容
通过划分PORTVLAN实现本交换端口隔离。
三、实验拓扑
Switch
PC1PC2
四、实验设备
S2126G(1台)
五、实验步骤
第一步:
在未划VLAN前两台PC互相ping可以通。
第二步:
创立VLAN。
Switch#configureterminal!
进入交换机全局配置模式。
Switch(config)#vlan10!
创立vlan10。
Switch(config-vlan)#nametest10!
将Vlan10命名为test10。
Switch(config)#vlan20!
创立vlan20。
Switch(config-vlan)#nametest20!
将Vlan20命名为test20。
第三步:
将接口分配到VLAN。
Switch(config)#interfacefastethernet0/5!
进入fastethernet0/5的接口配置模式。
Switch(config-if)#switchaccessvlan10!
将fastethernet0/5端口参加vlan10中。
Switch(config)#interfacefastethernet0/15!
进入fastethernet0/15的接口配置模式。
Switch(config-if)#switchaccessvlan20!
将fastethernet0/15端口参加
vlan20中。
第四步:
两台PC互相ping不通。
验证测试:
Switch#showvlan
VLANNameStatusPorts
----------------------------------------------------------------------------
1defaultactiveFa0/1,Fa0/2,Fa0/3
Fa0/4,Fa0/6,Fa0/7
Fa0/8,Fa0/9,Fa0/10
Fa0/11,Fa0/12,Fa0/13
Fa0/14,Fa0/16,Fa0/17
Fa0/18,Fa0/19,Fa0/20
Fa0/21,Fa0/22,Fa0/23
Fa0/24
10test10activeFa0/5
20test20activeFa0/15
如下列图在未划VLAN前两台PC互相ping可以通。
但是划分VLAN之后两台PC互相ping不通。
六、实验心得
实验一的时候那个交换机根本配置的实验根本看不懂,一直输入错误,原来要先输入enable,然后那些前缀的东西,例如Switch(config)#、Switch(config-if)#,你进入了下一层,就要输入e*it退出返回上一层,不然就会错误。
对那些语句也有了更好的理解。
实验2.2
一、实验目的
理解VLAN如何跨交换机实现。
二、实验容
使在同一VLAN里的计算机系统能跨交换机进展相互通信,而在不同VLAN里的计算机系统不能进展相互通信。
三、
实验拓扑
SwitchASwitchB
PC1PC3
PC2
四、实验设备
S2126G(2台)
五、实验步骤
第一步:
在交换机SwitchA上创立Vlan10,并将0/5端口划分到Vlan10中。
SwitchA#configureterminal!
进入全局配置模式。
SwitchA(config)#vlan10!
创立Vlan10。
SwitchA(config-vlan)#namesales!
将Vlan10命名为sales。
SwitchA(config-vlan)#e*it
SwitchA(config)#interfacefastethernet0/5!
进入接口配置模式。
SwitchA(config-if)#switchportaccessvlan10!
将0/5端口划分到Vlan10。
验证测试:
验证已创立了Vlan10,并将0/5端口已划分到Vlan10中。
SwitchA#showvlanid10
VLANNameStatusPorts
----------------------------------------------------------------------------
10salesactiveFa0/5
第二步:
在交换机SwitchA上创立Vlan20,并将0/15端口划分到Vlan20中。
SwitchA(config)#vlan20!
创立Vlan20。
SwitchA(config-vlan)#nametechnical!
将Vlan20命名为technical。
SwitchA(config-vlan)#e*it
SwitchA(config)#interfacefastethernet0/15!
进入接口配置模式。
SwitchA(config-if)#switchportaccessvlan20!
将0/15端口划分到Vlan20。
验证测试:
验证已创立了Vlan20,并将0/15端口已划分到Vlan20中。
SwitchA#showvlanid20
VLANNameStatusPorts
----------------------------------------------------------------------------
20technicalactiveFa0/15
第三步:
在交换机SwitchA上将与SwitchB相连的端口〔假设为0/24端口〕定义为tagvlan模式。
SwitchA(config)#interfacefastethernet0/24!
进入接口配置模式。
SwitchA(config-if)#switchportmodetrunk!
将fastethernet0/24端口设为tagvlan模式。
验证测试:
验证fastethernet0/24端口已被设置为tagvlan模式。
SwitchA#showinterfacesfastEthernet0/24switchport
InterfaceSwitchportModeAccessNativeProtectedVLANlists
-------------------------------------------------------------------------
Fa0/24EnabledTrunk11DisabledAll
第四步:
在交换机SwitchB上创立Vlan10,并将0/5端口划分到Vlan10中。
SwitchB#configureterminal!
进入全局配置模式。
SwitchB(config)#vlan10!
创立Vlan10。
SwitchB(config-vlan)#namesales!
将Vlan10命名为sales。
SwitchB(config-vlan)#e*it
SwitchB(config)#interfacefastethernet0/5!
进入接口配置模式。
SwitchB(config-if)#switchportaccessvlan10!
将0/5端口划分到Vlan10。
验证测试:
验证已在SwitchB上创立了Vlan10,并将0/5端口已划分到Vlan10中。
SwitchB#showvlanid10
VLANNameStatusPorts
----------------------------------------------------------------------------
10salesactiveFa0/5
第五步:
在交换机SwitchB上将与SwitchA相连的端口〔假设为0/24端口〕定义为tagvlan模式。
SwitchB(config)#interfacefastethernet0/24!
进入接口配置模式。
SwitchB(config-if)#switchportmodetrunk!
将fastethernet0/24端口设为tagvlan模式。
验证测试:
验证fastethernet0/24端口已被设置为tagvlan模式。
SwitchB#showinterfacesfastEthernet0/24switchport
InterfaceSwitchportModeAccessNativeProtectedVLANlists
-------------------------------------------------------------------------
Fa0/24EnabledTrunk11DisabledAll
第六步:
验证PC1与PC3能互相通信,但PC2与PC3不能互相通信。
六、实验心得
理解了那些语句就没有则难了,在上一个实验的根底上,很快就做出来了。
教师给的实验步骤都很相信跟着做根本都能做出来。
实验2.3
一、实验目的
通过三层交换机实现VLAN间互相通信。
二、实验容
使在同一VLAN里的计算机系统能跨交换机进展相互通信,而在不同VLAN里的计算机系统也能进展相互通信。
三、实验拓扑
SwitchASwitchB
PC1PC3
PC2
四、实验设备
S2126G〔1台〕、S3550-24〔1台〕
五、实验步骤
第一步:
在交换机SwitchA上创立Vlan10,并将0/5端口划分到Vlan10中。
SwitchA#configureterminal!
进入全局配置模式。
SwitchA(config)#vlan10!
创立Vlan10。
SwitchA(config-vlan)#namesales!
将Vlan10命名为sales。
SwitchA(config-vlan)#e*it
SwitchA(config)#interfacefastethernet0/5!
进入接口配置模式。
SwitchA(config-if)#switchportaccessvlan10!
将0/5端口划分到Vlan10。
验证测试:
验证已创立了Vlan10,并将0/5端口已划分到Vlan10中。
SwitchA#showvlanid10
VLANNameStatusPorts
----------------------------------------------------------------------------
10salesactiveFa0/5
第二步:
在交换机SwitchA上创立Vlan20,并将0/15端口划分到Vlan20中。
SwitchA(config)#vlan20!
创立Vlan20。
SwitchA(config-vlan)#nametechnical!
将Vlan20命名为technical。
SwitchA(config-vlan)#e*it
SwitchA(config)#interfacefastethernet0/15!
进入接口配置模式。
SwitchA(config-if)#switchportaccessvlan20!
将0/15端口划分到Vlan20。
验证测试:
验证已创立了Vlan20,并将0/15端口已划分到Vlan20中。
SwitchA#showvlanid20
VLANNameStatusPorts
----------------------------------------------------------------------------
20technicalactiveFa0/15
第三步:
在交换机SwitchA上将与SwitchB相连的端口〔假设为0/24端口〕定义为tagvlan模式。
SwitchA(config)#interfacefastethernet0/24!
进入接口配置模式。
SwitchA(config-if)#switchportmodetrunk!
将fastethernet0/24端口设为tagvlan模式。
在虚拟环境下配置时会出错,解决方法:
先配置封装,再设置为trunk模式,命令:
SwitchA(config-if)#Switchporttrunkencapsulationdotlq
SwitchA(config-if)#switchportmodetrunk
验证测试:
验证fastethernet0/24端口已被设置为tagvlan模式。
SwitchA#showinterfacesfastEthernet0/24switchport
InterfaceSwitchportModeAccessNativeProtectedVLANlists
-------------------------------------------------------------------------
Fa0/24EnabledTrunk11DisabledAll
第四步:
在交换机SwitchB上创立Vlan10,并将0/5端口划分到Vlan10中。
SwitchB#configureterminal!
进入全局配置模式。
SwitchB(config)#vlan10!
创立Vlan10。
SwitchB(config-vlan)#namesales!
将Vlan10命名为sales。
SwitchB(config-vlan)#e*it
SwitchB(config)#interfacefastethernet0/5!
进入接口配置模式。
SwitchB(config-if)#switchportaccessvlan10!
将0/5端口划分到Vlan10。
验证测试:
验证已在SwitchB上创立了Vlan10,并将0/5端口已划分到Vlan10中。
SwitchB#showvlanid10
VLANNameStatusPorts
----------------------------------------------------------------------------
10salesactiveFa0/5
第五步:
在交换机SwitchB上将与SwitchA相连的端口〔假设为0/24端口〕定义为tagvlan模式。
SwitchB(config)#interfacefastethernet0/24!
进入接口配置模式。
SwitchB(config-if)#switchportmodetrunk!
将fastethernet0/24端口设为tagvlan模式。
验证测试:
验证fastethernet0/24端口已被设置为tagvlan模式。
SwitchB#showinterfacesfastEthernet0/24switchport
InterfaceSwitchportModeAccessNativeProtectedVLANlists
-------------------------------------------------------------------------
Fa0/24EnabledTrunk11DisabledAll
第六步:
验证PC1与PC3能互相通信,但PC2与PC3不能互相通信。
第七步:
设置三层交换机VLAN间通讯。
SwitchA(config)#intvlan10!
创立虚拟接口vlan10
SwitchA(config-if)#e*it!
返回到全局配置模式
SwitchA(config)#intvlan20!
创立虚拟接口vlan20
第九步:
测试结果
不同VLAN的主机可以互相PING通
六、实验心得
IP地址与网关必须设置在同一网段,三层的交换机才有路由功能,二层交换机不具备路由功能。
这两条信息必须严格遵守,不然实验做不出来。
通过整个实验二,提高太多了,之前看着那些代码没有什么感觉,现在根本都能看懂了,知道是要干什么。
然后不得不说这些实验容不得一点错误,必须一步一步跟着来做。