---
title: "VLANs and Trunks for CCNA: 802.1Q and DTP | CyberWithMadhav"
description: "Free CCNA lesson: create VLANs, access and voice ports, 802.1Q trunks with a safe native VLAN, the DTP table and VLAN hopping defences, with a lab."
url: https://www.cyberwithmadhav.com/learn-ccna-vlans-trunks.html
source_format: markdown rendering of the HTML page
---

[Learn](https://www.cyberwithmadhav.com/learn.html) / [Stage 3: Networking and CCNA](https://www.cyberwithmadhav.com/learn.html#stage-3) / Lesson 3.4

$ lesson 3.4 --track ccna --domain access

# VLANs and Trunks: 802.1Q, Native VLAN, DTP, Voice VLAN

VLANs are the first real security boundary inside a network: guests on one side, staff on another, phones in their own lane. Build them, join switches with trunks that cannot be talked into leaking, and understand the two classic VLAN hopping tricks well enough to shut them down.

- Stage **3** Networking and CCNA
- Level **Intermediate**
- **60** min
- **5** sections, quiz, lab

Start the lesson Jump to the lab

## In this lesson

1. VLANs: separate networks on shared switches
2. Access ports and voice VLANs
3. 802.1Q trunks, the native VLAN and allowed lists
4. DTP: when two switches negotiate a trunk
5. VLAN hopping and how to stop it
6. Flashcards
7. Quick quiz
8. Hands-on lab
9. Key takeaways

## By the end of this lesson you can

- Create normal range VLANs and assign data and voice access ports
- Build 802.1Q trunks with a non default native VLAN and an allowed list
- Predict the result of each DTP mode pair and switch DTP off
- Explain switch spoofing and double tagging and apply the standard defences

3.4.01

## VLANs: separate networks on shared switches

A **VLAN** is a separate broadcast domain carved out of shared switches. Ports in VLAN 10 and ports in VLAN 20 behave as if they were on different switches: broadcasts stay inside their VLAN, and traffic between VLANs must go through a router or Layer 3 switch (lesson 3.6), which is exactly where you can filter it.

- **Normal range**: 1 to 1005. VLANs 1002 to 1005 are reserved for old FDDI and Token Ring uses. **Extended range**: 1006 to 4094.
- **VLAN 1** is the default; every port starts there and it cannot be deleted. Good practice is to keep users and management out of it.
- Each VLAN normally gets its own IP subnet, so your VLSM plan from lesson 3.2 maps straight onto VLANs.

| VLAN | Name | Subnet | Ports on each switch |
| --- | --- | --- | --- |
| 10 | STAFF | 192.168.10.0/24 | Fa0/1 to Fa0/10 |
| 20 | GUEST | 192.168.20.0/24 | Fa0/11 to Fa0/20 |
| 30 | VOICE | 192.168.30.0/24 | voice on Fa0/3 |
| 99 | NATIVE | no hosts | trunk native VLAN only |
| 999 | PARKING | no hosts | Fa0/21 to Fa0/24, shut |

Think of it like this

VLANs are separate WhatsApp groups on the same phone network. Everyone uses the same towers, but a message to the family group never reaches the office group, and forwarding between groups needs someone (the router) to do it deliberately.

3.4.02

## Access ports and voice VLANs

An **access port** belongs to one data VLAN and sends untagged frames, so the PC never knows VLANs exist. It can also carry one **voice VLAN**, so an IP phone and the PC plugged into the phone share one cable: the phone tags its own traffic with the voice VLAN (CDP or LLDP tells it which one), and the PC's traffic stays untagged in the data VLAN.

```
SW1(config)#vlan 10
SW1(config-vlan)#name STAFF
SW1(config-vlan)#exit
SW1(config)#interface range Fa0/1 - 10
SW1(config-if-range)#switchport mode access
SW1(config-if-range)#switchport access vlan 10
SW1(config-if-range)#switchport nonegotiate
SW1(config-if-range)#interface Fa0/3
SW1(config-if)#switchport voice vlan 30
```

If you assign a port to a VLAN that does not exist yet, IOS creates it for you with a message such as `% Access VLAN does not exist. Creating vlan 10`, named VLAN0010. Name your VLANs anyway; names make `show vlan brief` readable at 2 a.m.

3.4.03

## 802.1Q trunks, the native VLAN and allowed lists

A **trunk** carries many VLANs over one link, usually between switches or to a router. It marks each frame's VLAN by inserting a 4 byte **802.1Q tag**.

The 802.1Q tag sits between the source MAC and the EtherType. Its 12 bit VLAN ID allows VLANs 1 to 4094 (0 and 4095 are reserved).

- The **native VLAN** is the one VLAN sent *untagged* on a trunk (VLAN 1 unless you change it). Both ends must agree. A mismatch makes frames leak between VLANs, and CDP reports it with a message like `%CDP-4-NATIVE_VLAN_MISMATCH`.
- The **allowed list** (`switchport trunk allowed vlan 10,20,30,99`) limits which VLANs cross the trunk. By default, all of them do.
- On 2960 class switches only 802.1Q exists, so `switchport trunk encapsulation dot1q` is not needed (and may be rejected). On 3560 and 3650 class switches you may need it before `switchport mode trunk`.

```
SW1(config)#interface GigabitEthernet0/1
SW1(config-if)#switchport mode trunk
SW1(config-if)#switchport trunk native vlan 99
SW1(config-if)#switchport trunk allowed vlan 10,20,30,99
SW1(config-if)#switchport nonegotiate
SW1#show interfaces trunk
```

3.4.04

## DTP: when two switches negotiate a trunk

Cisco switches can negotiate whether a link becomes a trunk using **DTP** (Dynamic Trunking Protocol). The result depends on the mode at each end:

|  | dynamic auto | dynamic desirable | trunk | access |
| --- | --- | --- | --- | --- |
| **dynamic auto** | access | trunk | trunk | access |
| **dynamic desirable** | trunk | trunk | trunk | access |
| **trunk** | trunk | trunk | trunk | limited connectivity |
| **access** | access | access | limited connectivity | access |

The default on many current Catalyst switches, including the 2960, is `dynamic auto`, and auto plus auto gives an *access* link. That surprises people: two new switches cabled together do not trunk until you configure one side. Professionals do not rely on negotiation at all; they hard code every port as access or trunk and turn DTP off with `switchport nonegotiate`.

3.4.05

## VLAN hopping and how to stop it
How attackers abuse this

**Switch spoofing**: a laptop that speaks DTP talks a user port left in `dynamic` mode into becoming a trunk, and suddenly receives every VLAN. **Double tagging**: an attacker in the trunk's native VLAN sends a frame with two tags; the first switch strips the outer (native) tag and forwards the frame, and the next switch reads the inner tag and delivers it into another VLAN. Double tagging only works from the native VLAN and only one way, but that is enough to send attack traffic into a protected VLAN.
Defender move

The standard defences, all of which you configure in this lesson's lab:

- User ports: `switchport mode access` plus `switchport nonegotiate`.
- Trunks: `switchport mode trunk` plus `switchport nonegotiate`, and only the needed VLANs allowed.
- Native VLAN set to an unused VLAN that no host uses (VLAN 99 here), and no users in VLAN 1.
- Unused ports moved to a parking VLAN and shut.
- Where the platform supports it, tag the native VLAN too (`vlan dot1q tag native`); Packet Tracer support for that is UNVERIFIED and likely missing on the 2960 image.

Practise the whole SW1 configuration in the simulator, then build both switches in Packet Tracer.

console: SW1 (SW1 VLANs and trunk)

#### Missions  0/9

Simplified IOS simulator in your browser. It teaches the commands; Packet Tracer and real gear have many more.

## Flashcards: do you remember?

Tap a card to flip it. Try to answer in your head first; recalling is what makes it stick.

## Quick quiz

Instant feedback on every answer. Score 70% or more to pass this lesson's quiz.

### Q1 Two new 2960s with default settings are cabled together. What forms?

### Q2 What does the native VLAN carry?

### Q3 Which pair of commands hardens a user port?

### Q4 Double tagging works only when the attacker is in which VLAN?

### Q5 PCs in VLAN 10 on SW1 and SW2 cannot talk. The trunk is up. First thing to check?

### Q6 Why move unused ports to a parking VLAN and shut them?

**0 / 6**

## Hands-on lab

Cisco Packet Tracer lab  40 minutes  simulated network

### Packet Tracer lab 3.4: two switch VLANs with a hardened trunk

**You need:** Cisco Packet Tracer (free with a Cisco Networking Academy account; version 9.0.1 was the current download on the NetAcad Resource Hub when this lesson was written). Devices: 2 x 2960-24TT, 4 x PC-PT, and optionally 1 x IP Phone (7960).

**Simulator lab, zero risk.** This lab runs inside Cisco Packet Tracer, so it touches no real network. Packet Tracer is free with a Cisco Networking Academy account (netacad.com). It simulates a subset of Cisco IOS, so where support for a feature is uncertain we say so instead of promising it works.

#### Topology and addressing

Staff, phone and guest ports on SW1, staff and guest ports on SW2, and an 802.1Q trunk between their Gi0/1 ports.

| Device | Interface | IPv4 address / prefix | Default gateway or note |
| --- | --- | --- | --- |
| PC-Staff1 | Fa0 | 192.168.10.11/24 | VLAN 10, no gateway yet |
| PC-Staff2 | Fa0 | 192.168.10.12/24 | VLAN 10 |
| PC-Guest1 | Fa0 | 192.168.20.11/24 | VLAN 20 |
| PC-Guest2 | Fa0 | 192.168.20.12/24 | VLAN 20 |

1. Create the VLANs on both switches`SW1(config)#  vlan 10   SW1(config-vlan)#  name STAFF   SW1(config-vlan)#  vlan 20   SW1(config-vlan)#  name GUEST   SW1(config-vlan)#  vlan 30   SW1(config-vlan)#  name VOICE   SW1(config-vlan)#  vlan 99   SW1(config-vlan)#  name NATIVE   SW1(config-vlan)#  vlan 999   SW1(config-vlan)#  name PARKING`  Done
2. Access, voice and parking ports`SW1(config)#  interface range Fa0/1 - 10   SW1(config-if-range)#  switchport mode access   SW1(config-if-range)#  switchport access vlan 10   SW1(config-if-range)#  switchport nonegotiate   SW1(config-if-range)#  interface Fa0/3   SW1(config-if)#  switchport voice vlan 30   SW1(config-if)#  interface range Fa0/11 - 20   SW1(config-if-range)#  switchport mode access   SW1(config-if-range)#  switchport access vlan 20   SW1(config-if-range)#  switchport nonegotiate   SW1(config-if-range)#  interface range Fa0/21 - 24   SW1(config-if-range)#  switchport mode access   SW1(config-if-range)#  switchport access vlan 999   SW1(config-if-range)#  shutdown`  Done
3. See what DTP did by default`SW1#  show interfaces Gi0/1 switchport`Read Administrative Mode and Operational Mode before you change anything.  Done
4. Harden the trunk (both switches)`SW1(config)#  interface Gi0/1   SW1(config-if)#  switchport mode trunk   SW1(config-if)#  switchport trunk native vlan 99   SW1(config-if)#  switchport trunk allowed vlan 10,20,30,99   SW1(config-if)#  switchport nonegotiate`  Done
5. TestPC-Staff1 pings PC-Staff2: it works. PC-Staff1 pings PC-Guest2: it fails, because they are in different VLANs and subnets and there is no router yet (lesson 3.6).  Done
6. Break it on purposeOn SW2 only, set `switchport trunk native vlan 1`. Watch the console for the native VLAN mismatch message, then set it back to 99.  Done
7. Verify`SW1#  show vlan brief   SW1#  show interfaces trunk   SW1#  show interfaces Gi0/1 switchport   SW1#  show interfaces Fa0/3 switchport`  Done

**You are done when:** show interfaces trunk shows Gi0/1 in mode on, 802.1q, native VLAN 99 and allowed 10,20,30,99; staff PCs reach each other across the trunk; guests cannot reach staff.

#### Packet Tracer limits and notes

- Packet Tracer does not let you craft double tagged frames or DTP attacks, so the hopping attacks stay theory here. That is fine for a defence first course.
- `vlan dot1q tag native` (tagging the native VLAN) is UNVERIFIED in Packet Tracer and likely not supported on the 2960 image.
- The exact text of the CDP native VLAN mismatch message in Packet Tracer is UNVERIFIED; on real IOS it reads like `%CDP-4-NATIVE_VLAN_MISMATCH: Native VLAN mismatch discovered on ...`.
- Packet Tracer simulates a subset of IOS. If a command here is rejected in your version, note it, skip that step and carry on; the concept still applies to real Cisco gear.

[Download the lab checklist (.txt)](https://www.cyberwithmadhav.com/assets/learn/learn-ccna-vlans-trunks-lab-checklist.txt)  Print it or keep it open beside Packet Tracer.

## Key takeaways

- A VLAN is a broadcast domain, usually one subnet.
- Access ports are untagged; trunks tag with 802.1Q except the native VLAN.
- auto plus auto is an access link; hard code ports and use nonegotiate.
- Native VLAN unused, users out of VLAN 1, trunks carry only what they need.
- Park and shut unused ports.

Finished the sections, quiz and lab? Mark the lesson complete. Progress is saved only in this browser.

[Previous 3.3 Switching Fundamentals and Secure Device Access](https://www.cyberwithmadhav.com/learn-ccna-switching-secure-access.html)[Next 3.5 Redundant Switch Links: STP, Rapid PVST+, PortFast, BPDU Guard, EtherChannel](https://www.cyberwithmadhav.com/learn-ccna-stp-etherchannel.html)
