实验2.2 划分VLAN
- 格式:doc
- 大小:62.00 KB
- 文档页数:5
实验2.2 划分v lan
1.实验目的
通过本实验可以掌握:
(1)VLAN的创建
(2)把交换机接口划分到特定vlan的方法
2.实验拓扑
划分vlan实验拓扑如同2-1所示。
图2-1 划分VLAN实验拓扑
3.实验步骤
要配置vlan,首先要创建VLAN,然后把交换机的端口划分到特定的端口上。
(1)把交换机S1的配置清空,重启
在划分VLAN前,配置路由器R1和R2的fastethernet0/0接口,从R1上ping R2(172.16.0.2)。默认时,交换机的全部接口都在VLAN1上,R1和R2应该能够通信。
(2)在S1上创建VLAN
S1#vlan database
% Warning: It is recommended to configure VLAN from config mode,
as VLAN database mode is being deprecated. Please consult user
documentation for configuring VTP/VLAN in config mode.
S1(vlan)#
//进入vlan database模式,警告:推荐在config模式下配置vlan
S1(vlan)#vlan 2 name vlan2
VLAN 2 added:
Name: vlan2
S1(vlan)#
//以上创建vlan2,2就是vlan的编号,vlan2是该vlan的名字
S1(vlan)#vlan 3 name vlan3
VLAN 3 added:
Name: vlan3
S1(vlan)#exit
APPLY completed. Exiting....
S1#
//退出vlan模式,创建的vlan立即生效
Vlan模式有以下几个命令:
①abort:退出vlan模式,配置不生效
②reset:放弃刚才的配置,不退出vlan模式
③apply:配置立即生效,但不退出vlan模式
④exit:配置立即生效,并退出vlan模式
===在vlan数据库模式创建vlan===
S1(vlan)#abort
Aborting....
S1#
S1(vlan)#reset
RESET completed.
S1(vlan)#
S1(vlan)#apply
APPLY completed.
S1(vlan)#
===在全局配置模式下创建vlan===
S1(config)#vlan 2
S1(config-vlan)#name vlan2
S1(config-vlan)#exit
S1(config)#vlan 3
S1(config-vlan)#name vlan3
(3)把端口划分在vlan中
S1(config)#int f0/1
S1(config-if)#sw
S1(config-if)#switchport
//把该端口配置为二层接口,这是默认值。S1是三层交换机,接口可以作为三层接口。
S1(config-if)#switchport ?
access Set access mode characteristics of the interface
backup Set backup for the interface
block Disable forwarding of unknown uni/multi cast addresses
host Set port host
mode Set trunking mode of the interface
nonegotiate Device will not engage in negotiation protocol on this
interface
port-security Security related command
priority Set appliance 802.1p priority
private-vlan Set the private VLAN configuration protected Configure an interface to be a protected port
trunk Set trunking characteristics of the interface
voice Voice appliance attributes
S1(config-if)#switchport host
switchport mode will be set to access
spanning-tree portfast will be enabled
channel group will be disabled
//把该端口配置为主机设备所连接的接口。该命令辉同时启用portfast并禁用EtherChannel特性。
S1(config-if)#switchport mode access
//把交换机端口的模式改为access模式,说明该端口是用于连接计算机的,而不是用于Trunk
S1(config-if)#switchport access vlan 2
//把该端口fastEthernet0/1划分到vlan2中
S1(config)#interface range fastEthernet 0/2-4
S1(config-if-range)#switchport mode access
S1(config-if-range)#switchport access vlan 3
如果要删除VLAN,使用“no vlan 3”命令即可。删除某一vlan后,要记得把该vlan上的端口重新划分到别的vlan上,否则将导致端口的“消失”。
4.实验调试
(1)show vlan
该命令用来查看vlan的信息
S1#show vlan
VLAN Name Status Ports
---- -------------------------------- --------- -------------------------------
1 default active Fa0/5, Fa0/6, Fa0/7, Fa0/8
Fa0/9, Fa0/10, Fa0/11, Fa0/12
Fa0/13, Fa0/14, Fa0/15, Fa0/16
Fa0/17, Fa0/18, Fa0/19, Fa0/20
Fa0/21, Fa0/22, Fa0/23, Fa0/24
Gi0/1, Gi0/2
2 vlan2 active Fa0/1
3 vlan3 active Fa0/2, Fa0/3, Fa0/4
1002 fddi-default act/unsup
1003 token-ring-default act/unsup
1004 fddinet-default act/unsup
1005 trnet-default act/unsup
//以上的第一列列出了VLAN ID;第二列列出了VLAN的状态,active或act为激活,unsup为非挂起;第三列列出了本交换机上属于该VLAN的接口。
VLAN Type SAID MTU Parent RingNo BridgeNo Stp BrdgMode Trans1 Trans2
---- ----- ---------- ----- ------ ------ -------- ---- -------- ------ ------ 1 enet 100001 1500 - - - - - 0 0
2 enet 100002 1500 - - - - - 0 0
3 enet 100003 1500 - - - - - 0 0
1002 fddi 101002 1500 - - - - - 0 0
1003 tr 101003 1500 - - - - - 0 0
//以上显示各个VLAN的类型及最大传输单元等信息;其他列的信息较少用到,也超出了本书的范围,不作详细解析。
(2)show vlan brief
该命令用来查看VLAN的信息摘要
S1#show vlan brief
VLAN Name Status Ports
---- -------------------------------- --------- -------------------------------
1 default active Fa0/5, Fa0/6, Fa0/7, Fa0/8
Fa0/9, Fa0/10, Fa0/11, Fa0/12
Fa0/13, Fa0/14, Fa0/15, Fa0/16
Fa0/17, Fa0/18, Fa0/19, Fa0/20