DEV Community

zNetLaB
zNetLaB

Posted on Originally published at Medium

Same VLAN, no ping: a VLAN and trunk troubleshooting checklist

Few things confuse new network engineers more than this: two PCs with addresses in the same subnet, cables plugged in, link lights green, and no ping. Nothing is "down". Layer 1 looks fine and the IP addressing looks fine, so the fault is almost always at layer 2, in how the switch ports are placed into VLANs and how those VLANs are carried between switches.

This checklist goes from the port the PC is plugged into, across the trunk, to the far side. Each step names the command that proves or rules out one cause. It uses Cisco IOS commands, but the same ideas apply on any vendor.

Before you start: confirm it really is a layer 2 problem

Check three things on both PCs first, because they take seconds:

  • The IP address and mask put both PCs in the same subnet (for example 192.168.10.11/24 and 192.168.10.12/24).
  • No duplicate address. If two devices share an IP, pings succeed and fail at random.
  • The PC firewall allows ICMP. Some desktop operating systems block inbound ping by default.

If those are right and the PCs still cannot reach each other, look at the switches.

Step 1: Is each PC's port in the VLAN you think it is?

SW1# show vlan brief

VLAN Name                             Status    Ports
---- -------------------------------- --------- -------------------------------
1    default                          active    Gi0/3, Gi0/4
10   SALES                            active    Gi0/1
20   ENGINEERING                      active    Gi0/2
Enter fullscreen mode Exit fullscreen mode

Find each PC's port in the Ports column. In the output above, a PC on Gi0/2 sits in VLAN 20, not VLAN 10. That one wrong switchport access vlan line is the most common cause of this whole problem.

Two details catch people out:

  • Trunk ports do not appear in show vlan brief. If a port is missing from the list, it is probably a trunk (or it has been shut down).
  • A port with no configuration is in VLAN 1. A new switch puts every port in the default VLAN, so a forgotten port looks like it "works" until it meets a port that was configured properly.

Fix by placing the port in the right VLAN:

SW1(config)# interface gi0/2
SW1(config-if)# switchport mode access
SW1(config-if)# switchport access vlan 10
Enter fullscreen mode Exit fullscreen mode

Step 2: Does the VLAN exist on this switch?

If you assign a port to a VLAN that has not been created, newer IOS versions create it for you with a message. Older versions and some platforms leave the port in an inactive VLAN, and the port forwards nothing. Check the port directly:

SW1# show interfaces gi0/1 switchport
Name: Gi0/1
Switchport: Enabled
Administrative Mode: static access
Operational Mode: static access
Access Mode VLAN: 30 (Inactive)
Enter fullscreen mode Exit fullscreen mode

(Inactive) means the VLAN does not exist in this switch's VLAN database. Create it with vlan 30 in global configuration and the port starts forwarding.

The same rule applies to the far switch. A VLAN must exist on every switch the traffic passes through, including switches in the middle that have no PCs in that VLAN. A transit switch without VLAN 10 will drop VLAN 10 frames arriving on its trunk.

Step 3: Is the link between the switches actually a trunk?

SW1# show interfaces trunk

Port        Mode             Encapsulation  Status        Native vlan
Gi0/24      on               802.1q         trunking      1

Port        Vlans allowed on trunk
Gi0/24      1-4094

Port        Vlans allowed and active in management domain
Gi0/24      1,10,20

Port        Vlans in spanning tree forwarding state and not pruned
Gi0/24      1,10,20
Enter fullscreen mode Exit fullscreen mode

If the uplink is not listed at all, it is not trunking. The usual reasons:

  • One side is configured as an access port. The link comes up, but it carries only one VLAN.
  • Both sides are set to dynamic auto. Each side waits for the other to ask for a trunk, so neither does, and the link becomes an access link in VLAN 1. This is a classic exam question and a real-world surprise on some switch models whose default is dynamic auto.
  • One side has switchport nonegotiate and the other side relies on DTP negotiation.

The clear fix is to set both ends explicitly:

SW1(config)# interface gi0/24
SW1(config-if)# switchport trunk encapsulation dot1q   ! only on switches that also support ISL
SW1(config-if)# switchport mode trunk
Enter fullscreen mode Exit fullscreen mode

Do the same on SW2. Explicit configuration on both sides removes any dependence on negotiation.

Step 4: Is the VLAN allowed on the trunk?

This is the fault that hides best, because the trunk shows "trunking" and everything looks healthy. Read the second and third blocks of show interfaces trunk:

Port        Vlans allowed on trunk
Gi0/24      1,20

