频道栏目
首页 > 资讯 > 交换机 > 正文

交换机实验教程:交换机VLAN划分实验

18-04-11        来源:[db:作者]  
收藏   我要投稿

交换机VLAN划分实验

一、实验目的

1、了解VLAN原理;

2、熟练掌握二层交换机VLAN的划分方法;

3、了解如何验证VLAN的划分。

二、应用环境

学校实验楼中有两个实验室位于同一楼层,一个是计算机软件实验室,一个是多媒体实验室,两个实验室的信息端口都连接在一台交换机上。学校已经为实验楼分配了固定的IP地址段,为了保证两个实验室的相对独立,就需要划分对应的VLAN,使交换机某些端口属于软件实验室,某些端口属于多媒体实验室,这样就能保证它们之间的数据互不干扰,也不影响各自的通信效率。

三、实验设备

1、DCS-3926S交换机1台

2、PC机2台

3、Console线1根

4、直通网线2根

四、实验拓扑

使用一台交换机和两台PC机,还将其中PC1作为控制台终端,使用Console口配置方式;使用两根网线分别将PC1和PC2连接到交换机的RJ-45接口上。

五、实验要求

在交换机上划分两个基于端口的VLAN:VLAN100,VLAN200。

VLAN

端口成员

100

1~8

200

9~16

使得VLAN100的成员能够互相访问,VLAN200的成员能够互相访问;VLAN100和VLAN200成员之间不能互相访问。

PC1和PC2的网络设置为:

设备

IP地址

Mask

交换机A

192.168.1.11

255.255.255.0

PC1

192.168.1.101

255.255.255.0

PC2

192.168.1.102

255.255.255.0

PC1、PC2接在VLAN100的成员端口1~8上,两台PC互相可以ping通;PC1、PC2接在VLAN的成员端口9~16上,两台PC互相可以ping通;PC1接在VLAN100的成员端口1~8上,PC2接在VLAN200的成员端口9~16上,则互相ping不通。

若实验结果和理论相符,则本实验完成。

六、实验步骤

第一步:交换机恢复出厂设置

switch#set default

switch#write

switch#reload

第二步:给交换机设置IP地址即管理IP。

switch#config

switch(Config)#interface vlan 1

switch(Config-If-Vlan1)#ip address 192.168.1.11 255.255.255.0

switch(Config-If-Vlan1)#no shutdown

switch(Config-If-Vlan1)#exit

switch(Config)#exit

第三步:创建vlan100和vlan200。

switch(Config)#

switch(Config)#vlan 100

switch(Config-Vlan100)#exit

switch(Config)#vlan 200

switch(Config-Vlan200)#exit

switch(Config)#

验证配置:

switch#show vlan

VLAN NameTypeMediaPorts

---- ------------ ---------- --------- ----------------------------------------

1defaultStaticENETEthernet0/0/1Ethernet0/0/2

Ethernet0/0/3Ethernet0/0/4

Ethernet0/0/5Ethernet0/0/6

Ethernet0/0/7Ethernet0/0/8

Ethernet0/0/9Ethernet0/0/10

Ethernet0/0/11Ethernet0/0/12

Ethernet0/0/13Ethernet0/0/14

Ethernet0/0/15Ethernet0/0/16

Ethernet0/0/17Ethernet0/0/18

Ethernet0/0/19Ethernet0/0/20

Ethernet0/0/21Ethernet0/0/22

Ethernet0/0/23Ethernet0/0/24

100VLAN0100StaticENET!已经创建了vlan100,vlan100中没有端口;

200VLAN0200StaticENET!已经创建了vlan200,vlan200中没有端口;

第四步:给vlan100和vlan200添加端口。

switch(Config)#vlan 100!进入vlan 100

switch(Config-Vlan100)#switchport interface ethernet 0/0/1-8

!给vlan100加入端口1-8

Set the port Ethernet0/0/1 access vlan 100 successfully

Set the port Ethernet0/0/2 access vlan 100 successfully

Set the port Ethernet0/0/3 access vlan 100 successfully

