Sub topic 4
Access Ports: Assigning End Devices to a VLAN
This chapter assumes you know how a switch learns MAC addresses and forwards, floods, and filters frames. It also assumes you are comfortable with IPv4 subnets and basic switch command-line use. Here you will see how an access port puts an end device into a VLAN and how to check that it worked.
What an access port does
An access port belongs to exactly one VLAN. Frames that arrive from the attached device are untagged. The switch notes the port's VLAN and handles each frame as part of that VLAN. When the switch sends a frame out of the port, it removes any VLAN tag first. The device never sees VLAN information.
This is why a PC, printer, or server needs no VLAN configuration. The VLAN assignment lives entirely in the switch.
Creating VLANs and assigning ports
First create the VLANs, then place ports in them.
vlan 10
name USERS
vlan 20
name SERVERS
!
interface GigabitEthernet0/1
switchport mode access
switchport access vlan 10
!
interface GigabitEthernet0/2
switchport mode access
switchport access vlan 20The switchport mode access command fixes the port as an access port. Without it, the port may try to negotiate a trunk. The switchport access vlan command sets the VLAN. Hosts on Gi0/1 and Gi0/2 are now in different broadcast domains. A broadcast from the PC is never flooded to the server.
If you assign a port to a VLAN that does not exist, many Cisco switches create it for you. Others show the port as inactive. Create VLANs explicitly so the result does not depend on the platform.
Verifying membership
Use show vlan brief to list each VLAN and the ports in it.
show vlan brief
show interfaces GigabitEthernet0/24 switchportThe first command shows ports grouped by VLAN. The second shows the administrative mode (what you configured) and the operational mode (what the port is actually doing) for one port. Trunk ports do not appear in the show vlan brief port lists, so a port that you expected to see there may be trunking.
Each VLAN needs its own subnet
A VLAN is a Layer 2 broadcast domain. In normal designs, each VLAN maps to one IP subnet. Hosts in VLAN 10 might use 192.168.10.0/24, and hosts in VLAN 20 might use 192.168.20.0/24. Putting a host in the wrong VLAN, or giving it an address from the wrong subnet, breaks its connectivity. Traffic between the two VLANs needs a router, which later chapters cover.
Common errors
| Symptom | Likely cause |
|---|---|
| Host cannot reach its gateway | Port is in the wrong VLAN |
| Port missing from `show vlan brief` | Port is trunking, or the VLAN is not defined |
| Port shows as inactive in the VLAN list | The assigned VLAN does not exist on this switch |
| Host works on one switch but not on another | The VLAN is missing from a switch or from the trunk between them |
Exercise
A PC on Gi0/5 has the address 192.168.10.20/24, which belongs to VLAN 10. It cannot reach its gateway. show vlan brief lists Gi0/5 under VLAN 20. What is the fault and how do you fix it?
Show answer
The port is assigned to the wrong VLAN, so the PC sits in a different broadcast domain from its gateway. Fix it with interface GigabitEthernet0/5, then switchport access vlan 10, and confirm with show vlan brief.