Creating VLANs Using Cisco IOS

VLANs can easily be implemented on Cisco switches to improve network layout as well as security and efficiency. With VLANs we are able to, with software, logically separate ports on a switch (or other network device) into discrete groups that function as their own independent LANs. For example, let’s say we are designing a network for a small school that will provide access to the Internet via a 48 port switch. We want to separate the Faculty and Staff network devices from Students and Guests.

For our internal network we will be using a 192.168.1.0/24 network address, and we will divide our network into two subnets, 192.168.1.0/25 for the faculty and staff (Fac/Staff) and 192.168.1.128/25 for students and the Public (Students). Now let’s set up our VLANs on the switch.

In IOS, enter config mode

Switch>;enable
Switch#configure terminal
Enter configuration commands, one per line.  End with CNTL/Z.
Switch(config)#

Next we will create the VLANs and give them a name. I don’t think naming the VLAN is required, but it is recommended.

Switch(config)#vlan 10
Switch(config-vlan)#name facstaff
Switch(config-vlan)#exit
Switch(config)#vlan 20
Switch(config-vlan)#name students
Switch(config-vlan)#end
%SYS-5-CONFIG_I: Configured from console by console

Let’s take a look at our VLAN set up.

Switch#show vlan brief

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   facstaff                         active
20   students                         active
1002 fddi-default                     active
1003 token-ring-default               active
1004 fddinet-default                  active
1005 trnet-default                    active
Switch#

VLAN 1 is the default VLAN and all ports are members of it. VLANs 1002 – 1005, are also assigned by default, as show. We are going to split the 24 FastEthernet ports between the two new VLANs. We will take advantage of the ability in IOS to configure a range of interfaces at a time.

Switch#configure terminal
Enter configuration commands, one per line.  End with CNTL/Z.
Switch(config)#interface range fastEthernet 0/1-12
Switch(config-if-range)#switchport mode access
Switch(config-if-range)#switchport access vlan 10
Switch(config-if-range)#exit
Switch(config)#interface range fastEthernet 0/13-24
Switch(config-if-range)#switchport mode access
Switch(config-if-range)#switchport access vlan 20
Switch(config-if-range)#exit
Switch(config)#end

%SYS-5-CONFIG_I: Configured from console by console

Switch# show vlan brief

VLAN Name                             Status    Ports
---- -------------------------------- --------- -------------------------------
1    default                          active    Gig1/1, Gig1/2
10   facstaff                         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
20   students                         active    Fa0/13, Fa0/14, Fa0/15, Fa0/16
Fa0/17, Fa0/18, Fa0/19, Fa0/20
Fa0/21, Fa0/22, Fa0/23, Fa0/24
1002 fddi-default                     active
1003 token-ring-default               active
1004 fddinet-default                  active
1005 trnet-default                    active