Sub topic 14
Verifying and Troubleshooting VLANs and Trunks
This chapter assumes you know how access ports, trunks, the native VLAN and router-on-a-stick work, and that you can use the Cisco IOS command line. The goal is a repeatable method for finding VLAN faults, not a list of memorized symptoms.
A Layered Method
Most VLAN faults fall into three places: the access port, the trunk, or the gateway. Work from the host outward and stop at the first layer that is wrong.
Verification Commands
Three commands cover most checks.
show vlan brief
show interfaces trunk
show interfaces GigabitEthernet0/24 switchportshow vlan brieflists each VLAN, its status and its access ports. A port missing from this list is either a trunk or in a VLAN that does not exist.show interfaces trunkhas four sections: ports that are trunking with their native VLAN, the allowed list, the VLANs allowed and active, and the VLANs in the spanning-tree forwarding state.show interfaces ... switchportshows the administrative mode (what you configured) and the operational mode (what the port is doing). A difference between them points to a negotiation problem.
Common Faults
| Symptom | Likely cause | How to confirm | Fix |
|---|---|---|---|
| Host has link but no connectivity, and its port is not in `show vlan brief` | The access VLAN was never created | `show interfaces ... switchport` shows the VLAN as inactive or absent | Create it with `vlan 10` |
| One VLAN works on one switch but not across the trunk | VLAN missing from the allowed list, or missing on the far switch | `show interfaces trunk` omits it from the allowed or active list | `switchport trunk allowed vlan add 10` and create it on both switches |
| Console messages about native VLAN mismatch, with traffic leaking between VLANs | Native VLAN differs at the two ends | CDP and spanning-tree messages name both VLAN IDs | Set the same native VLAN on both ends |
| Port is expected to trunk but operates as access | Mode or negotiation mismatch | Operational mode in `show interfaces ... switchport` | Set `switchport mode trunk` on both ends |
| Hosts reach their own VLAN but not others | Gateway fault | `show ip interface brief` on the router | Fix the subinterface |
Gateway Checks
For router-on-a-stick, confirm that each subinterface has the right VLAN number and an address in the host subnet.
show ip interface brief
show running-config interface GigabitEthernet0/0.10Look for these errors:
- The physical interface is shut down, which also takes down every subinterface.
encapsulation dot1Q 10names the wrong VLAN.- The host's default gateway does not match the subinterface address, or the subnet mask differs.
Checking Tags on the Wire
When the switch output looks right but traffic still fails, capture on the link. In Wireshark, the display filter vlan.id == 10 shows only frames tagged with VLAN 10. If frames arrive untagged where you expect tags, the far end is probably an access port. If tags appear on a port that should be an access port, the port is trunking.
The function below decodes the tag fields from raw frame bytes, which is useful when checking a capture by hand.
import struct
def parse_dot1q(frame: bytes):
"""Return the 802.1Q fields of an Ethernet frame, or None if it is untagged."""
tpid, tci = struct.unpack("!HH", frame[12:16])
if tpid != 0x8100:
return None
return {
"pcp": tci >> 13,
"dei": (tci >> 12) & 0x1,
"vid": tci & 0x0FFF,
}Exercises
Exercise
A new switch is connected over a trunk. Users in VLAN 20 on the new switch cannot reach the server in VLAN 20 on the old switch, but VLAN 10 works. show interfaces trunk on the old switch lists allowed VLANs 10,20. What are two things to check next?
Show answer
First, check the allowed VLAN list on the new switch's end of the trunk, since the list is set per port on each side and may lack VLAN 20. Second, check that VLAN 20 exists on the new switch with show vlan brief. If it does not exist, it will not appear in the "allowed and active" section, and no VLAN 20 traffic is forwarded.
Exercise
Hosts in VLAN 10 and VLAN 20 each reach their own gateway, but the router subinterface for VLAN 20 shows up/up and pings between VLANs fail only for VLAN 20 hosts. Which two configuration details on that subinterface would you inspect?
Show answer
Inspect the encapsulation dot1Q line, to confirm it uses VLAN 20, and the IP address and mask, to confirm they match the subnet and default gateway configured on the VLAN 20 hosts.