When a Cisco trunk is up and allows both VLANs but a Linux host cannot ping its gateway, compare the host's VLAN tag with the gateway's VLAN. The host's ARP request carried VLAN 20, the switch learned its MAC in VLAN 20 and the gateway SVI was in VLAN 10, so all four pings returned Destination Host Unreachable. Moving the host back to VLAN 10 restored them.
Part of the VLANs & Layer 2 Switching. Scope: one Linux 802.1Q subinterface connected to one Cisco IOL Layer 2 switch; no throughput, multiple switches, physical trunks or NIC offload testing.
The Cisco trunk is up. VLANs 10 and 20 are allowed. Yet the Linux host cannot ping its gateway. The clue is in the host's ARP request: it carries a VLAN 20 tag, while the gateway is on VLAN 10.
We'll start with a working VLAN 10 connection, move the Linux host to VLAN 20, and track down the failed ping using a packet capture and the Cisco MAC table. Then we'll move the host back and check that connectivity returns. The whole lab runs on one Linux VM with a locally available Cisco IOL Layer 2 image; you don't need a separate mini PC.
The lab setup
Containerlab's host link connects Cisco Ethernet0/1 to a temporary Linux interface named plvlan0. The VM adds an 802.1Q VLAN subinterface to that link. On SW1, Ethernet0/1 allows VLANs 10 and 20 over the trunk. Only Vlan10 has an IP address. This switch virtual interface (SVI) is the gateway for VLAN 10. The 192.0.2.0/24 range is reserved for documentation.
- Linux VM: Ubuntu 26.04.1 LTS, kernel 7.0.0-38-generic, iproute2 6.19.0, tcpdump 4.99.6.
- Lab platform: Containerlab 0.79.0 and Docker 29.8.2.
- Cisco node:
vrnetlab/cisco_iol:L2-17.18.02;show versionreported IOS XE 17.18.2. - Address plan: Linux
192.0.2.10/24; switchVlan10at192.0.2.1/24.
The packet captures and ping results below came from this virtual lab. You'll need your own locally available Cisco image; it isn't included with the lab files.
Build the topology
Create a new lab directory and save the following as linux-cisco-vlan.clab.yml. The host:plvlan0 endpoint creates a Linux-side link without using the VM's management interface. Use the image tag installed on your VM, or substitute another IOL-L2 tag you've tested.
name: linux-cisco-vlan
topology:
nodes:
sw1:
kind: cisco_iol
type: L2
image: vrnetlab/cisco_iol:L2-17.18.02
startup-config: sw1.partial.cfg
links:
- endpoints: ["sw1:e0/1", "host:plvlan0"]Save this as sw1.partial.cfg in the same directory. On the IOL-L2 image used here, set the trunk encapsulation to dot1q before switchport mode trunk. IOS rejected trunk mode when encapsulation was still set to Auto. VTP transparent mode keeps the VLAN definitions in the startup configuration.
hostname SW1
!
vtp mode transparent
!
vlan 10
name LAB-CLIENT
vlan 20
name LAB-MISMATCH
!
interface Ethernet0/1
description TO-LINUX-HOST-PLVLAN0
switchport trunk encapsulation dot1q
switchport mode trunk
switchport trunk allowed vlan 10,20
no shutdown
!
interface Vlan10
description LAB-CLIENT-GATEWAY
ip address 192.0.2.1 255.255.255.0
no shutdownRun these commands from the lab directory on the Linux VM. They check for the Cisco image, validate and deploy the topology, and bring up the host's VLAN 10 subinterface:
docker image inspect vrnetlab/cisco_iol:L2-17.18.02 --format "{{.RepoTags}}"
containerlab validate -t linux-cisco-vlan.clab.yml
containerlab deploy -t linux-cisco-vlan.clab.yml
sudo ip link add link plvlan0 name plvlan0.10 type vlan id 10
sudo ip addr add 192.0.2.10/24 dev plvlan0.10
sudo ip link set plvlan0.10 upGive the IOL node time to boot and spanning tree time to start forwarding VLAN 10. An early ping may fail while the switch is still starting. Begin the checks below once the trunk and SVI are up. Run this lab separately from your other Containerlab topologies.
Open a second terminal on the Linux VM and attach to SW1's console for the Cisco checks:
docker attach clab-linux-cisco-vlan-sw1Press Enter to get the switch prompt, then run show interfaces trunk and show ip interface brief. When you're done with the console, detach with Ctrl+P followed by Ctrl+Q.
Check that VLAN 10 works
On Linux, check that the subinterface reports vlan protocol 802.1Q id 10. On SW1, show interfaces trunk should list Ethernet0/1 as 802.1q trunking, with VLANs 10 and 20 allowed and forwarding. Vlan10 should be up/up at 192.0.2.1. In the working baseline, all five pings received replies:
ip -d link show plvlan0.10
# vlan protocol 802.1Q id 10
ping -I plvlan0.10 -c 5 -W 2 192.0.2.1
# 5 packets transmitted, 5 received, 0% packet lossBefore repeating the ping, open another terminal on the Linux VM and start the capture:
sudo tcpdump -eni plvlan0 -nnCapture on plvlan0, the parent interface beneath the VLAN subinterface, so you can see the 802.1Q tag. Leave tcpdump running while you send the ping, then stop it with Ctrl+C. Use this same capture command for the VLAN 20 test.
The capture on plvlan0 shows both the request and reply tagged as VLAN 10. Here are two lines from that capture:
06:54:41.941186 ... ethertype 802.1Q (0x8100), vlan 10, ethertype IPv4, 192.0.2.10 > 192.0.2.1: ICMP echo request
06:54:41.942399 ... ethertype 802.1Q (0x8100), vlan 10, ethertype IPv4, 192.0.2.1 > 192.0.2.10: ICMP echo replyMove the host to VLAN 20
Move the host's IP address from the VLAN 10 subinterface to a new VLAN 20 subinterface. Leave the switch alone: the trunk still allows both VLANs, and the gateway stays on VLAN 10.
sudo ip addr del 192.0.2.10/24 dev plvlan0.10
sudo ip link add link plvlan0 name plvlan0.20 type vlan id 20
sudo ip addr add 192.0.2.10/24 dev plvlan0.20
sudo ip link set plvlan0.20 up
ip -d link show plvlan0.20
ping -I plvlan0.20 -c 4 -W 1 192.0.2.1The host now reports vlan protocol 802.1Q id 20. All four pings fail with Destination Host Unreachable. Look at the ARP request and the switch's MAC table to see where the traffic went:
06:55:11.655088 ... ethertype 802.1Q (0x8100), vlan 20, ethertype ARP, Request who-has 192.0.2.1 tell 192.0.2.10
SW1# show mac address-table dynamic vlan 20
Vlan Mac Address Type Ports
20 aac1.abb0.0d5d DYNAMIC Et0/1ARP finds the MAC address for an IP address on the local network. Here, the host asks for 192.0.2.1 on VLAN 20. SW1 learns the host's MAC address on Ethernet0/1 in VLAN 20, so the frames are reaching the switch. The problem is the destination: 192.0.2.1 belongs to Vlan10, and there is no Vlan20 gateway to answer. Without an ARP reply, the host cannot send an ICMP echo request. That's why the failed-ping capture shows ARP but no echo request.
Move back to VLAN 10 and test again
Put the address back on the VLAN 10 subinterface and remove the temporary VLAN 20 subinterface:
sudo ip addr del 192.0.2.10/24 dev plvlan0.20
sudo ip addr add 192.0.2.10/24 dev plvlan0.10
sudo ip link del plvlan0.20
ping -I plvlan0.10 -c 5 -W 2 192.0.2.1Back on VLAN 10, all five pings receive replies: 0% packet loss. A clean redeployment using the saved topology and startup configuration produced the same result. After that boot, SW1 showed VLANs 10 and 20 active, Ethernet0/1 trunking, and Vlan10 up/up. The saved files reproduced the working setup.
VLAN and Trunk Troubleshooting Field Guide
Included with PingLabz Pro · 10 pages · US Letter PDF
Follow a frame from the host to its gateway. Cisco and Linux inspection commands, a worked tag mismatch, practice cases, and a change record.
Already a member? Sign in.
Use the same checks on your own trunk
- Start at Linux:
ip -d link showconfirms the VLAN ID;ip addrandip route getconfirm address and egress interface. - Read the Cisco trunk:
show interfaces trunkdistinguishes operational trunking, allowed VLANs, active VLANs, and forwarding VLANs. - Check the destination VLAN:
show vlan briefandshow ip interface brieflocate the gateway interface;show mac address-table dynamic vlan 20can prove frames arrived in the unexpected VLAN. - Capture at the parent link:
sudo tcpdump -eni plvlan0 -nnshows the 802.1Q tag in this virtual link. Compare captures with host configuration and switch state; host-side offloads can affect what a capture displays.
For wider Cisco-only trunk faults, see Troubleshooting VLAN and Trunk Problems on Cisco Switches. For capture basics, use tcpdump for Network Engineers.
FAQ
Why does ping fail when the trunk is up? The trunk only carries the VLANs. The host and the gateway were still in different VLANs.
How do I see the VLAN tag on Linux? ip -d link shows the 802.1Q ID of the subinterface, and a capture on the parent shows the tag on the ARP request.
How does the MAC table help? It shows the VLAN where the switch learned the host. Here it was VLAN 20, not the gateway VLAN.
Why Destination Host Unreachable instead of a timeout? The host could not resolve the gateway with ARP in its own VLAN, so it reported the failure locally.
What breaks
- Destination Host Unreachable. All four pings failed with the host on VLAN 20.
- ARP tagged VLAN 20. The request for 192.0.2.1 went out in the wrong VLAN.
- MAC learned in VLAN 20. Frames reached the switch, in the wrong VLAN.
- Trunk status misleads. The trunk was up and allowed both VLANs throughout.
Key takeaways
- A trunk being up does not put the host in the right VLAN.
- Compare the host tag, the learned VLAN and the gateway SVI.
- Capture the ARP request to see the tag.
- Retest the same ping after moving the host back.
Next: Linux Namespaces, veth and a Bridge: One Missing Route Broke the Routed Path, Not the LAN · Series hub: Linux Networking Commands: The Complete Guide
Related: VLANs & Layer 2 Switching · Cisco ACL Packet Drop: 4 Echo Requests In, 0 Out, and a Deny Counter That Rose by 4