Set the port Ethernet0/0/4 access vlan 100 successfully

Set the port Ethernet0/0/5 access vlan 100 successfully

Set the port Ethernet0/0/6 access vlan 100 successfully

Set the port Ethernet0/0/7 access vlan 100 successfully

Set the port Ethernet0/0/8 access vlan 100 successfully

switch(Config-Vlan100)#exit

switch(Config)#vlan 200!进入vlan 200

switch(Config-Vlan200)#switchport interface ethernet 0/0/9-16

!给vlan200加入端口9-16

Set the port Ethernet0/0/9 access vlan 200 successfully

Set the port Ethernet0/0/10 access vlan 200 successfully

Set the port Ethernet0/0/11 access vlan 200 successfully

Set the port Ethernet0/0/12 access vlan 200 successfully

Set the port Ethernet0/0/13 access vlan 200 successfully

Set the port Ethernet0/0/14 access vlan 200 successfully

Set the port Ethernet0/0/15 access vlan 200 successfully

Set the port Ethernet0/0/16 access vlan 200 successfully

switch(Config-Vlan200)#exit

验证配置:

switch#show vlan

VLAN NameTypeMediaPorts

---- ------------ ---------- --------- ----------------------------------------

1defaultStaticENETEthernet0/0/17Ethernet0/0/18

Ethernet0/0/19Ethernet0/0/20

Ethernet0/0/21Ethernet0/0/22

Ethernet0/0/23Ethernet0/0/24

100VLAN0100StaticENETEthernet0/0/1Ethernet0/0/2

Ethernet0/0/3Ethernet0/0/4

Ethernet0/0/5Ethernet0/0/6

Ethernet0/0/7Ethernet0/0/8

200VLAN0200StaticENETEthernet0/0/9Ethernet0/0/10

Ethernet0/0/11Ethernet0/0/12

Ethernet0/0/13Ethernet0/0/14

Ethernet0/0/15Ethernet0/0/16

第五步:验证实验。

PC1位置

PC2位置

动作

结果

1-8端口

 

PC1 ping 192.168.1.11

不通

9-16端口

 

PC1 ping 192.168.1.11

不通

17-24端口

 

PC1 ping 192.168.1.11

1-8端口

1-8端口

PC1 ping PC2

1-8端口

9-16端口

PC1 ping PC2

不通

1-8端口

17-24端口

PC1 ping PC2

不通

七、注意事项和排错

1、默认情况下,交换机所有端口都属于vlan1,因此我们通常把vlan1作为交换机的管理vlan,因此vlan1接口的IP地址就是交换机的管理地址。

2、在DCS-3926S中,一个普通端口只属于一个vlan。

八、配置序列

Switch#Show run

Current configuration:

!

hostname switch

!

!

Vlan 1

vlan 1

!

Vlan 100

vlan 100

!

Vlan 200

vlan 200

!

!

Interface Ethernet0/0/1

switchport access vlan 100

!

Interface Ethernet0/0/2

switchport access vlan 100

!

Interface Ethernet0/0/3

switchport access vlan 100

!

Interface Ethernet0/0/4

switchport access vlan 100

!

Interface Ethernet0/0/5

switchport access vlan 100

!

Interface Ethernet0/0/6

switchport access vlan 100

!

Interface Ethernet0/0/7

switchport access vlan 100

!

Interface Ethernet0/0/8

switchport access vlan 100

!

Interface Ethernet0/0/9

switchport access vlan 200

!

Interface Ethernet0/0/10

switchport access vlan 200

!

Interface Ethernet0/0/11

switchport access vlan 200

!

Interface Ethernet0/0/12

switchport access vlan 200

!

Interface Ethernet0/0/13

switchport access vlan 200

!

Interface Ethernet0/0/14

switchport access vlan 200

!

Interface Ethernet0/0/15

switchport access vlan 200

!

Interface Ethernet0/0/16

switchport access vlan 200

!

Interface Ethernet0/0/17

!

Interface Ethernet0/0/18

!

Interface Ethernet0/0/19

!

Interface Ethernet0/0/20

