One link, many VLANs
When a VLAN spans two switches, the link between them must carry frames from every VLAN. Instead of one cable per VLAN, a trunk carries them all, adding a 4-byte 802.1Q tag to each frame to say which VLAN it belongs to.
| 802.1Q tag field | Bits | Meaning |
|---|---|---|
| TPID | 16 | 0x8100: "this frame is tagged" |
| PCP (priority) | 3 | Class of service, for QoS (voice gets 5) |
| DEI | 1 | Drop eligible |
| VID | 12 | The VLAN number (0-4095, so 1-4094 usable) |
The native VLAN
Frames in the native VLAN (VLAN 1 by default) cross the trunk untagged. Both ends must agree on it, or untagged frames land in the wrong VLAN on the other side. CDP notices and warns. Best practice: use an unused VLAN as the native VLAN on every trunk.
Configuring a trunk
In NetLab
▶ SW1 SW1>enable SW1#configure terminal Enter configuration commands, one per line. End with CNTL/Z. SW1(config)#interface g0/1 SW1(config-if)#switchport mode trunk SW1(config-if)#switchport trunk native vlan 99 *Mar 1 00:00:05.000: %CDP-4-NATIVE_VLAN_MISMATCH: Native VLAN mismatch discovered on GigabitEthernet0/1 (99), with SW2 GigabitEthernet0/1 (1). SW1(config-if)#switchport trunk allowed vlan 10,20,99 SW1(config-if)#end *Mar 1 00:00:07.000: %SYS-5-CONFIG_I: Configured from console by console SW1#show interfaces trunk Port Mode Encapsulation Status Native vlan Gi0/1 on 802.1q trunking 99 Port Vlans allowed on trunk Gi0/1 10,20,99 Port Vlans allowed and active in management domain Gi0/1 10,20 Port Vlans in spanning tree forwarding state and not pruned Gi0/1 10,20 ▶ SW2 *Mar 1 00:00:05.000: %CDP-4-NATIVE_VLAN_MISMATCH: Native VLAN mismatch discovered on GigabitEthernet0/1 (1), with SW1 GigabitEthernet0/1 (99). SW2>enable SW2#show interfaces trunk Port Mode Encapsulation Status Native vlan Gi0/1 auto 802.1q trunking 1 Port Vlans allowed on trunk Gi0/1 1-4094 Port Vlans allowed and active in management domain Gi0/1 1,10,20 Port Vlans in spanning tree forwarding state and not pruned Gi0/1 1,10,20
SW1 complains at once: its native VLAN is 99, SW2's is still 1. Fix SW2 to match, and check the result:
In NetLab
▶ SW2 SW2>enable SW2#configure terminal Enter configuration commands, one per line. End with CNTL/Z. SW2(config)#vlan 99 SW2(config-vlan)#name NATIVE SW2(config-vlan)#interface g0/1 SW2(config-if)#switchport trunk native vlan 99 SW2(config-if)#switchport trunk allowed vlan 10,20,99 SW2(config-if)#end *Mar 1 00:00:08.000: %SYS-5-CONFIG_I: Configured from console by console SW2#show interfaces g0/1 switchport | include Mode|Native|Trunking VLANs Administrative Mode: trunk Operational Mode: trunk Access Mode VLAN: 1 (default) Trunking Native Mode VLAN: 99 (NATIVE) Administrative Native VLAN tagging: enabled Trunking VLANs Enabled: 10,20,99 Capture Mode Disabled ▶ PC1 NetLab Windows-style command prompt. Type help to see the commands. C:\Users\student>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=64 Reply from 192.168.10.12: bytes=32 time<1ms TTL=64 Reply from 192.168.10.12: bytes=32 time<1ms TTL=64 Reply from 192.168.10.12: bytes=32 time<1ms TTL=64 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
Reading show interfaces trunk
| Section | Shows |
|---|---|
| Mode / Status / Native vlan | on (trunk) or auto/desirable (DTP); trunking or not; the native VLAN |
| Vlans allowed on trunk | The allowed list you set (1-4094 by default) |
| Vlans allowed and active | Allowed and existing on this switch |
| Vlans in spanning tree forwarding state | Actually being forwarded (module 11) |
Common mistake:
switchport trunk allowed vlan 30replaces the whole list with just 30. To change the list, useswitchport trunk allowed vlan add 30orremove 30.