Sub topic 11
Voice VLANs on access ports
This chapter assumes you know how access ports and 802.1Q tagging work, as covered earlier in this tutorial. You should also be comfortable with Cisco IOS interface configuration and with how a switch learns MAC addresses. Here you will see how a single switch port can carry two VLANs, one for a PC and one for an IP phone, without being a trunk.
The problem a voice VLAN solves
Desks usually have one wall jack. An IP phone sits on that jack, and the user's PC plugs into a small switch built into the phone. Two devices now share one switch port, and you want them in different VLANs:
- Voice traffic is delay-sensitive and needs priority queuing. Keeping it in its own subnet makes QoS and firewall policy simpler.
- Phones often get their configuration from a provisioning server that PCs should not reach.
- A busy data VLAN can have many broadcasts. Keeping phones out of it keeps their call setup and media traffic away from that noise.
A plain access port cannot do this, because it places every frame into one VLAN. A full trunk could, but it is more than a desk needs. It would also expose every allowed VLAN to whatever is plugged in. The voice VLAN feature is a middle path.
How the port behaves
A port with a voice VLAN is still configured as switchport mode access. It has two VLANs:
- The access VLAN holds the PC. The PC sends ordinary untagged frames, and the switch places them in this VLAN.
- The voice VLAN holds the phone. The phone sends its own traffic tagged with an 802.1Q header carrying the voice VLAN ID.
The phone's built-in switch passes the PC's untagged frames through unchanged and tags only the phone's own traffic. The switch port therefore sees a mix: untagged frames that belong to the access VLAN, and tagged frames that belong to the voice VLAN.
Basic configuration
This example uses VLAN 10 for data and VLAN 150 for voice. The port is the one shown in the diagram.
vlan 10
name USERS
vlan 150
name VOICE
!
interface GigabitEthernet0/5
description IP phone with PC behind it
switchport mode access
switchport access vlan 10
switchport voice vlan 150
spanning-tree portfastThe single line switchport voice vlan 150 is the whole feature. Everything else is an ordinary access port. spanning-tree portfast is not specific to voice. It is included because phones that wait through STP listening and learning states will boot slowly, and this is an edge port.
Both VLANs must exist in the switch's VLAN database. If VLAN 150 is missing, the port will not forward voice traffic, and the phone will usually fail to register.
How the phone learns the voice VLAN ID
The phone cannot guess VLAN 150. It gets the ID in one of three ways:
- CDP or LLDP-MED. The switch advertises the voice VLAN on the port, and the phone applies it. This is the usual method and needs no phone configuration. Both protocols must be enabled on the switch, and the phone must support the one you use. Cisco switches run CDP by default. LLDP is off by default on many Catalyst models and needs
lldp run. - Manual setting on the phone. An administrator types the VLAN ID into the phone menu. This works without discovery protocols, but it does not scale.
- DHCP-based provisioning. Some vendors deliver the VLAN through vendor-specific DHCP options. The phone must first get an address somewhere, so this tends to be used together with option 1 or option 2.
The phone typically starts untagged in the access VLAN, hears the CDP or LLDP-MED advertisement, then re-initialises its network connection and sends tagged frames in the voice VLAN. This is why a phone behind a port without CDP or LLDP-MED ends up in the data VLAN, and a quick check of its IP address often reveals the problem.
Options for the voice VLAN command
The keyword after switchport voice vlan decides what the phone is told:
| Command | What the phone does |
|---|---|
| `switchport voice vlan 150` | Tags its frames with VLAN 150 and the CoS priority. |
| `switchport voice vlan dot1p` | Tags its frames with VLAN 0 (priority tag only). The switch puts them in the access VLAN, but the CoS value is kept. |
| `switchport voice vlan untagged` | Sends untagged frames. They go to the access VLAN, and no priority is carried. |
| `switchport voice vlan none` | Receives no voice VLAN information. This is the default. |
VLAN ID 0 in the dot1p case is the reserved value covered in the chapter on VLAN ID ranges. It means the tag carries only priority and no VLAN membership.
Priority and trust
A voice VLAN separates traffic, but separation alone does not give voice any priority. The priority comes from the CoS field in the 802.1Q tag (and from DSCP at Layer 3). Cisco IP phones typically mark voice media with CoS 5 and signaling with CoS 3.
On a switch with QoS enabled, you decide whether to believe those markings. The switch should trust them only when it has confirmed that the device is a real Cisco phone, and it should not trust a PC that could mark everything as CoS 5. On Catalyst switches that use the mls qos model, the pattern is:
mls qos
!
interface GigabitEthernet0/5
mls qos trust device cisco-phone
mls qos trust cosThis syntax is platform-specific. Newer platforms use different QoS models and commands, so check the documentation for your switch. The principle carries over: trust is conditional on detecting the phone through CDP.
The phone also decides what to do with the PC's frames. By default the phone usually passes them unchanged. Some switch models let you tell the phone to reset the PC's CoS to a chosen value with switchport priority extend cos 0, so a PC cannot claim high priority through the phone.
Verification
The verification commands you already know still apply, with a few differences.
show interfaces GigabitEthernet0/5 switchport
show vlan brief
show cdp neighbors GigabitEthernet0/5 detailIn the switchport output, the lines to check look like this:
Administrative Mode: static access
Operational Mode: static access
Access Mode VLAN: 10 (USERS)
Voice VLAN: 150 (VOICE)Notice what does not change. The operational mode is still static access, and the port does not appear in show interfaces trunk. Learners often look there and conclude the voice VLAN is missing. In show vlan brief, the port is listed under the access VLAN (10) only. On many platforms it also appears under the voice VLAN, but you should not rely on that. The reliable source is the Voice VLAN: line.
The MAC address table shows the effect most clearly. Run show mac address-table interface GigabitEthernet0/5 and you should see the phone's MAC in VLAN 150 and the PC's MAC in VLAN 10, both on the same port.
Edge cases and gotchas
- Port security counts both devices. The phone and the PC both have MAC addresses on the port. A limit of one will shut the port down or drop frames when the second device appears. Allow at least two, and more if the PC also runs a softphone or virtual adapters.
- The PC can still send tagged frames. Nothing stops a user from configuring their NIC to send frames tagged with VLAN 150. The switch accepts them into the voice VLAN, which bypasses the separation. The risk is similar to VLAN hopping, covered in a later chapter. Limit it with ACLs on the voice VLAN's gateway, DHCP snooping and Dynamic ARP Inspection, and by using port security.
- Do not reuse the same VLAN for both roles. Setting the voice VLAN equal to the access VLAN defeats the purpose, and some platforms reject the configuration.
- Do not combine this with trunk mode. If you set
switchport mode trunkon a phone port, theswitchport voice vlancommand is not what carries voice. Use one model or the other. - PoE and boot order. A phone powered by PoE boots, negotiates power, then starts CDP or LLDP-MED. Faults in power negotiation can look like VLAN faults.
- Routing. The voice VLAN is a separate subnet like any other VLAN. It needs a default gateway through router-on-a-stick or a switched virtual interface, or phones cannot reach the call server in another subnet.
Exercise
A phone plugged into a port configured with switchport mode access, switchport access vlan 10 and switchport voice vlan 150 gets an address from the VLAN 10 DHCP scope instead of VLAN 150. show interfaces trunk shows nothing for the port. Name two likely causes and what you would check for each.
Show answer
The first cause is that the phone never learned the voice VLAN, so it stayed untagged in VLAN 10. Check that CDP (or LLDP-MED, with lldp run) is enabled on the switch and port, and that show cdp neighbors detail lists the phone. The second cause is that VLAN 150 is missing from the VLAN database, so the voice VLAN has nothing to forward into. Check show vlan brief. The empty output of show interfaces trunk is expected, because a voice VLAN port is an access port and does not appear there. Use show interfaces GigabitEthernet0/5 switchport and look for the Voice VLAN: line instead.