Networks

How to configure VLANs on Cisco/IOS network equipment

Configure VLANs on Cisco Catalyst switches: read the default VLAN configuration, create VLAN 10 and assign the switch interfaces to it in access mode.

· 2 min read · level: intermediate

1. VLAN configuration with Cisco

In this new workshop we will see how to configure VLANs on Cisco Catalyst switches and how to assign interfaces to particular VLANs.

Let us start with a simple network topology:

Let us start with a simple example. H1 (Host 1) and H2 (Host 2) are connected to SW1. ​ We will first examine the default VLAN configuration on the switch. To do so, use the command show vlan.

Switch>show vlan

Interesting… VLAN 1 is the default local network and you can see that all the active interfaces are assigned to VLAN 1. ​ VLAN information is not saved in the running-config or the startup-config, but in a separate file called vlan.dat on your flash memory. If you want to delete the VLAN information, you have to delete that file by typing delete flash: vlan.dat . We have configured the IP address 192.168.1.1/24 on H1 and 192.168.1.2/24 on H2 so that they are in the same subnet. ​ Let us see whether H1 and H2 can reach each other:

Even with the default switch configuration, H1 can reach H2. Let us see how we can create a new VLAN for our hosts:

Switch(config)#vlan 10
Switch(config-vlan)#name Hotes
Switch(config-vlan)#exit
Switch(config)#do show vlan

This is how you create a new VLAN. You simply use the vlan command. It selects the VLAN indicated and creates it if it does not already exist. If you wish, you can give it a name with the name command, but that is optional. Here we call our VLAN "Hotes".

VLAN 10 has been created on the switch and you can see that it is active. However, no port is currently in VLAN 10. Let us see how we can change that… ​ First, let us select the interfaces connected to our hosts, namely fa0/1 and fa0/2 in our case. The switch port (the interface) then has to be configured in access mode with the switchport mode access command. Using the switchport access vlan command, we can now move our interfaces to the VLAN indicated by its number after the command.

Switch(config)#interface fa0/1
Switch(config-if)#switchport mode access
Switch(config-if)#switchport access vlan 10
​
Switch(config)#interface fa0/2
Switch(config-if)#switchport mode access
Switch(config-if)#switchport access vlan 10
Switch(config-if)#do show vlan

It is up to you to check that the ping now goes through between your hosts, now that they communicate over virtual local network 10.

Using the "show interfaces switchport" command, we can see that the operational mode is "static access", which means that it is in access mode. We can also check that the interface is assigned to VLAN 10.