CCNA · Lesson 3 of 13
Access Ports: How to Assign a Port to a VLAN
You know what a VLAN is. Now you will create one and put ports in it with just 4 commands.
In a nutshell
An access port belongs to a single VLAN. It is configured with two commands: switchport mode access and switchport access vlan.
In this lesson
What is an access port?
An access port belongs to a single data VLAN. That is where you connect PCs, printers or cameras. The PC does not even know VLANs exist: it sends normal Ethernet frames, untagged. The switch is the one that knows which VLAN the port belongs to.
Step 1: create the VLAN
SW1# configure terminal
SW1(config)# vlan 10
SW1(config-vlan)# name SALES
SW1(config-vlan)# vlan 20
SW1(config-vlan)# name ACCOUNTING
SW1(config-vlan)# exit
The name is optional, but it helps a lot when there are dozens of VLANs.
Step 2: assign the ports
SW1(config)# interface range fa0/1 - 2
SW1(config-if-range)# switchport mode access
SW1(config-if-range)# switchport access vlan 10
SW1(config)# interface range fa0/3 - 4
SW1(config-if-range)# switchport mode access
SW1(config-if-range)# switchport access vlan 20
switchport mode access fixes the port as access (and stops it from negotiating a trunk with DTP). switchport access vlan 10 puts it in VLAN 10.
Step 3: verify
SW1# show vlan brief
VLAN Name Status Ports
---- ----------- --------- -------------------------
1 default active Fa0/5, Fa0/6, Fa0/7 ...
10 SALES active Fa0/1, Fa0/2
20 ACCOUNTING active Fa0/3, Fa0/4
Two behaviors you must know
- VLAN that does not exist: if you assign a port to a missing VLAN (
switchport access vlan 30), the switch creates it automatically and warns: % Access VLAN does not exist. Creating vlan 30. - Deleted VLAN: if you delete a VLAN with
no vlan 10, its ports do not go back to VLAN 1: they become inactive and pass no traffic until you assign them to another VLAN.
Best practice
Put unused ports in an unused "parking" VLAN (for example 999) and disable them with shutdown.
What you must remember
- Access port = one data VLAN, untagged frames.
- Create: vlan 10 → name SALES.
- Assign: switchport mode access + switchport access vlan 10.
- Verify: show vlan brief.
Check what you learned
4 exam-style questions. Some have one answer and others ask you to choose several. Answer them all to complete the lesson.