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:

SW1 Console
SW1#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
SW1(config)#interface gi0/1
SW1(config-if)#switchport mode access
SW1(config-if)#switchport access vlan 100
SW1(config-if)#

VLANs, trunking, VLAN tagging and inter-vlan routing are covered comprehensively in the following interactive module: CCNA 200-301 Part 1A Module 5 - VLANs & TRUNKS. The course features visual, animated explanations and hands-on interactive labs.

TRY THIS COURSE

Want to test your networking skills with hands-on configuration and troubleshooting questions? Try out the Workshops section of this website here: CCNA 200-301 Consolidation Labs (Login required).

Learn about the industry's only browser-native network device simulators here: Connected Dots browser-native network device simulators

Planning to take the CCNA exam, or simply looking to level up your networking skills?
Look no further. Try our interactive courses.