Port        Vlans allowed and active in management domain
Gi0/24      1,20
Enter fullscreen mode Exit fullscreen mode

VLAN 10 is not on the list, so VLAN 10 frames are dropped at this trunk even though the link is up.

The usual cause is a single missing word. These two commands look almost identical but do very different things:

switchport trunk allowed vlan 20        ! REPLACES the list: now only VLAN 20
switchport trunk allowed vlan add 20    ! ADDS VLAN 20 to the existing list
Enter fullscreen mode Exit fullscreen mode

Someone wanted to add VLAN 20 and typed the first form, which removed every other VLAN from the trunk. Fix it with add:

SW1(config-if)# switchport trunk allowed vlan add 10
Enter fullscreen mode Exit fullscreen mode

Check the allowed list on both ends of the trunk. Each side filters independently, so a VLAN missing on either side is enough to stop it.

The fourth block, "forwarding state and not pruned", can also hide a VLAN. If VTP pruning is on or spanning tree has blocked the VLAN on that port, it disappears there. That is a different investigation (spanning tree and VTP), but this block is where you notice it.

Step 5: Do the native VLANs match?

On an 802.1Q trunk, frames in the native VLAN travel untagged. If SW1 uses native VLAN 1 and SW2 uses native VLAN 99, untagged frames leave SW1 as VLAN 1 and arrive on SW2 as VLAN 99. Traffic leaks between the two VLANs and both appear broken.

Compare the Native vlan column on both switches. If CDP is running, the switch usually tells you directly in its log:

%CDP-4-NATIVE_VLAN_MISMATCH: Native VLAN mismatch discovered on GigabitEthernet0/24 (1), with SW2 GigabitEthernet0/24 (99).
Enter fullscreen mode Exit fullscreen mode

Set the same native VLAN on both ends:

SW1(config-if)# switchport trunk native vlan 99
Enter fullscreen mode Exit fullscreen mode

Many organisations use an unused VLAN as the native VLAN and keep user traffic off it, which also closes off a class of VLAN-hopping attacks.

Step 6: Is the MAC address learned where you expect?

When the configuration looks right but traffic still fails, follow the frames:

SW1# show mac address-table vlan 10

          Mac Address Table
-------------------------------------------

Vlan    Mac Address       Type        Ports
----    -----------       --------    -----
  10    0050.7966.6801    DYNAMIC     Gi0/1
  10    0050.7966.6802    DYNAMIC     Gi0/24
Enter fullscreen mode Exit fullscreen mode

Read it like a map. PC1's MAC is learned on its access port and PC2's MAC is learned through the trunk, which means frames are crossing between the switches in VLAN 10. If PC2's MAC is missing, or appears in a different VLAN, you know which side to look at. Start a ping from each PC so the switches have something to learn.

Step 7: Check port security and err-disabled ports

A port that was shut down by a protection feature looks like a cabling fault:

SW1# show interfaces status err-disabled
Enter fullscreen mode Exit fullscreen mode

Port security (too many MAC addresses, or a sticky MAC from a previous device), BPDU guard (someone plugged a switch into an access port) and storm control can all err-disable a port. Fix the cause first, then bounce the port with shutdown and no shutdown.

The checklist on one page

  1. Same subnet, no duplicate IP, firewall allows ping.
  2. show vlan brief: each PC's port is in the intended VLAN.
  3. show interfaces <port> switchport: the VLAN exists (not "Inactive") on every switch on the path.
  4. show interfaces trunk: the uplink is trunking; set switchport mode trunk on both ends.
  5. Allowed list on both ends includes the VLAN; use allowed vlan add, never the bare form, when adding.
  6. Native VLAN is the same on both ends.
  7. show mac address-table vlan <id>: MACs are learned on the expected ports.
  8. show interfaces status err-disabled: no port has been shut down by a protection feature.

Practise it before you need it

These faults are easy to read about and surprisingly hard to spot under pressure, because every individual output looks "fine". The quickest way to build the instinct is to break a working network on purpose and fix it using only show commands.

Build two switches with a trunk and two PCs per switch in VLANs 10 and 20. Then introduce one fault at a time: a wrong access VLAN, a missing VLAN on one switch, dynamic auto on both ends, a replaced allowed list, a native VLAN mismatch. Time yourself and write down which command found each fault.

If you want ready-made broken labs that check your fix, zNetLaB has two free browser labs for exactly these faults: two PCs on one switch that cannot talk and the trunk is up but one VLAN never arrives. Packet Tracer, GNS3 and EVE-NG work just as well if you build the topology yourself.

Disclosure: written by the zNetLaB team.

Top comments (0)