Trunk Port Configuration (802.1Q)
Access ports connect end devices to a single VLAN. But what happens when devices in VLAN 10 on one switch need to communicate with devices in VLAN 10 on another switch? A single cable between the two switches must carry traffic for all VLANs simultaneously — this is exactly what a trunk link does. Using the IEEE 802.1Q standard, the switch inserts a 4-byte VLAN tag into each Ethernet frame so the receiving switch knows which VLAN the traffic belongs to.
This lab covers everything you need to configure, restrict, and verify trunk links on Cisco IOS switches. Before starting, ensure VLANs are already created by completing VLAN Creation and Management and Assigning VLANs to Switch Ports. For VLAN concepts see VLANs and VLAN Tagging 802.1Q. For troubleshooting trunk issues see Troubleshooting Layer 2 VLANs & Trunks.
1. How 802.1Q Trunking Works
When a switch sends a frame out a trunk port, it inserts a VLAN tag into the Ethernet frame header. The receiving switch reads this tag, identifies the VLAN, strips the tag, and forwards the frame to the correct access port.
802.1Q Frame Tag Structure
| Field | Size | Value / Purpose |
|---|---|---|
| TPID (Tag Protocol ID) | 2 bytes | Always 0x8100 — identifies this as an 802.1Q tagged frame |
| PCP (Priority Code Point) | 3 bits | CoS (Class of Service) value for QoS — 0–7, used to prioritize voice/video traffic |
| DEI (Drop Eligible Indicator) | 1 bit | Marks frames eligible to be dropped during congestion |
| VID (VLAN Identifier) | 12 bits | The VLAN ID (1–4094) — tells the receiving switch which VLAN this frame belongs to |
Access Port vs Trunk Port
| Feature | Access Port | Trunk Port |
|---|---|---|
| Connected to | End devices (PC, printer, IP phone) | Other switches, routers, or Layer 3 switches |
| VLANs carried | One data VLAN only | Multiple VLANs simultaneously |
| Frame tagging | Untagged — end device unaware of VLAN | Tagged with 802.1Q headers (except native VLAN) |
| IOS mode command | switchport mode access |
switchport mode trunk |
Native VLAN — The Exception
One VLAN on a trunk is designated the native VLAN. Frames belonging to the native VLAN are sent untagged across the trunk. By default this is VLAN 1. The native VLAN must match on both ends of a trunk — a mismatch causes a CDP/STP warning and frames are delivered to the wrong VLAN, creating a subtle and dangerous security hole known as VLAN hopping.
2. DTP — Dynamic Trunking Protocol
Cisco switches use DTP (Dynamic Trunking Protocol) to automatically negotiate trunk links between Cisco devices. While convenient in labs, DTP should always be disabled in production environments — it can be exploited to cause unauthorized trunk negotiation.
| DTP Mode | Behavior | Forms Trunk With |
|---|---|---|
dynamic auto |
Passively waits — will form trunk if other side initiates | dynamic desirable, trunk |
dynamic desirable |
Actively tries to negotiate a trunk | dynamic auto, dynamic desirable, trunk |
trunk |
Forces trunk mode — does not negotiate | Any mode (always a trunk) |
access |
Forces access mode — never a trunk | Never |
nonegotiate |
Disables DTP entirely — used with trunk mode |
N/A — DTP frames not sent |
dynamic auto ports facing each other will NOT form a trunk
— both are passively waiting. At least one side must be desirable or
trunk. This is a common exam scenario.
Lab Scenario
In this lab, NetsTuts_SW1 and NetsTuts_SW2 are
connected via GigabitEthernet0/1 on each switch. Both switches have
VLANs 10, 20, 30, and 40 created. The trunk link will carry all four VLANs,
with VLAN 999 set as the native VLAN.
[PC-VLAN10]──Fa0/1──[NetsTuts_SW1]──Gi0/1═══Gi0/1──[NetsTuts_SW2]──Fa0/1──[PC-VLAN10]
[PC-VLAN20]──Fa0/2──[ ] [ ]──Fa0/2──[PC-VLAN20]
[PC-VLAN30]──Fa0/3──[ ] [ ]──Fa0/3──[PC-VLAN30]
═══ = 802.1Q Trunk Link (Gi0/1 — Gi0/1)
Native VLAN: 999
Allowed VLANs: 10, 20, 30, 40
| Parameter | Value |
|---|---|
| Trunk interface (both switches) | GigabitEthernet0/1 |
| Encapsulation | 802.1Q (dot1q) |
| Native VLAN | 999 (unused — security hardening) |
| Allowed VLANs | 10, 20, 30, 40 |
3. Step 1 — Configure a Basic Trunk Port
Configure GigabitEthernet0/1 on NetsTuts_SW1 as a
trunk port. Repeat the same commands on NetsTuts_SW2.
NetsTuts_SW1 — Trunk Configuration
NetsTuts_SW1>en NetsTuts_SW1#conf t Enter configuration commands, one per line. End with CNTL/Z. NetsTuts_SW1(config)#interface GigabitEthernet0/1 NetsTuts_SW1(config-if)#description Trunk to NetsTuts_SW2 NetsTuts_SW1(config-if)#switchport trunk encapsulation dot1q NetsTuts_SW1(config-if)#switchport mode trunk NetsTuts_SW1(config-if)#switchport nonegotiate NetsTuts_SW1(config-if)#end NetsTuts_SW1#wr Building configuration... [OK] NetsTuts_SW1#
switchport nonegotiate disables DTP —
the port will not send or respond to DTP negotiation frames.
Command Breakdown
| Command | What It Does | Notes |
|---|---|---|
description Trunk to NetsTuts_SW2 |
Labels the interface for documentation | Best practice — makes the trunk link immediately identifiable |
switchport trunk encapsulation dot1q |
Sets the trunking encapsulation to IEEE 802.1Q | Required on some older Cisco switches that also support ISL. Not needed on most modern Catalyst switches that only support 802.1Q. |
switchport mode trunk |
Forces the port into permanent trunk mode | Does not wait for DTP negotiation — always a trunk |
switchport nonegotiate |
Disables DTP frame transmission | Prevents the port from sending or accepting DTP negotiation — security hardening |
NetsTuts_SW2 — Mirror Configuration
NetsTuts_SW2>en NetsTuts_SW2#conf t Enter configuration commands, one per line. End with CNTL/Z. NetsTuts_SW2(config)#interface GigabitEthernet0/1 NetsTuts_SW2(config-if)#description Trunk to NetsTuts_SW1 NetsTuts_SW2(config-if)#switchport trunk encapsulation dot1q NetsTuts_SW2(config-if)#switchport mode trunk NetsTuts_SW2(config-if)#switchport nonegotiate NetsTuts_SW2(config-if)#end NetsTuts_SW2#wr Building configuration... [OK] NetsTuts_SW2#
4. Step 2 — Restrict Allowed VLANs
By default, a trunk port carries all VLANs (1–4094). This is inefficient and a security risk — VLANs that have no devices on a particular switch segment should not be carried across that trunk. Restricting allowed VLANs limits traffic to only what is needed.
Set Allowed VLANs to 10, 20, 30, and 40
NetsTuts_SW1(config)#interface GigabitEthernet0/1 NetsTuts_SW1(config-if)#switchport trunk allowed vlan 10,20,30,40 NetsTuts_SW1(config-if)#end NetsTuts_SW1#wr Building configuration... [OK] NetsTuts_SW1#
Allowed VLAN Command Options
| Command | Result | Use Case |
|---|---|---|
switchport trunk allowed vlan 10,20,30 |
Replaces the allowed list with exactly these VLANs | Setting the list from scratch |
switchport trunk allowed vlan add 40 |
Adds VLAN 40 to the existing allowed list | Adding a new VLAN without disrupting others |
switchport trunk allowed vlan remove 20 |
Removes VLAN 20 from the allowed list | Decommissioning a VLAN from a trunk segment |
switchport trunk allowed vlan all |
Restores the default — all VLANs allowed | Resetting to default (not recommended for production) |
switchport trunk allowed vlan except 1,999 |
Allows all VLANs except the specified ones | Excluding specific VLANs from a trunk |
switchport trunk allowed vlan add 40
vs switchport trunk allowed vlan 40. The first adds
VLAN 40 to the existing list. The second replaces the entire list
with just VLAN 40 — removing all previously allowed VLANs. Always use add
when extending an existing list.
5. Step 3 — Set the Native VLAN
Change the native VLAN from the default VLAN 1 to an unused VLAN (999). This must be configured identically on both ends of every trunk link — a mismatch triggers CDP/STP warnings and causes traffic to be misdelivered.
On NetsTuts_SW1
NetsTuts_SW1(config)#interface GigabitEthernet0/1 NetsTuts_SW1(config-if)#switchport trunk native vlan 999 NetsTuts_SW1(config-if)#end NetsTuts_SW1#wr Building configuration... [OK] NetsTuts_SW1#
On NetsTuts_SW2
NetsTuts_SW2(config)#interface GigabitEthernet0/1 NetsTuts_SW2(config-if)#switchport trunk native vlan 999 NetsTuts_SW2(config-if)#end NetsTuts_SW2#wr Building configuration... [OK] NetsTuts_SW2#
Create VLAN 999 on Both Switches
NetsTuts_SW1(config)#vlan 999 NetsTuts_SW1(config-vlan)#name NATIVE-UNUSED NetsTuts_SW1(config-vlan)#end
6. Complete Trunk Configuration (Both Switches)
! ══════════════════════════════════════════════════════════ ! NetsTuts Trunk Baseline — NetsTuts_SW1 ! ══════════════════════════════════════════════════════════ NetsTuts_SW1>en NetsTuts_SW1#conf t Enter configuration commands, one per line. End with CNTL/Z. ! ── Create native VLAN ──────────────────────────────────── NetsTuts_SW1(config)#vlan 999 NetsTuts_SW1(config-vlan)#name NATIVE-UNUSED NetsTuts_SW1(config-vlan)#exit ! ── Configure trunk port ────────────────────────────────── NetsTuts_SW1(config)#interface GigabitEthernet0/1 NetsTuts_SW1(config-if)#description Trunk to NetsTuts_SW2 NetsTuts_SW1(config-if)#switchport trunk encapsulation dot1q NetsTuts_SW1(config-if)#switchport mode trunk NetsTuts_SW1(config-if)#switchport nonegotiate NetsTuts_SW1(config-if)#switchport trunk allowed vlan 10,20,30,40 NetsTuts_SW1(config-if)#switchport trunk native vlan 999 NetsTuts_SW1(config-if)#end NetsTuts_SW1#wr Building configuration... [OK] NetsTuts_SW1#
7. Verification
show interfaces trunk
The primary command for verifying trunk links — shows all active trunks, their encapsulation, native VLAN, and allowed/active VLAN lists:
NetsTuts_SW1#show interfaces trunk Port Mode Encapsulation Status Native vlan Gi0/1 on 802.1q trunking 999 Port Vlans allowed on trunk Gi0/1 10,20,30,40 Port Vlans allowed and active in the management domain Gi0/1 10,20,30,40 Port Vlans in spanning tree forwarding state and not pruned Gi0/1 10,20,30,40
show interfaces trunk — Output Explained
| Section | Meaning | What to Check |
|---|---|---|
| Mode: on | Port is statically set to trunk (switchport mode trunk) |
Confirm "on" — "desirable" or "auto" means DTP is still active |
| Encapsulation: 802.1q | Using IEEE 802.1Q tagging standard | Should always be 802.1q in modern networks |
| Status: trunking | Trunk is operational | "not-trunking" means the link is not forming a trunk — check both ends |
| Native vlan: 999 | Native VLAN is set to 999 | Must match on both ends — mismatch causes CDP warning and traffic issues |
| Vlans allowed on trunk | VLANs configured in the allowed list | Confirm only required VLANs are listed |
| Vlans allowed and active | VLANs that exist in the VLAN database AND are allowed | A VLAN missing here means it was not created — check show vlan brief |
| Vlans in STP forwarding | VLANs actively forwarding traffic (not blocked by STP) | A VLAN missing here is blocked by STP |
show interfaces GigabitEthernet0/1 switchport
NetsTuts_SW1#show interfaces GigabitEthernet0/1 switchport Name: Gi0/1 Switchport: Enabled Administrative Mode: trunk Operational Mode: trunk Administrative Trunking Encapsulation: dot1q Operational Trunking Encapsulation: dot1q Negotiation of Trunking: Off Access Mode VLAN: 1 (default) Trunking Native Mode VLAN: 999 (NATIVE-UNUSED) Trunking VLANs Enabled: 10,20,30,40
switchport nonegotiate is working.
Native VLAN shows the name "NATIVE-UNUSED" — confirming VLAN 999 was created and named.
show running-config interface GigabitEthernet0/1
NetsTuts_SW1#show running-config interface GigabitEthernet0/1 ! interface GigabitEthernet0/1 description Trunk to NetsTuts_SW2 switchport trunk encapsulation dot1q switchport trunk native vlan 999 switchport trunk allowed vlan 10,20,30,40 switchport mode trunk switchport nonegotiate !
8. Troubleshooting Trunk Issues
| Problem | Symptom | Cause | Fix |
|---|---|---|---|
| Trunk not forming | show interfaces trunk shows no output for the port |
Both sides set to dynamic auto — neither initiates; or one side is access mode |
Set at least one side to switchport mode trunk |
| Native VLAN mismatch | CDP warning: %CDP-4-NATIVE_VLAN_MISMATCH |
Native VLAN configured differently on each end of the trunk | Set the same native VLAN on both ends with switchport trunk native vlan 999 |
| VLAN traffic not crossing trunk | Devices in same VLAN on different switches cannot ping each other | VLAN not in the allowed list, or VLAN not created on the remote switch | Check show interfaces trunk "allowed and active" section; create the VLAN on both switches |
| VLAN active but not forwarding | VLAN appears in "allowed and active" but not in "STP forwarding" section | STP has blocked this VLAN on the port | Check show spanning-tree vlan [id] — identify root bridge and port roles |
| DTP still active | show interfaces switchport shows "Negotiation of Trunking: On" |
switchport nonegotiate not configured |
Add switchport nonegotiate under the trunk interface |
| VLAN 1 traffic appearing unexpectedly | Untagged management traffic crossing the trunk | Native VLAN left as default VLAN 1 — untagged frames are associated with VLAN 1 | Change native VLAN to an unused VLAN: switchport trunk native vlan 999 |
Key Points & Exam Tips
- A trunk port carries multiple VLANs simultaneously using 802.1Q tagging — a 4-byte tag is inserted into each Ethernet frame identifying its VLAN.
- The native VLAN is the one VLAN whose traffic is sent untagged across a trunk. It must match on both ends — a mismatch causes CDP/STP warnings and traffic misdelivery.
- Change the native VLAN from the default VLAN 1 to an unused VLAN (e.g., 999) on all trunk links — this is a security best practice that prevents VLAN hopping attacks.
- By default a trunk carries all VLANs (1–4094). Always restrict with
switchport trunk allowed vlan [list]— only carry VLANs that have devices on both sides of the trunk. - Use
switchport trunk allowed vlan add [id]to add a VLAN — never justswitchport trunk allowed vlan [id]which replaces the entire allowed list. - Always disable DTP with
switchport nonegotiateon trunk ports in production — DTP negotiation can be exploited to create unauthorized trunks. - Two ports both set to
dynamic autowill not form a trunk — both are waiting for the other to initiate. show interfaces trunkis the primary verification command — memorize its four output sections: mode/encapsulation/status/native VLAN, allowed VLANs, allowed and active, STP forwarding.- A VLAN appearing in "allowed" but not in "allowed and active" means the VLAN was not created on this switch — run
show vlan briefto confirm. - Trunk links are required for Router-on-a-Stick and Layer 3 Switch inter-VLAN routing — mastering trunk configuration is a prerequisite for both.
- Multiple trunk links between switches can be bundled using EtherChannel (LACP) for increased bandwidth and redundancy.