!

Interface Ethernet0/0/21

!

Interface Ethernet0/0/22

!

Interface Ethernet0/0/23

!

Interface Ethernet0/0/24

!

switch#

九、共同思考

1、怎样取消一个vlan。

2、怎样取消一个vlan中的某些端口。

十、课后练习

1、请给交换机划分三个vlan,验证vlan实验

VLAN

端口成员

10

1~6

20

7~12

30

13~16

十一、相关配置命令详解

vlan

命令:vlan <vlan-id>

no vlan <vlan-id>

功能:创建VLAN并且进入VLAN配置模式,在VLAN模式中,用户可以配置VLAN名称和为该VLAN分配交换机端口;本命令的no操作为删除指定的VLAN。

参数:<vlan-id>为要创建/删除的VLAN的VID,取值范围为1~4094。

命令模式:全局配置模式

缺省情况:交换机缺省只有VLAN1。

使用指南:VLAN1为交换机的缺省VLAN,用户不能配置和删除VLAN1。允许配置VLAN的总共数量为255个。另需要提醒的是不能使用本命令删除通过GVRP学习到的动态VLAN。

举例:创建VLAN100,并且进入VLAN100的配置模式。

Switch(Config)#vlan 100

Switch(Config-Vlan100)#

name

命令:name

no name

功能:为VLAN指定名称,VLAN的名称是对该VLAN一个描述性字符串;本命令的no操作为删除VLAN的名称。

参数:为指定的vlan名称字符串。

命令模式:VLAN配置模式

缺省情况:VLAN缺省VLAN名称为vlanXXX,其中XXX为VID。

使用指南:交换机提供为不同的VLAN指定名称的功能,有助于用户记忆VLAN,方便管理。

举例:为VLAN100指定名称为TestVlan。

Switch(Config-Vlan100)#name TestVlan

switchport interface

命令:switchport interface <interface-list>

no switchport interface <interface-list>

功能:给VLAN分配以太网端口的命令;本命令的no操作为删除指定VLAN内的一个或一组端口。

参数:<interface-list>要添加或者删除的端口的列表,支持”;” ”-”,如:ethernet 0/0/1;2;5或ethernet 0/0/1-6;8。

命令模式:VLAN配置模式

缺省情况:新建立的VLAN缺省不包含任何端口。

使用指南:Access端口为普通端口,可以加入VLAN,但同时只允许加入一个VLAN。

举例:为VLAN100分配百兆以太网端口1,3,4-7,8。

Switch(Config-Vlan100)#switchport interface ethernet 0/0/1;3;4-7;8

switchport mode

命令:switchport mode {trunk|access}

功能:设置交换机的端口为access模式或者trunk模式。

参数:trunk表示端口允许通过多个VLAN的流量;access为端口只能属于一个VLAN。

命令模式:端口配置模式

缺省情况:端口缺省为Access模式。

使用指南:工作在trunk mode下的端口称为Trunk端口,Trunk端口可以通过多个VLAN的流量,通过Trunk端口之间的互联,可以实现不同交换机上的相同VLAN的互通;工作在access mode下的端口称为Access端口,Access端口可以分配给一个VLAN,并且同时只能分配给一个VLAN。

注意在Trunk端口不允许802.1X认证。

举例:将端口5设置为trunk模式,端口8设置为access模式。

Switch(Config)#interface ethernet 0/0/5

Switch(Config-ethernet0/0/5)#switchport mode trunk

Switch(Config-ethernet0/0/5)#exit

Switch(Config)#interface ethernet 0/0/8

Switch(Config-ethernet0/0/8)#switchport mode access

Switch(Config-ethernet0/0/8)#exit

相关TAG标签
上一篇:Doing Homework again
下一篇:交换机实验教程:多层交换机静态路由实验
相关文章
图文推荐

关于我们 | 联系我们 | 广告服务 | 投资合作 | 版权申明 | 在线帮助 | 网站地图 | 作品发布 | Vip技术培训 | 举报中心

版权所有: 红黑联盟--致力于做实用的IT技术学习网站