一、项目拓扑图
二、创建VLAN
在Cisco IOS中有两种方式创建VLAN,在全局配置模式下使用vlan id命令,如switch(config)#vlan 10;在vlan database下创建vlan,如switch(vlan)vlan 20
Switch>en
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#hostname CoreSW
CoreSW(config)#vlan 10 !创建VLAN 10
CoreSW(config-vlan)#name Math
CoreSW(config-vlan)#exit
CoreSW#vlan database
CoreSW(vlan)#vlan 20 name Chinese !创建VLAN 20
VLAN 20 added:
Name: Chinese
CoreSW(vlan)#vlan 30 name Other
VLAN 30 added:
Name: Other
三、把端口划分给vlan(基于端口的vlan)
switch(config)#interface fastethernet0/1
switch(config-if)#switchport mode access !配置端口为access模式
switch(config-if)#switchport access vlan 10 !把端口划分到vlan 10
CoreSW(config-if)#interface fa0/7
CoreSW(config-if)#switchport mode access
CoreSW(config-if)#switchport access vlan 10
CoreSW(config-if)#
如果一次把多个端口划分给某个vlan,可以使用interface range命令。
CoreSW(config-if)#interface range fa0/2 - 4
CoreSW(config-if-range)#switchport mode access
CoreSW(config-if-range)#switchport access vlan 20
CoreSW(config-if-range)#interface range fa0/5 - 6
CoreSW(config-if-range)#switchport mode access
CoreSW(config-if-range)#switchport access vlan 30
CoreSW(config-if-range)#
四、查看vlan信息
CoreSW#show vlan
VLAN Name Status Ports
---- -------------------------------- --------- -------------------------------
1 default active 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, Gig1/1, Gig1/2
10 Math active Fa0/1, Fa0/7
20 Chinese active Fa0/2, Fa0/3, Fa0/4
30 Other active Fa0/5, Fa0/6
1002 fddi-default act/unsup
1003 token-ring-default act/unsup
1004 fddinet-default act/unsup
1005 trnet-default act/unsup
CoreSW#show vlan brief
VLAN Name Status Ports
---- -------------------------------- --------- -------------------------------
1 default active 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, Gig1/1, Gig1/2
10 Math active Fa0/1, Fa0/7
20 Chinese active Fa0/2, Fa0/3, Fa0/4
30 Other active Fa0/5, Fa0/6
1002 fddi-default active
1003 token-ring-default active
1004 fddinet-default active
1005 trnet-default active
CoreSW#show vlan id 10
VLAN Name Status Ports
---- -------------------------------- --------- -------------------------------
10 Math active Fa0/1, Fa0/7
VLAN Type SAID MTU Parent RingNo BridgeNo Stp BrdgMode Trans1 Trans2
---- ----- ---------- ----- ------ ------ -------- ---- -------- ------ ------
10 enet 100010 1500 - - - - - 0 0
CoreSW#sh vlan id 30
VLAN Name Status Ports
---- -------------------------------- --------- -------------------------------
30 Other active Fa0/5, Fa0/6
VLAN Type SAID MTU Parent RingNo BridgeNo Stp BrdgMode Trans1 Trans2
---- ----- ---------- ----- ------ ------ -------- ---- -------- ------ ------
30 enet 100030 1500 - - - - - 0 0
CoreSW#show vlan name Math
VLAN Name Status Ports
---- -------------------------------- --------- -------------------------------
10 Math active Fa0/1, Fa0/7
VLAN Type SAID MTU Parent RingNo BridgeNo Stp BrdgMode Trans1 Trans2
---- ----- ---------- ----- ------ ------ -------- ---- -------- ------ ------
10 enet 100010 1500 - - - - - 0 0
五、删除配置
CoreSW(config)#interface fa0/8
CoreSW(config-if)#no switchport access vlan 40 ! 把该端口从vlan 40中删除
CoreSW(config-if)#exit
CoreSW(config)#exit
CoreSW#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.
CoreSW(vlan)#no vlan 40 !删除vlan 40
Deleting VlAN 40...