Assigning Switch Ports to VLANs

Interfaces on Cisco switches can belong to two VLANs, one for data traffic and one for voice traffic. You set the interface to be an access port. This also turns off trunking and VLAN Trunking Protocol (VTP).

Configure

The following command will configure an access port. An access port is intended for data traffic.

Switch#configure terminal
Switch(config)#interface interface-id
Switch(config-if)#switchport mode access
Switch(config-if)#switchport access vlan vlan-id

In order to configure a voice VLAN, you follow the exact same procedure as above, but this time, use the voice vlan keyword in place of the access keyword. The following command will configure a voice port. A voice port is intended for voice traffic.

Switch#configure terminal
Switch(config)#interface interface-id
Switch(config-if)#switchport voice vlan vlan-id

Verify

The following command will output switchport statistics for the interface you choose.

Switch#show interfaces interface-id switchport

The above command will output the following:

Name: interface-id
Switchport: Enabled
Administrative Mode: static access
Operational Mode: static access
Administrative Trunking Encapsulation: negotiated
Operational Trunking Encapsulation: native
Negotiation of Trunking: Off
Access Mode VLAN: vlan-id (vlan-name)
Trunking Native Mode VLAN: 1 (default)
Voice VLAN: vlan-id

You can also look at the running-config output for the interface.

!
interface interface-id
switchport access vlan vlan-id
switchport mode access
switchport nonegotiate
switchport voice vlan vlan-id
!

Troubleshooting

An issue you may run into is seeing  an inactive VLAN entry when you check the status of the switchport.

Switch#show interfaces interface-id switchport
Name: interface-id 
Switchport: Enabled 
Administrative Mode: static access 
Operational Mode: static access 
Administrative Trunking Encapsulation: negotiated 
Operational Trunking Encapsulation: native 
Negotiation of Trunking: Off 
Access Mode VLAN: vlan-id (inactive) 
Trunking Native Mode VLAN: 1 (default) 
Voice VLAN: vlan-id

This occurs when a VLAN was assigned to an interface and then the VLAN was deleted. This could be a result of administrative error or with configuring a protocol like VLAN Trunking Protocol (VTP). If you are not careful, you could plug a switch into the network that will delete the current vlan.dat file. When the VLAN is deleted, the assigned VLAN does not go away. As you can see from the above output, you can see that where the name of the VLAN is usually displayed, instead, you see the word inactive. No traffic flows and the packets are dropped.