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
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 |
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 30If 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.
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 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 dot1qis not needed (and may be rejected). On 3560 and 3650 class switches you may need it beforeswitchport 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 trunkDTP: 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.
VLAN hopping and how to stop it
Practise the whole SW1 configuration in the simulator, then build both switches in Packet Tracer.
Missions 0/9
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.
Q1Two new 2960s with default settings are cabled together. What forms?
dynamic auto on both ends never starts negotiation.
Q2What does the native VLAN carry?
Frames in the native VLAN cross the trunk untagged.
Q3Which pair of commands hardens a user port?
Static access and no DTP stops switch spoofing.
Q4Double tagging works only when the attacker is in which VLAN?
The outer tag must match the native VLAN to be stripped.
Q5PCs in VLAN 10 on SW1 and SW2 cannot talk. The trunk is up. First thing to check?
A VLAN must exist and be allowed on the trunk.
Q6Why move unused ports to a parking VLAN and shut them?
Defence in depth for physical access.
Hands-on lab
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
| 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 |
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 PARKINGAccess, 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)#shutdownSee what DTP did by default
SW1#show interfaces Gi0/1 switchportRead Administrative Mode and Operational Mode before you change anything.
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 nonegotiateTest
PC-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).
Break it on purpose
On SW2 only, set
switchport trunk native vlan 1. Watch the console for the native VLAN mismatch message, then set it back to 99.Verify
SW1#show vlan brief SW1#show interfaces trunk SW1#show interfaces Gi0/1 switchport SW1#show interfaces Fa0/3 switchport
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) 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.