switchport access vlan
Switchport access vlan
The switchport access vlan command assigns a Layer 2 interface on a Cisco IOS device to the specified VLAN. This command only takes effect for interfaces that are operating in access mode.
The process to configure a Layer 2 interface as an access port assigned to a specific VLAN involves 2 steps:
- Step 1: Configure the interface to operate in access mode using the command switchport mode access
- Step 2: Assign the interface to the desired VLAN using the switchport access vlan command
The format of the command is as follows:
switchport access vlan <vlan-id>
where <vlan-id> is the desired VLAN to which the interface must belong.
Let's take a look at an example. If we wanted to configure interface GigabitEthernet 0/1 to operate in access mode and be assigned to VLAN 100, we would enter configuration commands as follows:
VLANs, trunking, VLAN tagging and inter-vlan routing are covered comprehensively in the following interactive course: Course 5 - VLANs & Trunks. The course features visual, animated explanations and hands-on interactive labs.
Want to test your networking skills with hands-on configuration and troubleshooting questions? Try out the Workshops section of this website here: Workshops (Login required).
Read how to use the device simulators on this website here: Workshops - General Instructions