By default, all ports on a switch are in the VLAN 1. We can verify that by typing the show vlan command from the IOS enable mode of a switch:
In the picture above, you can see that all of the 24 ports of the switch are in the same VLAN, namely VLAN 1.
Two steps are required to create a VLAN and assign a switch port to the VLAN:
- create a vlan using the vlan NUMBER global mode command
- assing a port to the VLAN by using two interface subcommands. The first command is the switchport mode access command. This command specifies that the interface is an access interface. The second command is the switchport access vlan NUMBER command. This command assigns the interface to a VLAN.
Here is an example of assigning the VLAN 2 to the interface:
The first command (vlan 2) created the VLAN 2. We’ve then entered the Fa0/1 subinterface mode and configured the interface as an access interface that belongs to VLAN 2. To verify this, we can again use the show vlan command: