Configuring VLAN on a Cisco Switch
On this page, we learn how to configure:
The following is a basic configuration of VLAN on Cisco switches:
Before you begin you must have worked out your IP addresses
We are configuring VLAN ports for three departments:
VLAN 10 IT
VLAN 20 Sales
VLAN 30 HR (Human Resources)
Lets do it one after the other:
Configuring Telnet line and password:
switch1#config t
Switch1(config)#enable secret cisco
Switch1(config)#line vty 0 15
Switch1(config-line)#password cisco
Switch1(config-line)#login
Switch1(config-line)#exit
Configuring console line and password:
Switch1(config)#line con 0
Switch1(config-line)#password cisco
Switch1(config-line)#login
Switch1(config-line)#exit
Configuring hostname or Switch name
Switch1(config)#hostname BRANCH1
BRANCH1(config)#exit
Configuring VLAN and names on a switch:
BRANCH1#config t
BRANCH1(config)#vlan 10
BRANCH1(config-vlan)#name IT
BRANCH1(config-vlan)#exit
BRANCH1(config)#vlan 20
BRANCH1(config-vlan)#name Sales
BRANCH1(config-vlan)#exit
BRANCH1(config)#vlan 30
BRANCH1(config-vlan)#name HR
BRANCH1(config-vlan)#exit
BRANCH1(config)#exit
To view your configurations, use the show vlan command: -
BRANCH1#show vlan
VLAN Name Status Ports
---- -------------------------------- --------- -------------------------------
1 default active Fa0/1, Fa0/2, Fa0/3, Fa0/4
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
Gig1/1, Gig1/2
10 IT active
20 Sales active
30 HR active
1002 fddi-default active
1003 token-ring-default active
1004 fddinet-default active
005 trnet-default active
VLAN Type SAID MTU Parent RingNo BridgeNo Stp BrdgMode Trans1 Trans2
---- ----- ---------- ----- ------ ------ -------- ---- -------- ------ ------
1 enet 100001 1500 - - - - - 0 0
10 enet 100010 1500 - - - - - 0 0
20 enet 100020 1500 - - - - - 0 0
30 enet 100030 1500 - - - - - 0 0
1002 enet 101002 1500 - - - - - 0 0
1003 enet 101003 1500 - - - - - 0 0
1004 enet 101004 1500 - - - - - 0 0
1005 enet 101005 1500 - - - - - 0 0
Switch#
Delete VLANs
To delete a VLAN, use the global configuration command no vlan vlan-id to remove VLAN 20 from the switch.
e.g.
BRANCH1(config)#no vlan 10
BRANCH1(config)#end
The show vlan brief command verifies that VLAN 20 is no longer in the vlan.dat file.
Alternatively, the entire vlan.dat file can be deleted using the command delete flash:vlan.dat from privileged EXEC mode. After the switch is reloaded, the previously configured VLANs will no longer be present. This effectively places the switch into is "factory default" concerning VLAN configurations.
Assign a switch port
After creating your vlan you can assign a switch port to the vlan .
VLAN 20, is statically assigned to port F0/8 on switch S1:
switch1#config t
BRANCH1(config)#interface fa0/8
BRANCH1(config-if)#switchport mode access
BRANCH1(config-if)#switchport access vlan 20
BRANCH1(config-if)#no shut
BRANCH1(config-if)#exit
BRANCH1(config)#exit
BRANCH1#