Three Steps to Configure VLAN Properly

VLAN Configuration

The implementation of VLANs is done in three steps
  • Create VLANs
  • Name the VLANs
  • Assign ports to the VLANs

                              
The following configuration parameters show how to create VLAN2 & 3 and assign names as HR and sales respectively.
SW0#config t
Enter configuration commands, one per line. End with CNTL/Z
SW0(config)#
SW0(config)#
SW0(config)#vlan2
SW0(config-vlan)#name HR
SW0(config-vlan)#vlan 3
SW0(config-vlan)#name Sales
SW0(config-vlan)#exit
When creating the first VLAN, the ‘global config’ prompt changes to the ‘config-vlan’ prompt. To continue creating further VLANs, Continue to use the same prompt as the preferred practice.
Step 1
Set up the VLAN interface
SW0(config)# interface vlan 2
SW0(config-if)#
%LINK-5-CHANGED: Interface VLAN2, changed state to up
SW0(config-if)# interface vlan 3
SW0(config-if)#
%Link-5-changed: Interface Vlan3, changed state to up
Notes:
By defaults, the interface status of the newly created VLANs will be down. To “Up” the VLAN interface, we need to enter into the interface of the VLAN and execute the “No Shutdown” command (optional).
In most of the Cisco switches, the “No Shutdown” command is not necessary.
Step 2
Verify the VLAN database by executing a show VLAN brief command:
SW0#
SW0#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,
                                                                          Gig0/1, Gig0/2
2             HR                                    active
3             Sales                                active
1002 fddi-default                          active
1003 token-ringdefault                 active                                        
1004 fddinet-default                     active
1005 trnet-default                         active
Note:
The created VLAN database, will not be stored in the running-config or startup-config file in NVRAM, instead, it will copy top flash memory under VLAN.dat file.
Switch#show flash
Directory of flash
      1     -rw-       4414921            <no date> c2960-lanbase-mz.122-25.FX.bin
64016384 bytes total (59601463 bytes free)
Switch#config  t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#vlan 2
Switch(config-vlan) # name training
Switch(config-vlan) # vlan 3
Switch(config-vlan) # name sales
Switch(config-vlan) # exit
Switch(config-vlan) # do sh flash
Directory of flash:/
         1       -rw-        4414921                                   <no date>    c2960-lanbase-mz.122-25.FX.bin
         2       -rw-                 676                                    <no date>   vlan.dat
64016384 bytes total     (59600787 bytes free)
Switch(config) #exit                    
This means that even if the startup-config file is erased and the router is reloaded, the VLANs will still remain.

To delete the VLANs:

  • Use the no vlan command.  Or,
  • Delete the vlan.bat files by using the following command:

Switch #delete flash:vlan.dat
Delete filename [vlan.dat]?
Delete flash:/vlan.dat? [confirm]
Switch# show flash
Directory of flash:/
        1       -rw-       4414921                   <no date>         c2960-lanbase-mz.122-25.FX.bin
64016384 bytes total     (59601463 bytes free)
Note:
If the VLAN.dat file is deleted, all created VLANs will get deleted.

Assigning Switch Ports to VLAN

  • By defaults, all ports in a switch are assigned to the VLAN 1.
  • VLAN 1 is also called native VLAN.
  • VLANs can be assigned to individual switch ports or a range of ports.
  • VLANs can be statically or dynamically assigned to a single port
  • ports in a switch will become active only if the VLAN is assigned to that particular port or if the port is a native VLAN (VLAN1).
  • In the case static VLAN assignment to switch port, the administrator should configure to assign vlan to a particular port. This does not get modified unless the administrator manually removes it.
  • For dynamic VLAN assignment, ensure that the VLAN membership policy server (VMPS) and client database is properly implemented.

SW0(config) #interface fa0/1
SW0(config-if) #switchport mode access
SW0(config-if) #switchport   access vlan 2
SW0(config-if)#
%LINEPROTO-5-UPDOWN: Line protocol on interface vlan2, changed state to up
SW0(config) #interface fa0/2
SW0(config-if) #switchport mode access
SW0(config-if) #switchport   access vlan 3
SW0 (config-if) #
%LINEPROTO-5-UPDOWN: Line protocol on interface vlan3, changed state to up
SW0(config) #interface fa0/3
SW0(config-if) #switchport mode access
SW0(config-if) #switchport   access vlan 3

Also read:
1. What is VLAN and How It is Work and It’s Benefits
2. Difference Between Bridge And Switch- Bridge vs Switch
3. Three Types Switching You Need to Know About it.

Leave a Reply

Your email address will not be published. Required fields are marked *