VLAN Tagging (802.1Q) – Detailed Explanation
1. What Is VLAN Tagging?
VLAN tagging is the mechanism by which a switch embeds a VLAN identifier directly inside an Ethernet frame so that receiving devices know which VLAN the frame belongs to. This allows a single physical link (a trunk) to carry traffic for many different VLANs simultaneously while keeping each VLAN's traffic logically isolated.
Without VLAN tagging (access port):
[Dst MAC | Src MAC | EtherType | Data | FCS] <-- No VLAN info
With 802.1Q VLAN tagging (trunk port):
[Dst MAC | Src MAC | TPID 0x8100 | TCI (PCP+CFI+VID) | EtherType | Data | FCS]
|<------- 4 bytes added -------->|
VLAN ID lives here (12 bits, 1-4094)
Related pages: Access vs Trunk Ports | VLAN Creation & Management | VLANs Overview | show vlan | show interfaces trunk | Router-on-a-Stick | Layer 3 Switch Routing | Port Security | Port Security Violation Modes | Step-by-Step: Trunk Configuration | Step-by-Step: Assigning VLANs to Switch Ports | Step-by-Step: Layer 2 VLAN Troubleshooting
2. IEEE 802.1Q Standard Overview
IEEE 802.1Q is the open industry standard for VLAN tagging, supported by all modern switch vendors (Cisco, Juniper, Aruba, HPE, etc.). It was defined to replace the earlier Cisco-proprietary ISL (Inter-Switch Link) protocol, which is now obsolete.
| Protocol | Standard | Vendor Support | Status |
|---|---|---|---|
| 802.1Q | IEEE open standard | All vendors | Current — use this |
| ISL | Cisco proprietary | Cisco only | Obsolete — do not use |
3. The 802.1Q Tag Structure
The 802.1Q tag is a 4-byte (32-bit) field inserted into the Ethernet frame between the Source MAC address and the original EtherType/Length field:
| Field | Size | Value | Purpose |
|---|---|---|---|
| TPID (Tag Protocol Identifier) | 16 bits | 0x8100 (always) | Signals to the receiving switch that a VLAN tag follows — distinguishes a tagged frame from an untagged one |
| PCP (Priority Code Point) | 3 bits | 0–7 | 802.1p QoS priority — 0 = best effort, 7 = highest priority (used for voice/video) |
| CFI (Canonical Format Indicator) / DEI | 1 bit | 0 or 1 | Legacy token ring compatibility indicator (always 0 on Ethernet). In modern 802.1ad, repurposed as DEI (Drop Eligible Indicator) |
| VID (VLAN Identifier) | 12 bits | 1–4094 | Identifies the VLAN — the core purpose of the tag. 0 and 4095 are reserved. |
4. How 802.1Q Tagging Works — Step by Step
- Host A (in VLAN 10) sends an untagged Ethernet frame to its access port on Switch1
- Switch1 identifies the incoming port as belonging to VLAN 10 (access port assignment)
- When forwarding out the trunk port toward Switch2, Switch1 inserts the 802.1Q tag with VID=10 into the frame
- Switch2 receives the tagged frame, reads VID=10, and knows to forward it to VLAN 10 ports
- Before delivering to Host B's access port, Switch2 strips the tag — the end device receives a normal, untagged Ethernet frame
Host A (VLAN 10) Host B (VLAN 10)
Untagged frame Untagged frame
| ^
v |
Switch1 Access Port Switch2 Access Port
(adds tag VID=10) (strips tag)
| |
+---------- Trunk Link -- Tagged [VID=10] -----------+
5. Trunk Ports vs Access Ports
| Feature | Access Port | Trunk Port |
|---|---|---|
| VLANs carried | One VLAN only | Multiple VLANs simultaneously |
| Frames | Untagged — no 802.1Q tag | Tagged (except native VLAN) |
| Connected to | End devices (PCs, printers, phones) | Other switches, routers, servers (multi-VLAN) |
| Configuration | switchport mode access + switchport access vlan X | switchport mode trunk + allowed VLAN list |
See Access vs Trunk Ports for the complete configuration guide and Assigning VLANs to Switch Ports for a hands-on lab.
Trunk Port Configuration Example
interface GigabitEthernet0/1
switchport mode trunk
switchport trunk allowed vlan 10,20,30,40
switchport trunk native vlan 99
switchport nonegotiate
switchport nonegotiate disables DTP (Dynamic Trunking Protocol) negotiation — strongly recommended on all trunk ports to prevent VLAN hopping attacks (see Section 12).
6. Native VLAN
The native VLAN is the one VLAN on a trunk port whose frames are sent and received without an 802.1Q tag. Any untagged frame arriving on a trunk port is automatically assigned to the native VLAN.
- Cisco default native VLAN: VLAN 1
- Best practice: Change native VLAN to an unused, dedicated VLAN (e.g., VLAN 99) on all trunk links
- Both ends of a trunk must be configured with the same native VLAN
Native VLAN Mismatch
If the two ends of a trunk have different native VLANs configured, Cisco switches will generate a CDP warning:
%CDP-4-NATIVE_VLAN_MISMATCH: Native VLAN mismatch discovered on GigabitEthernet0/1 (99), with Switch2 GigabitEthernet0/1 (1).
The result is misrouting of untagged traffic — frames from the native VLAN on one switch arrive in the wrong VLAN on the other. This is a connectivity and security issue. Verify with show interfaces trunk and show vlan brief.
7. DTP — Dynamic Trunking Protocol
DTP is a Cisco-proprietary protocol that automatically negotiates trunk formation between adjacent switches. While convenient, DTP poses a significant security risk because an attacker can send DTP frames to negotiate a trunk link with a user-facing port, then access all VLANs.
| DTP Mode | Behaviour |
|---|---|
dynamic auto | Passively waits for the other end to initiate trunking |
dynamic desirable | Actively tries to form a trunk with the neighbour |
trunk | Forces trunk mode — sends DTP frames |
access | Forces access mode — sends DTP frames to disable trunking |
nonegotiate | Forces the configured mode WITHOUT sending DTP frames — most secure |
Security best practice: Always disable DTP on both access ports (switchport mode access) and hardcoded trunk ports (switchport nonegotiate). Never leave ports in dynamic auto or dynamic desirable mode.
8. Q-in-Q Double Tagging (IEEE 802.1ad)
Q-in-Q (IEEE 802.1ad, also called Provider Bridging) stacks two 802.1Q tags on a single frame: an outer provider tag (S-TAG) and an inner customer tag (C-TAG). This allows service providers to transport customer VLANs transparently across their MPLS/Metro-Ethernet backbone while using their own VLAN namespace.
[Dst MAC | Src MAC | S-TAG 0x88A8 | C-TAG 0x8100 | EtherType | Data | FCS]
Provider VID Customer VID
(outer tag) (inner tag)
Use case: A customer with VLANs 10, 20, 30 connects to an ISP. The ISP wraps all customer traffic in a single provider VLAN tag (e.g., PVID 200) across their network, preserving the customer's VLAN tags inside.
9. MTU Considerations
The 802.1Q tag adds 4 bytes to every tagged Ethernet frame. Standard Ethernet maximum frame size is 1518 bytes — tagged frames can be up to 1522 bytes.
- Switches must support "baby giant" frames (up to 1522 bytes) to handle tagged frames without dropping them
- Q-in-Q frames (double tagged) can be up to 1526 bytes — requires jumbo frame support on the network path
- Misconfigured MTU settings can cause silent packet drops on trunk links — especially noticeable for large transfers or VoIP
10. Impact on Switch Processing
The 802.1Q VLAN tag fundamentally changes how switches handle frames:
- Switches use the VID in the tag to select the correct per-VLAN forwarding table (MAC address table is per-VLAN)
- Frames tagged with different VIDs are Layer-2 isolated — VLAN 10 traffic never appears to VLAN 20 hosts without routing through a Layer 3 device (router or Layer 3 switch)
- The PCP field (3 bits) in the TCI enables 802.1p QoS prioritisation — voice and video frames can be marked high priority (PCP=5–6) for preferential treatment through the network
11. Cisco IOS Configuration Reference
! Trunk port configuration
interface GigabitEthernet0/1
switchport mode trunk
switchport trunk encapsulation dot1q ! Needed on older IOS to specify 802.1Q
switchport trunk allowed vlan 10,20,30
switchport trunk native vlan 99
switchport nonegotiate ! Disable DTP
! Verify trunk configuration
Switch# show interfaces trunk
Switch# show interfaces GigabitEthernet0/1 switchport
! Check all VLAN and port assignments
Switch# show vlan brief
! Set native VLAN for security (both switches must match)
Switch(config-if)# switchport trunk native vlan 99
See show interfaces trunk for full output annotation,
show vlan brief to verify VLAN assignments,
and Step-by-Step: Trunk Configuration for a full hands-on walkthrough.
12. Security: VLAN Hopping Attack and Mitigation
A VLAN hopping attack allows an attacker to send traffic to VLANs they shouldn't have access to. There are two main techniques:
Switch Spoofing
An attacker sends DTP frames from a user port, causing the switch to form a trunk link with the attacker's machine. The attacker's machine then has access to all VLANs on the trunk.
Double Tagging
An attacker on the native VLAN sends a frame with two 802.1Q tags. The outer tag matches the native VLAN (and is stripped by the first switch without being checked). The inner tag contains a target VLAN ID. The second switch sees the inner tag and forwards the frame to the target VLAN — a one-way attack that works even if DTP is disabled.
Mitigations
! 1. Disable DTP on ALL user-facing (access) ports
Switch(config-if)# switchport mode access
Switch(config-if)# switchport nonegotiate
! 2. Change native VLAN away from VLAN 1 (and any user VLAN)
Switch(config-if)# switchport trunk native vlan 999
! 3. Explicitly tag native VLAN traffic (removes untagged native VLAN)
Switch(config)# vlan dot1q tag native
! 4. Place all unused ports in an unused VLAN and disable them
Switch(config-if)# switchport access vlan 999
Switch(config-if)# shutdown
! 5. Restrict trunk allowed VLANs to only what's needed
Switch(config-if)# switchport trunk allowed vlan 10,20,30
For broader Layer 2 security hardening, also see Port Security, DHCP Snooping, Dynamic ARP Inspection, and Firewalls.
13. Troubleshooting VLAN Tagging Issues
| Problem | Likely Cause | Diagnostic Command |
|---|---|---|
| Devices in same VLAN can't communicate across switches | VLAN not in trunk allowed list, or trunk not formed | show interfaces trunk — check VLANs in "VLANs allowed and active" |
| CDP native VLAN mismatch warning | Different native VLANs on each end of trunk | show interfaces [int] switchport — check "Trunking Native Mode VLAN" |
| Large file transfers failing on trunk | MTU mismatch — switch not handling 1522-byte tagged frames | show interfaces [int] — check for "input errors" or "giants" |
| Host can't communicate, port is access but in wrong VLAN | Access port assigned to wrong VLAN | show vlan brief — verify port is in correct VLAN |
| Trunk not forming between switches | DTP mode mismatch (auto/auto won't form trunk) | show interfaces [int] switchport — check "Administrative Mode" |
For a full guided troubleshooting scenario see Step-by-Step: Layer 2 VLAN & Trunk Troubleshooting.
14. Complete Summary
| Aspect | 802.1Q Behaviour |
|---|---|
| Tag size | 4 bytes added to the Ethernet frame |
| Tag location | Inserted after Source MAC address, before original EtherType |
| TPID value | 0x8100 — identifies the frame as 802.1Q tagged |
| VLAN ID range | 1–4094 (12-bit VID field; 0 and 4095 reserved) |
| Native VLAN | Frames sent and received untagged; default is VLAN 1 (change it) |
| Trunk port | Carries multiple VLANs tagged; one native VLAN untagged |
| Access port | Carries one VLAN; all frames untagged |
| MTU impact | Frame grows to 1522 bytes (single tag); 1526 bytes (Q-in-Q) |
| Security risk | VLAN hopping via DTP or double-tagging; mitigate with nonegotiate + native VLAN change. See Port Security. |
| QoS | PCP field (3 bits) provides 802.1p priority marking |