fbpx

What is VLAN and How to Configure VLANs in Cisco Switch

In this article, I will show you how to configure VLANs in a Cisco switch. You will learn all the detailed configurations, and commands you need to create and manage your switch VLANs easily.

What is a VLAN network?

VLANs allow us to create different virtual networks inside a LAN . and this is done in the switch configuration.

We specify a range of ports to a VLAN and then, we create a new Virtual LAN (VLAN).

VLAN network advantages

These are the reasons why you need to use VLAN in your LAN:
– More secure: Each group/VLAN is separated from another group.
– Minimize network equipment and costs: you do not need a switch and more cables for each VLAN.
– Reduce broadcast domains.
– Efficient performance: because of reducing broadcast domains that allow computer resources to not receive unwanted traffic.

How many VLANs I can create?

Cisco Switches allow you to create a maximum number of VLANs is 2^12 = 4096. This number is determined because the VLAN id is encoded n only 12 bits.
– VLAN starts from 0 – 4095.
– VLAN 4095 the last VLAN is a reserved VLAN. As well as VLAN 0 is also reserved to be used for unknown traffic.
– Means we have available VLAN IDs from 1 – 4094.
– VLAN 1 is the default VLAN. This means this is the VLAN the switch assigns to all ports automatically.

Now, something to know is that VLANs are separated into 2 ranges.
+ VLAN Normal range: numbered from 1 to 1005
+ VLAN Extended range: numbered from 1006 to 4094. (these VLANs are usually used by big enterprises).

since we have VLAN 1,1002,1003,1004,1005 as default VLANs that means we have an available normale range of VLAN 2 – VLAN 1002. and of course, all VLANs of extended range from 1006 – 4094 if need it.

where is the switch store VLAN information?

Answer: New created VLANs are stored in the flash memory in a file called vlan.dat which stands for VLAN database. The extended-range VLANs are stored in the NVRAM configuration file.

VLAN configuration in Cisco Switch step by step

In this guide, you will learn How to create and configure VLAN in a Network (Switch). So because there are two ways of doing that, one by configuring each interface one by one. The second way is by using the “range” command, which allows you to assign a VLAN ID to multiple interfaces at one time. This last method is what you will need to use when you have a big large network.

How to create new VLANs:

- Switch(config)# vlan "ID"
- Switch(config-vlan)# name "VlanName"

Method 1: assign VLAN to interfaces one by one:

– First Go to your switch global configuration mode.
– Create a VLAN by this command (Id must be different than 1 and 1002/3/4/5) and it needs to be smaller 4094.
– Switch(config)# vlan “ID”
– Switch(config-vlan)# name “vlanName”
– Now go back to global configuration mode again, then configure interfaces so that we change the VLAN assigned to the interface from the default (VLAN 1) to the one you’ve created.
– Switch(config)# int “Interfacename NB”
– Switch(config-if)# switchport mode <access>
– Switch(config-if)# switchport access vlan “ID”

 Switch(config)# vlan "ID"
 Switch(config-vlan)# name "vlanName"
 Switch(config-vlan)# exit
 Switch(config-vlan)# int f0/1
 Switch(config-if)# switchport mode <access>
 Switch(config-if)# switchport access vlan "ID"

You should do this to all interfaces depending on how many posts you have in each VLAN.

Method 2: assign a VLAN ID to multiple interfaces with range command:

In case we have a lot of hosts connected to the switch Now we have to use “range” to simplify the configuration.
– Go to global conf mode.
– Switch(config)# vlan “ID”
– Switch(config-vlan)# name “vlanName”
Go back to global configuration mode.
– Switch(config)# int range f0/0-n
– Switch(config-if-range)# switchport mode access
– Switch(config-if-range)# switchport access vlan ID
now bu using range you specify a range of interfaces to configure at the same time.

Suppose we have 3 hosts in a VLAN.

 Switch(config)# vlan "ID"
 Switch(config-vlan)# name "vlanName"
 Switch(config-vlan)# exit
 Switch(config-vlan)# int range f0/1-3
 Switch(config-if)# switchport mode <access>
 Switch(config-if)# switchport access vlan "ID"

Use the command: show VLAN brief to see all VLAN configurations.

 Switch# show VLAN brief

Trunking Protocol Connect different VLAN networks

VLAN trunk mode, Trunking protocol allows connecting VLANs in different switches. in french it’s called (Protocole aggregation).
– In the switch configuration we can change interfaces mode to trunk mode, by turning the interfaces that connect two switches to trunk mode. So that can allow connection between different VLANs.

All switches today use a standard trunking protocol invented by IETF called 802.1q.

The process of trunking protocol in Cisco switch :
When a host sends a frame of data to another host. the connected switch check if the destination host is located in the local VLAN, if not it adds a tag to the frame to identify which VLAN it comes from.

The other switch receives the frame containing a VLAN ID tag. Then it can easily send the data to its destination.

Use this command to see which interfaces the using trunk mode. and some other details. You can use this command. “show int trunk”.

 Switch# show int trunk

Note: Always turn interfaces that are connected t different switches or different VLAN destinations to trunk mode.

You can configure trunk mode interfaces like this:

  • Note that you configure interfaces one by one or you can configure them in bulk using the range command.

Configuring switch interfaces trunk mode one by one:

– Switch(config)# int fas 0/1

Configuring multiple switch interfaces to trunk mode :

Switch(conf)# int range f0/1-n
Switch(config-if-range)# switchport mode trunk
Switch(config-if-range)#switchport trunk allowed vlan 1-n

note that we usually the “allowed” keyword, so that to allow a group of VLANs to communicate in the interface.

For more information about Networking Go check the Networking category on the main menu of our Website.

Scroll to Top