Once you have more than one switch, VLANs only work if the links between switches can carry traffic for many VLANs at once. That is the job ...
Once you have more than one switch, VLANs only work if the links between switches can carry traffic for many VLANs at once. That is the job of an 802.1Q trunk. In this Packet Tracer 8.x lab you will build a trunk between two Cisco 2960 switches, set a dedicated native VLAN, restrict the allowed VLANs, and then deliberately break it in the three ways I see most often: native VLAN mismatch, wrong allowed VLAN list and DTP negotiation problems.
Prefer video? Watch more hands-on labs on the Technical Hakim YouTube channel.
What 802.1Q actually does
An access port belongs to one VLAN and sends normal Ethernet frames. A trunk port carries many VLANs, so the switch needs a way to tell the other side which VLAN each frame belongs to. IEEE 802.1Q solves this by inserting a 4-byte tag between the source MAC address and the EtherType field. The tag contains a 12-bit VLAN ID, which is why VLAN numbers go up to 4094.
There is one exception: the native VLAN. Frames in the native VLAN are sent across the trunk untagged, and any untagged frame received on a trunk is placed into the native VLAN. By default the native VLAN is VLAN 1. Both ends of a trunk must agree on the native VLAN, otherwise untagged traffic leaks from one VLAN into another.
Lab topology
Devices: two Cisco 2960-24TT switches and four PCs. Connect SW1 Gi0/1 to SW2 Gi0/1 with a copper cross-over cable.
| Device | Port | VLAN | IP address / mask |
|---|---|---|---|
| PC1 | SW1 Fa0/1 | 10 (STAFF) | 192.168.10.11 /24 |
| PC2 | SW1 Fa0/2 | 20 (GUEST) | 192.168.20.11 /24 |
| PC3 | SW2 Fa0/1 | 10 (STAFF) | 192.168.10.12 /24 |
| PC4 | SW2 Fa0/2 | 20 (GUEST) | 192.168.20.12 /24 |
| SW1 – SW2 | Gi0/1 – Gi0/1 | Trunk, native 99 | N/A |
There is no router in this lab, so the goal is that PC1 can ping PC3 (VLAN 10) and PC2 can ping PC4 (VLAN 20) across the trunk. Pings between VLANs will fail, which is expected.
Step 1: Create VLANs on both switches
Run the same VLAN commands on SW1 and SW2. A VLAN must exist on both switches for its traffic to cross the trunk.
SW1(config)# vlan 10
SW1(config-vlan)# name STAFF
SW1(config-vlan)# vlan 20
SW1(config-vlan)# name GUEST
SW1(config-vlan)# vlan 99
SW1(config-vlan)# name NATIVE
SW1(config-vlan)# exit
SW1(config)# interface fastEthernet 0/1
SW1(config-if)# switchport mode access
SW1(config-if)# switchport access vlan 10
SW1(config-if)# interface fastEthernet 0/2
SW1(config-if)# switchport mode access
SW1(config-if)# switchport access vlan 20
SW1(config-if)# exit
VLAN 99 is a dedicated native VLAN with no hosts in it. Using an unused VLAN as the native VLAN, instead of VLAN 1, is a common security recommendation because it limits VLAN-hopping tricks that rely on untagged frames.
Step 2: Configure the trunk
Apply this on SW1 Gi0/1 and on SW2 Gi0/1:
SW1(config)# interface gigabitEthernet 0/1
SW1(config-if)# switchport mode trunk
SW1(config-if)# switchport trunk native vlan 99
SW1(config-if)# switchport trunk allowed vlan 10,20,99
SW1(config-if)# switchport nonegotiate
SW1(config-if)# end
switchport mode trunkmakes the port a permanent trunk regardless of what the other side does.switchport trunk native vlan 99sends VLAN 99 untagged and places received untagged frames into VLAN 99.switchport trunk allowed vlan 10,20,99permits only these VLANs on the trunk. The default is all VLANs (1–4094).switchport nonegotiateturns off DTP frames on this port. Only use it when the other side is also hard-coded as a trunk.
On a 2960 there is no switchport trunk encapsulation command because it only supports 802.1Q. On a 3560 multilayer switch, which also supports the older Cisco ISL encapsulation, enter switchport trunk encapsulation dot1q first. If you skip it, IOS rejects the trunk command with: Command rejected: An interface whose trunk encapsulation is "Auto" can not be configured to "trunk" mode.
Step 3: Verify the trunk
SW1# show interfaces trunk
Port Mode Encapsulation Status Native vlan
Gig0/1 on 802.1q trunking 99
Port Vlans allowed on trunk
Gig0/1 10,20,99
Port Vlans allowed and active in management domain
Gig0/1 10,20,99
Port Vlans in spanning tree forwarding state and not pruned
Gig0/1 10,20,99
Read the four sections from top to bottom: is it trunking, which VLANs are allowed, which of those actually exist on this switch, and which are forwarding in spanning tree. A VLAN that is allowed but missing from the second list does not exist locally.
SW1# show interfaces gigabitEthernet 0/1 switchport
Name: Gig0/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: 99 (NATIVE)
Voice VLAN: none
...
Trunking VLANs Enabled: 10,20,99
Pruning VLANs Enabled: 2-1001
"Administrative Mode" is what you configured, "Operational Mode" is what the port is actually doing. "Negotiation of Trunking: Off" confirms switchport nonegotiate is active. (Output trimmed.)
Finally, ping PC3 (192.168.10.12) from PC1. Replies prove VLAN 10 crosses the trunk with its tag intact.
C:\>ping 192.168.10.12
Pinging 192.168.10.12 with 32 bytes of data:
Reply from 192.168.10.12: bytes=32 time<1ms TTL=128
Reply from 192.168.10.12: bytes=32 time<1ms TTL=128
Reply from 192.168.10.12: bytes=32 time<1ms TTL=128
Reply from 192.168.10.12: bytes=32 time<1ms TTL=128
Ping statistics for 192.168.10.12:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 0ms, Average = 0ms
The TTL stays at 128 because no router is involved; switches do not change the IP header.
DTP modes and what they negotiate
Dynamic Trunking Protocol (DTP) is Cisco-proprietary and lets two switch ports negotiate whether to become a trunk. On a 2960 in Packet Tracer, the default port mode is dynamic auto.
| SW1 mode \ SW2 mode | dynamic auto | dynamic desirable | trunk | access |
|---|---|---|---|---|
| dynamic auto | Access | Trunk | Trunk | Access |
| dynamic desirable | Trunk | Trunk | Trunk | Access |
| trunk | Trunk | Trunk | Trunk | Mismatch (avoid) |
| access | Access | Access | Mismatch (avoid) | Access |
"Auto" waits to be asked, "desirable" actively asks, and "trunk" is always a trunk while still sending DTP frames unless you add switchport nonegotiate. If you use nonegotiate, the other side must be switchport mode trunk too, because a dynamic port will never receive the DTP frames it is waiting for.
Common errors and how to fix them
Error 1: Both sides left at default (dynamic auto)
If you connect two new 2960 switches and only configure access ports, the link between them stays an access link in VLAN 1. PC1 cannot reach PC3 even though both are in VLAN 10.
SW1# show interfaces gigabitEthernet 0/1 switchport
Name: Gig0/1
Switchport: Enabled
Administrative Mode: dynamic auto
Operational Mode: static access
...
show interfaces trunk returns nothing at all. Fix: configure switchport mode trunk on at least one side (I recommend both, plus nonegotiate).
Error 2: Native VLAN mismatch
Suppose you set switchport trunk native vlan 99 on SW1 but forget it on SW2, which stays at VLAN 1. CDP notices and logs a message on both switches every minute or so:
%CDP-4-NATIVE_VLAN_MISMATCH: Native VLAN mismatch discovered on GigabitEthernet0/1 (99), with SW2 GigabitEthernet0/1 (1).
The trunk still shows "trunking", and tagged VLANs 10 and 20 may keep working, which is why this error is easy to ignore. But untagged frames sent from VLAN 99 on SW1 arrive in VLAN 1 on SW2, merging two broadcast domains. On real switches, spanning tree may also put the port into a blocking (inconsistent) state for the affected VLANs. Fix: set the same native VLAN on both ends and confirm the "Native vlan" column in show interfaces trunk matches.
Error 3: Allowed VLAN list overwritten
Later you add VLAN 30 and type:
SW1(config-if)# switchport trunk allowed vlan 30
This replaces the list. Now only VLAN 30 is allowed and VLANs 10, 20 and 99 stop crossing the trunk. The correct commands are:
SW1(config-if)# switchport trunk allowed vlan add 30
SW1(config-if)# switchport trunk allowed vlan remove 30
You can also use switchport trunk allowed vlan all to return to the default or switchport trunk allowed vlan except 30 to allow everything except one VLAN.
Error 4: VLAN exists on only one switch
If VLAN 20 was created on SW1 but not on SW2, the trunk on SW2 shows "Vlans allowed and active in management domain: 10,99". PC2 and PC4 cannot ping. Fix: create the VLAN on SW2 (or use VTP if your design allows it).
Error 5: Trunk on one side, access on the other
If SW1 Gi0/1 is switchport mode trunk and SW2 Gi0/1 is switchport mode access, SW1 sends tagged frames that SW2 does not expect. Some traffic in the native VLAN may pass, everything else fails. Always configure both ends explicitly.
Summary
A reliable trunk between Cisco switches has the same configuration on both ends: switchport mode trunk, a matching unused native VLAN, an explicit allowed VLAN list, and optionally switchport nonegotiate. Verify with show interfaces trunk and show interfaces switchport. When something fails, check in this order: is it trunking, do the native VLANs match, is the VLAN allowed, and does the VLAN exist on both switches.
Related tutorials
- Inter-VLAN Routing with Router-on-a-Stick (Packet Tracer Lab)
- Basic Cisco Router Setup: Hostname, Passwords, Banner and SSH
- DHCP Server on a Cisco Router plus DHCP Relay (ip helper-address)
- Subnetting Made Simple: /24 to /30 with Worked Examples
Sources
- IEEE 802.1Q, Bridges and Bridged Networks (VLAN tagging standard)
- Cisco Catalyst 2960 Switch Software Configuration Guide, chapter "Configuring VLANs" (VLAN trunks and DTP)
- Cisco Catalyst 3560 Switch Software Configuration Guide, trunk encapsulation section
No comments