Access and Trunk Ports
1. Definition and Purpose
Switch ports operate in one of two fundamental modes that determine how VLAN traffic is handled. Understanding this distinction is one of the most foundational concepts in Cisco switching and a core CCNA topic.
- Access Port: A switch port configured to carry traffic for exactly one VLAN. Frames entering and leaving an access port are untagged — end devices such as PCs, printers, IP phones, and cameras never see or process VLAN tags. The switch internally tracks which VLAN the port belongs to and handles tagging transparently.
- Trunk Port: A switch port configured to carry traffic for multiple VLANs simultaneously. Each frame is tagged with an 802.1Q header identifying its VLAN, allowing a single physical link to transport traffic from many VLANs between switches, to routers, or to virtualization hosts.
Related pages: VLAN Tagging (802.1Q) | VLANs | VLAN Creation & Management | Router-on-a-Stick | Voice VLAN | Trunk Port Configuration (Step-by-Step) | Assigning VLANs to Switch Ports | Inter-VLAN Routing — Router-on-a-Stick
2. Access Port vs. Trunk Port — Full Comparison
| Aspect | Access Port | Trunk Port |
|---|---|---|
| VLANs carried | Single VLAN | Multiple VLANs (plus native VLAN untagged) |
| Frame tagging | None — frames always untagged to/from device | 802.1Q tags added/removed per VLAN (except native) |
| Typical connected device | PC, printer, IP phone, camera, AP | Switch, router, firewall, hypervisor, WLC |
| Cisco IOS command | switchport mode access |
switchport mode trunk |
| Native VLAN applies? | No | Yes — untagged frames belong to native VLAN |
| Default VLAN | VLAN 1 (unless changed) | Allows all VLANs by default; native VLAN 1 |
| VLAN hopping risk | Low (single VLAN, no negotiation) | Higher if DTP enabled or native VLAN misconfigured |
| DTP involvement | Can negotiate to trunk (if dynamic auto/desirable) | Actively involved in DTP negotiation |
3. 802.1Q VLAN Tagging — How It Works
IEEE 802.1Q is the industry-standard protocol for VLAN tagging on trunk links. When a frame enters a trunk port from the wired network, the switch inserts a 4-byte 802.1Q tag into the Ethernet frame header — after the source MAC address.
802.1Q Tag Structure
Original Ethernet Frame:
┌──────────┬──────────┬──────────┬──────────────────────┐
│ Dst MAC │ Src MAC │ EtherType│ Payload │
│ (6 bytes)│ (6 bytes)│ (2 bytes)│ │
└──────────┴──────────┴──────────┴──────────────────────┘
802.1Q Tagged Frame (trunk):
┌──────────┬──────────┬──────────────┬──────────┬───────────────────┐
│ Dst MAC │ Src MAC │ 802.1Q Tag │EtherType │ Payload │
│ (6 bytes)│ (6 bytes)│ (4 bytes) │ (2 bytes)│ │
└──────────┴──────────┴──────┬───────┴──────────┴───────────────────┘
│
┌───────────┴────────────┐
│ TPID: 0x8100 (2 bytes) │ Identifies 802.1Q frame
│ TCI: │
│ PCP: 3 bits (QoS) │ Priority Code Point
│ DEI: 1 bit │ Drop Eligible Indicator
│ VID: 12 bits │ VLAN ID (0–4094)
└────────────────────────┘
- TPID (Tag Protocol Identifier): Always 0x8100 — identifies this as an 802.1Q-tagged frame.
- PCP (Priority Code Point): 3 bits for 802.1p QoS marking — used to prioritize time-sensitive traffic like VoIP.
- DEI (Drop Eligible Indicator): 1 bit indicating whether the frame can be dropped during congestion.
- VID (VLAN Identifier): 12 bits — supports VLAN IDs 0–4095 (0 and 4095 reserved; usable range is 1–4094).
4. Native VLAN — Concept and Security
The native VLAN is a special concept that applies only to trunk ports. Frames belonging to the native VLAN are transmitted untagged across the trunk link — no 802.1Q tag is added. When a trunk port receives an untagged frame, the switch places it in the native VLAN.
- Cisco default native VLAN: VLAN 1 on all trunk ports.
- Native VLAN must match on both ends of a trunk link. A mismatch causes frames to be placed in the wrong VLAN — a common troubleshooting issue that generates CDP warnings.
- Management traffic (CDP, VTP, PAgP, LACP) always travels on VLAN 1, regardless of the native VLAN setting.
Native VLAN Mismatch Behaviour
Switch A (native VLAN 1) Switch B (native VLAN 99)
┌──────────────────────┐ ┌──────────────────────┐
│ Trunk port │ │ Trunk port │
│ Native VLAN: 1 │◀─────────▶│ Native VLAN: 99 │
└──────────────────────┘ └──────────────────────┘
Result: Untagged frames sent by Switch A (VLAN 1) are received
by Switch B and placed into VLAN 99 — traffic ends up in the
WRONG VLAN. CDP will report: "Native VLAN mismatch discovered."
Native VLAN Security Best Practices
- Change the native VLAN away from VLAN 1 to an unused, dedicated VLAN (e.g., VLAN 999).
- That unused native VLAN should carry no user traffic — it exists solely to handle untagged frames on the trunk.
- Ensure native VLAN matches on both ends of every trunk link.
- Use
vlan dot1q tag nativeglobally to force tagging of native VLAN frames, eliminating the untagged native VLAN entirely.
! Force tagging of native VLAN frames on all trunks (global) Switch(config)# vlan dot1q tag native
5. Configuring Access Ports
Access ports are straightforward to configure. Every end-device port should be explicitly set to access mode — never leave ports in dynamic auto/desirable mode on user-facing interfaces.
Basic Access Port Configuration
Switch(config)# interface GigabitEthernet0/1 Switch(config-if)# description PC - Finance Dept Switch(config-if)# switchport mode access Switch(config-if)# switchport access vlan 10 Switch(config-if)# switchport nonegotiate ! Disable DTP Switch(config-if)# spanning-tree portfast ! Enable PortFast for end devices Switch(config-if)# no shutdown
Configuring Multiple Access Ports at Once
! Configure ports 1–20 as access ports in VLAN 10 Switch(config)# interface range GigabitEthernet0/1 - 20 Switch(config-if-range)# switchport mode access Switch(config-if-range)# switchport access vlan 10 Switch(config-if-range)# switchport nonegotiate Switch(config-if-range)# spanning-tree portfast
Voice VLAN on an Access Port (IP Phone)
When connecting a Cisco IP phone, the port carries two VLANs: a data VLAN for the PC plugged into the phone's pass-through port, and a voice VLAN for VoIP traffic. The port is still considered an access port from the PC's perspective.
Switch(config)# interface GigabitEthernet0/5 Switch(config-if)# switchport mode access Switch(config-if)# switchport access vlan 10 ! Data VLAN for PC Switch(config-if)# switchport voice vlan 20 ! Voice VLAN for IP phone Switch(config-if)# spanning-tree portfast Switch(config-if)# no shutdown
6. Configuring Trunk Ports
Trunk ports require slightly more configuration — specifying the encapsulation (on older switches), setting the mode, and controlling which VLANs are allowed.
Full Trunk Port Configuration
Switch(config)# interface GigabitEthernet0/24 Switch(config-if)# description Trunk to Core-SW1 Switch(config-if)# switchport trunk encapsulation dot1q ! Required on older (3-layer) switches Switch(config-if)# switchport mode trunk Switch(config-if)# switchport trunk native vlan 999 ! Change from default VLAN 1 Switch(config-if)# switchport trunk allowed vlan 10,20,30,40,999 Switch(config-if)# switchport nonegotiate ! Disable DTP Switch(config-if)# no shutdown
Managing Allowed VLANs on a Trunk
! Add VLANs to existing allowed list (non-destructive) Switch(config-if)# switchport trunk allowed vlan add 50,60 ! Remove specific VLANs from allowed list Switch(config-if)# switchport trunk allowed vlan remove 40 ! Replace entire allowed list (overwrites — use with caution!) Switch(config-if)# switchport trunk allowed vlan 10,20,30 ! Allow ALL VLANs (default — not recommended in production) Switch(config-if)# switchport trunk allowed vlan all
Verify Trunk Configuration
Switch# show interfaces GigabitEthernet0/24 trunk Port Mode Encapsulation Status Native vlan Gi0/24 on 802.1q trunking 999 Port Vlans allowed on trunk Gi0/24 10,20,30,999 Port Vlans allowed and active in management domain Gi0/24 10,20,30,999 Port Vlans in spanning tree forwarding state and not pruned Gi0/24 10,20,30,999
7. Dynamic Trunking Protocol (DTP)
DTP is a Cisco-proprietary protocol that allows switch ports to automatically negotiate whether to form a trunk link. While convenient in lab environments, DTP poses a security risk in production — it should be disabled on all user-facing and external ports.
DTP Mode Negotiation Matrix
| Local Port Mode | Remote: Access | Remote: Dynamic Auto | Remote: Dynamic Desirable | Remote: Trunk |
|---|---|---|---|---|
| Access | Access ✅ | Access | Access | Access (misconfigured!) |
| Dynamic Auto | Access | Access ⚠️ | Trunk | Trunk |
| Dynamic Desirable | Access | Trunk | Trunk | Trunk |
| Trunk | Access (misconfigured!) | Trunk | Trunk | Trunk ✅ |
dynamic auto will NOT form a trunk —
both are passively waiting for the other to initiate. You need at least one side set to
dynamic desirable or trunk for a trunk to form automatically.
Always use spanning-tree portfast on access ports facing end devices — see
PortFast & BPDU Guard.
Disabling DTP — Best Practice Configuration
! On user-facing access ports — explicitly set mode and disable DTP Switch(config-if)# switchport mode access Switch(config-if)# switchport nonegotiate ! On trunk ports — explicitly set trunk mode and disable DTP Switch(config-if)# switchport mode trunk Switch(config-if)# switchport nonegotiate
switchport nonegotiate stops the port from sending DTP frames entirely. This is required
when connecting to non-Cisco devices that do not understand DTP and may misinterpret DTP frames.
8. Frame Handling — Access vs. Trunk Ports Step by Step
Understanding exactly what happens to a frame as it enters and exits each port type is critical for the CCNA exam.
Frame Path: PC → Access Port → Trunk → Access Port → PC
PC-A (VLAN 10)
│
│ Untagged Ethernet frame
▼
┌─────────────────────┐
│ Switch A — Gi0/1 │ Access port, VLAN 10
│ (Access Port) │ Switch tags frame internally as VLAN 10
└──────────┬──────────┘
│
│ 802.1Q tagged frame [VLAN 10]
▼
┌─────────────────────┐
│ Switch A — Gi0/24 │ Trunk port
│ (Trunk Port) │ Adds 802.1Q tag: VLAN ID = 10
└──────────┬──────────┘
│
│ Tagged frame travels across trunk link
▼
┌─────────────────────┐
│ Switch B — Gi0/24 │ Trunk port
│ (Trunk Port) │ Reads VLAN ID = 10, forwards to VLAN 10 ports
└──────────┬──────────┘
│
│ 802.1Q tag removed
▼
┌─────────────────────┐
│ Switch B — Gi0/3 │ Access port, VLAN 10
│ (Access Port) │ Strips 802.1Q tag — sends untagged frame
└──────────┬──────────┘
│
│ Untagged Ethernet frame
▼
PC-B (VLAN 10)
Native VLAN Frame Handling on Trunk
- A frame arriving on a trunk port without a tag is placed into the native VLAN.
- A frame being sent out a trunk port belonging to the native VLAN is sent untagged.
- All other VLANs on a trunk port are always tagged with their respective VLAN IDs.
9. Router-on-a-Stick — Trunk to Router
Router-on-a-Stick (ROAS) is an inter-VLAN routing method where a single router interface is configured as a trunk, with sub-interfaces for each VLAN acting as the default gateway for that VLAN. The physical switch port connected to the router is configured as a trunk.
Router-on-a-Stick Architecture
┌─────────┐ Trunk (VLANs 10,20,30) ┌─────────────────────────┐
│ Switch │◀─────────────────────────▶│ Router │
│ │ Gi0/0 (trunk port) │ Gi0/0.10 — VLAN 10 GW │
└─────────┘ │ Gi0/0.20 — VLAN 20 GW │
│ │ Gi0/0.30 — VLAN 30 GW │
Access ports: └─────────────────────────┘
Gi0/1 VLAN 10 (Finance)
Gi0/2 VLAN 20 (HR)
Gi0/3 VLAN 30 (IT)
Router Sub-Interface Configuration
! Router — sub-interfaces for each VLAN Router(config)# interface GigabitEthernet0/0 Router(config-if)# no shutdown Router(config)# interface GigabitEthernet0/0.10 Router(config-subif)# encapsulation dot1Q 10 Router(config-subif)# ip address 192.168.10.1 255.255.255.0 Router(config)# interface GigabitEthernet0/0.20 Router(config-subif)# encapsulation dot1Q 20 Router(config-subif)# ip address 192.168.20.1 255.255.255.0 Router(config)# interface GigabitEthernet0/0.30 Router(config-subif)# encapsulation dot1Q 30 Router(config-subif)# ip address 192.168.30.1 255.255.255.0
Switch Trunk Port to Router
! Switch — trunk port connecting to the router Switch(config)# interface GigabitEthernet0/24 Switch(config-if)# switchport trunk encapsulation dot1q Switch(config-if)# switchport mode trunk Switch(config-if)# switchport trunk allowed vlan 10,20,30 Switch(config-if)# switchport trunk native vlan 999 Switch(config-if)# switchport nonegotiate
See: Router-on-a-Stick Explained | Inter-VLAN Routing — Router-on-a-Stick (Step-by-Step) | Inter-VLAN Routing — Layer 3 Switch
10. VLAN Hopping Attacks and Prevention
VLAN hopping is a Layer 2 attack where a malicious device sends traffic to a VLAN it should not have access to, bypassing network segmentation. There are two primary methods:
Attack Method 1 — Switch Spoofing
An attacker's device sends DTP frames pretending to be a switch, tricking the legitimate switch into forming a trunk. Once the trunk forms, the attacker's device can send and receive traffic on any VLAN carried by the trunk — bypassing access control entirely.
switchport mode access
and switchport nonegotiate. A port in explicit access mode cannot be tricked into
forming a trunk regardless of what DTP frames it receives.
Attack Method 2 — Double Tagging
The attacker sends a frame with two 802.1Q tags — an outer tag matching the native VLAN and an inner tag for the target VLAN. The first switch strips the outer (native VLAN) tag and forwards the frame with the inner tag still intact onto the trunk. The second switch reads the inner tag and delivers the frame to the target VLAN — which the attacker should not have access to.
Attacker sends double-tagged frame:
┌──────────┬──────────┬─────────────┬─────────────┬──────────┐
│ Dst MAC │ Src MAC │Outer Tag │ Inner Tag │ Payload │
│ │ │VLAN 1(native│ VLAN 99 │ │
└──────────┴──────────┴──────┬──────┴─────────────┴──────────┘
│
Switch 1 strips outer tag
(VLAN 1 = native, sent untagged)
│
▼
┌──────────┬──────────┬─────────────┬──────────┐
│ Dst MAC │ Src MAC │ Inner Tag │ Payload │
│ │ │ VLAN 99 │ │
└──────────┴──────────┴──────┬──────┴──────────┘
│
Switch 2 delivers to VLAN 99 ← Attacker wins
Complete VLAN Security Hardening Checklist
- Set all user-facing ports explicitly to
switchport mode access. - Disable DTP on all ports:
switchport nonegotiate. - Change native VLAN from VLAN 1 to an unused, dedicated VLAN (e.g., VLAN 999).
- Shutdown and assign all unused ports to a "black hole" VLAN (e.g., VLAN 999) that has no routing or active traffic.
- Restrict allowed VLANs on trunks to only those explicitly required.
- Do not use VLAN 1 for any user, management, or native traffic.
- Enable
vlan dot1q tag nativeglobally to tag native VLAN frames.
See: DHCP Snooping & Dynamic ARP Inspection | VLAN Creation & Management
11. Common Use Cases
| Scenario | Port Type | Configuration Notes |
|---|---|---|
| PC / workstation | Access — single data VLAN | Explicit access mode + nonegotiate + PortFast |
| IP phone with PC passthrough | Access — data VLAN + voice VLAN | switchport access vlan 10 + switchport voice vlan 20 |
| Printer / IoT device | Access — single VLAN | Isolate in a dedicated VLAN for security |
| Switch uplink (access layer → distribution) | Trunk — multiple VLANs | Explicit trunk mode + restricted allowed VLANs + nonegotiate |
| Router-on-a-Stick (inter-VLAN routing) | Trunk — to router | Router sub-interfaces with encapsulation dot1Q <vlan> |
| Wireless LAN Controller (WLC) | Trunk — multiple SSIDs/VLANs | Each SSID maps to a VLAN; WLC port carries all SSIDs as a trunk |
| VMware / Hyper-V hypervisor | Trunk — virtual machine VLANs | Hypervisor handles tagging internally for each VM's VLAN |
| Firewall DMZ interface | Trunk — multiple security zones | Each firewall interface or sub-interface represents a VLAN/zone |
12. Troubleshooting Access and Trunk Ports
Common Issues and Solutions
| Problem | Likely Cause | Solution |
|---|---|---|
| Trunk not forming between switches | Both ports set to dynamic auto — neither initiates |
Set at least one side to switchport mode trunk or
dynamic desirable |
| Native VLAN mismatch warning (CDP) | Native VLAN configured differently on each end of trunk | Set same native VLAN on both sides:
switchport trunk native vlan 999 |
| VLAN traffic not passing through trunk | VLAN not in the allowed list on one or both sides | Add VLAN: switchport trunk allowed vlan add <vlan-id> |
| PC cannot communicate across trunk link | VLAN exists on one switch but not the other (VTP or manual mismatch) | Create VLAN on both switches; verify with show vlan brief |
| Port shows as access when trunk was expected | Remote end is in access mode; DTP negotiation resulted in access | Explicitly set both ends to switchport mode trunk |
| Device cannot get IP address (DHCP fails) | Access port assigned to wrong VLAN; DHCP helper not configured on VLAN SVI | Verify show interfaces switchport; check VLAN SVI and
ip helper-address |
Key Verification Commands
| Command | What It Shows |
|---|---|
show interfaces switchport |
Port mode (access/trunk), access VLAN, voice VLAN, native VLAN, allowed VLANs |
show interfaces trunk |
All active trunk ports, encapsulation, native VLAN, allowed VLANs, active VLANs in STP |
show vlan brief |
All VLANs on the switch and which ports are assigned to each VLAN |
show interfaces Gi0/1 switchport |
Detailed switchport config for a specific interface |
show mac address-table vlan 10 |
MAC addresses learned on VLAN 10 and which ports they are on |
show cdp neighbors detail |
Reveals native VLAN mismatch warnings between CDP-capable neighbors |
See: show vlan Explained | Troubleshooting Layer 2 — VLAN & Trunk Issues
13. Multi-Vendor Considerations
While 802.1Q is a universal standard, the CLI commands and negotiation behavior differ across vendors. DTP is Cisco-proprietary and does not exist on non-Cisco equipment.
| Vendor | Trunk Command Example | Notes |
|---|---|---|
| Cisco IOS | switchport mode trunk |
DTP available; use nonegotiate with non-Cisco peers |
| Aruba / HP | tagged vlan 10,20,30 |
No DTP — trunking always manual; "tagged" = trunk, "untagged" = access |
| Juniper EX | set interfaces ge-0/0/0 unit 0 family ethernet-switching interface-mode trunk |
No DTP; VLANs listed explicitly per interface |
| Fortinet / other | GUI-based or vendor-specific CLI | Always use switchport nonegotiate on Cisco side when connecting to
non-Cisco devices |
14. Common Misconceptions
-
"An access port only carries its assigned VLAN — all other VLANs are blocked."
Correct in terms of forwarding, but the reason is that the switch simply does not tag or forward any other VLAN's frames on that port — it's not an active block, just isolation by design. -
"Two switches set to dynamic auto will form a trunk automatically."
No — both sides are passively waiting for the other to initiate. Twodynamic autoports result in an access link, not a trunk. At least one side must betrunkordynamic desirable. -
"The native VLAN on a trunk can be any VLAN, and it doesn't need to match the other side."
The native VLAN must match on both ends. A mismatch causes untagged frames to land in the wrong VLAN — a logic error that CDP will warn about but the switch will not automatically fix. -
"A port in trunk mode always carries all VLANs."
By default yes, but the allowed VLAN list can restrict which VLANs traverse the trunk. Additionally, a VLAN must exist on the switch (in the VLAN database) AND be in the allowed list to actually be trunked.show interfaces trunkshows the distinction between "allowed" and "active." -
"Hiding management traffic on VLAN 1 is safe because VLAN 1 is not routed."
VLAN 1 is the default native VLAN and carries CDP, VTP, STP, and other control traffic. Using VLAN 1 for management makes it a high-value target and exposes management traffic to double- tagging attacks. Always move management to a dedicated, non-default VLAN.
15. Key Points & Exam Tips
| Topic | Key Facts to Remember |
|---|---|
| Access port | Single VLAN; frames untagged to/from device; use for all end devices; explicit
switchport mode access |
| Trunk port | Multiple VLANs; 802.1Q tags; switch-to-switch, switch-to-router, hypervisors;
explicit switchport mode trunk |
| 802.1Q tag | 4-byte tag inserted after Src MAC; contains 12-bit VID (VLAN ID 1–4094); TPID = 0x8100 |
| Native VLAN | Sent untagged on trunk; default is VLAN 1; must match both ends; change to unused VLAN for security |
| DTP | Cisco-only; auto+auto = access (NOT trunk); disable with nonegotiate;
never leave enabled on user ports |
| VLAN hopping | Switch spoofing (DTP exploit) and double tagging (native VLAN exploit); prevent with access mode + nonegotiate + change native VLAN |
| Voice VLAN | Access port carries data VLAN (untagged) + voice VLAN (tagged to phone via CDP); port still classified as access |
| Allowed VLANs | Use add/remove to modify without overwriting; a VLAN must
exist on the switch AND be in the allowed list to traverse the trunk |
Related pages: VLAN Tagging (802.1Q) | VLANs | VLAN Creation & Management | Router-on-a-Stick | Voice VLAN | Layer 3 Switch Routing | show vlan Command | STP Overview | PortFast & BPDU Guard | Trunk Port Configuration | Assigning VLANs to Switch Ports | Inter-VLAN Routing — Router-on-a-Stick | Inter-VLAN Routing — Layer 3 Switch | VLAN Creation & Management | Voice VLAN Configuration | Troubleshooting Layer 2 — VLAN & Trunk