Sub topic 7
The native VLAN
This chapter assumes you know Ethernet frames and MAC addresses, how a switch learns and forwards, basic IPv4 subnetting, and how to use a switch command line. It also assumes you have met access ports, trunk ports, and the 802.1Q tag. Here we cover what the native VLAN is, how a trunk handles untagged frames, what goes wrong when the two ends disagree, and how to configure it safely.
The problem the native VLAN solves
A trunk carries frames from many VLANs. The 802.1Q tag tells the receiver which VLAN each frame belongs to. A trunk may also receive frames that have no tag at all. Some examples are frames from an older device that does not understand tags, or frames from a hub or unmanaged switch connected to the trunk port.
The receiving switch needs a rule for untagged frames. The rule is the native VLAN. Every 802.1Q trunk port has a native VLAN, also called the port VLAN ID (PVID) in the IEEE standard. The switch does two things with it:
- Receiving: an untagged frame that arrives on the trunk is placed in the native VLAN.
- Sending: a frame that belongs to the native VLAN is sent out of the trunk without a tag. All other VLANs are sent with a tag.
The default native VLAN on Cisco switches is VLAN 1. Other vendors have their own defaults, and some let you tag the native VLAN.
What it looks like on the wire
Take two frames leaving a trunk whose native VLAN is 999. The first belongs to VLAN 10. The second belongs to VLAN 999.
| Frame belongs to | Tag on the trunk | Bytes after source MAC |
|---|---|---|
| VLAN 10 | Yes, VID 10 | `81 00` then the TCI with VID 10, then the EtherType |
| VLAN 999 (native) | No | The EtherType directly |
The native frame is a plain Ethernet frame. The receiver cannot tell its VLAN from the frame itself. It has to rely on its own configuration. This is the whole reason a mismatch is dangerous: nothing in the frame says which VLAN it was meant for.
The parser below, from the tag chapter, shows the same idea in code. A frame without the 0x8100 value at byte 12 returns None, meaning "no tag, so the native VLAN applies".
import struct
def parse_dot1q(frame: bytes):
"""Return the 802.1Q fields of an Ethernet frame, or None if it is untagged."""
tpid, tci = struct.unpack("!HH", frame[12:16])
if tpid != 0x8100:
return None
return {
"pcp": tci >> 13,
"dei": (tci >> 12) & 0x1,
"vid": tci & 0x0FFF,
}Configuring the native VLAN
The native VLAN is set per trunk port. Use a VLAN that no user, server, or management device uses.
interface GigabitEthernet0/24
switchport mode trunk
switchport trunk native vlan 999
switchport trunk allowed vlan 10,20
switchport nonegotiateNotice that the allowed list is 10,20 and does not include 999. This is a common surprise, and the next sections explain what it means.
On a router that uses subinterfaces, mark the subinterface that carries the native VLAN with the native keyword:
interface GigabitEthernet0/0.999
encapsulation dot1Q 999 nativeWithout native, the router expects every frame on that subinterface to carry a tag. Untagged frames from the switch's native VLAN would then not match any subinterface. A router with only tagged subinterfaces will fail to talk to the native VLAN.
Both ends of a link must agree. If the switch uses native VLAN 999, the device at the other end must also treat untagged frames as VLAN 999.
Native VLAN mismatch
A mismatch happens when the two ends of a trunk have different native VLANs. Suppose Switch A has native VLAN 1 on its trunk and Switch B has native VLAN 999 on the same link.
- A host in VLAN 1 on Switch A sends a frame.
- Switch A sends it on the trunk untagged, because VLAN 1 is its native VLAN.
- Switch B receives an untagged frame and places it in its own native VLAN, 999.
- The frame now sits in VLAN 999 and is flooded to the hosts there, even though it was sent from VLAN 1.
Two VLANs have been joined into one broadcast domain across the link. Traffic leaks in both directions. Hosts may receive frames from the wrong subnet, and the addressing in the two VLANs may not match, so connections fail in confusing ways.
How the switch warns you
Cisco switches running Cisco Discovery Protocol (CDP) compare native VLANs across a trunk. If they differ, the log shows a message like this:
%CDP-4-NATIVE_VLAN_MISMATCH: Native VLAN mismatch discovered on GigabitEthernet0/24 (1), with SwitchB GigabitEthernet0/24 (999).Spanning Tree Protocol can also react. Per-VLAN spanning tree on Cisco switches sends its VLAN 1 bridge protocol data units (BPDUs) untagged and the others tagged, and a mismatch can put a port in a blocking state with a type inconsistency message. Do not rely on these warnings alone. CDP might be off, and the behavior of spanning tree depends on its mode.
Untagged frames and the allowed list
The allowed VLAN list and the native VLAN interact in a way that surprises many people.
- On most Cisco switches, removing the native VLAN from the allowed list stops the trunk from forwarding that VLAN's user traffic. The trunk can still carry some control protocols for that VLAN.
- The native VLAN still exists as a setting on the port. Only its traffic is filtered.
In the configuration above, VLAN 999 is not allowed. That is intentional: no user traffic should be in VLAN 999. The port still has a native VLAN, so any stray untagged frame is assigned to VLAN 999 and then dropped, because 999 is not allowed.
Check your platform's behavior before relying on this. Some platforms accept untagged frames in the native VLAN even when it is not in the allowed list, and some drop them.
Why the native VLAN is a security concern
The native VLAN is the only VLAN whose frames cross a trunk without a tag. This is the weakness that the double-tagging attack uses. An attacker in the native VLAN sends a frame with two tags. The first switch removes the outer tag, because it matches its native VLAN, and sends the frame on with only the inner tag. The next switch reads the inner tag and delivers the frame into another VLAN. The attack is one-way, and it needs the attacker's access port to be in the same VLAN as the trunk's native VLAN. A later chapter covers it in full.
The usual defenses are about the native VLAN itself:
- Change the native VLAN from VLAN 1 to a dedicated, unused VLAN such as 999.
- Do not assign any access port to that VLAN.
- Do not use the native VLAN for management or for user traffic.
- Keep the same native VLAN on both ends of every trunk.
- Do not leave access ports in VLAN 1.
Some platforms can also tag the native VLAN on the trunk, which removes the untagged exception. On Cisco switches, the global command vlan dot1q tag native does this. When you use it, every device on the trunk must support it, or untagged traffic assumptions break.
vlan dot1q tag nativeVerification
Use these commands to see the native VLAN and compare both ends.
show interfaces trunk
show interfaces GigabitEthernet0/24 switchportIn show interfaces trunk, the first table has a Native vlan column. In show interfaces ... switchport, look for Trunking Native Mode VLAN. Run the command on both switches and compare the numbers.
Common errors
| Symptom | Likely cause | Fix |
|---|---|---|
| CDP native VLAN mismatch messages | Different `native vlan` on each end | Set the same value on both ends |
| Router cannot reach hosts in the native VLAN | Subinterface lacks the `native` keyword | Add `native` to the `encapsulation dot1Q` line |
| Hosts in two VLANs see each other's broadcasts | Native VLAN mismatch merging them | Correct the native VLAN on one end |
| Native VLAN traffic does not cross the trunk | Native VLAN missing from the allowed list | Add it to the list, or confirm that it is intended |
| Management access lost after changing the native VLAN | Management IP was in the old native VLAN | Move management to a tagged VLAN first |
Summary
The native VLAN is the VLAN that a trunk port assigns to untagged frames, and the one whose frames it sends untagged. It must match on both ends of the link. Change it from the default, keep it unused, and verify both ends after every change.
Exercise
Switch A has switchport trunk native vlan 1 and Switch B has switchport trunk native vlan 50 on the two ends of the same trunk. A host in VLAN 1 on Switch A sends a broadcast. Which VLAN does Switch B put the frame in, and why is this a problem?
Show answer
Switch B puts it in VLAN 50. Switch A sends VLAN 1 frames untagged because VLAN 1 is its native VLAN. Switch B treats every untagged frame as belonging to its own native VLAN, 50. The broadcast reaches hosts in VLAN 50, so the two VLANs act as one broadcast domain across the trunk. Traffic leaks between subnets, and the fix is to set the same native VLAN on both ends.
Exercise
You configure a router subinterface with encapsulation dot1Q 99 on a trunk whose switch side uses native VLAN 99. Hosts in VLAN 99 cannot reach the router. What is the likely cause and the fix?
Show answer
The switch sends VLAN 99 frames untagged, but the subinterface expects tagged frames. Add the native keyword so the line reads encapsulation dot1Q 99 native. Alternatively, change the native VLAN on the switch to an unused VLAN and keep VLAN 99 tagged.