Lab fixes / VLANs and switching
Ping fails between VLANs
Packet Tracer · GNS3 · Cisco IOS · Last checked
ip routing.On this page
What you see
Every PC can ping other PCs in its own VLAN. As soon as you ping a PC in another VLAN you get Request timed out or Destination host unreachable. Everything in the topology looks green.
Why it happens
A switch keeps VLANs apart on purpose. A PC in VLAN 10 (192.168.10.0/24) sends anything outside its own subnet to its default gateway. That gateway has to be an interface that lives in VLAN 10 and can route to VLAN 20. If any link in that chain is missing, the packet just stops.
Check it in this order
Work from the PC outwards. It is faster than staring at the whole config.
- On the PC, run
ipconfig. Is the default gateway the router's address in the same VLAN (for example 192.168.10.1)? A gateway of 0.0.0.0 or an address from the other VLAN is the most common mistake in student labs. - From the PC, ping your own gateway. If that fails, the problem is between the PC and the router, not between the VLANs.
- On the switch, run
show vlan briefand check that the PC's port is in the right VLAN. - On the switch, run
show interfaces trunk. The port towards the router must be listed, and both VLANs must be in "allowed and active". - On the router, run
show ip interface brief. Every subinterface must beup/up. - On the router, run
show ip route. You should see aC(connected) line for each VLAN subnet.
Fix: router-on-a-stick
The router needs one subinterface per VLAN. The number after dot1Q must match the VLAN, the IP must be the gateway the PCs use, and the physical port must be up.
interface g0/0
no shutdown
interface g0/0.10
encapsulation dot1Q 10
ip address 192.168.10.1 255.255.255.0
interface g0/0.20
encapsulation dot1Q 20
ip address 192.168.20.1 255.255.255.0
The switch port that goes to the router must be a trunk:
interface g0/1
switchport mode trunk
If the physical port g0/0 is shut down, every subinterface on it is down too. no shutdown goes on g0/0, not on g0/0.10.
Fix: Layer 3 switch (SVIs)
On a multilayer switch (3560, 3650) you give each VLAN an SVI and turn routing on. Forgetting ip routing is the classic one: the SVIs come up, the PCs can ping their gateway, and nothing crosses between VLANs.
ip routing
interface vlan 10
ip address 192.168.10.1 255.255.255.0
no shutdown
interface vlan 20
ip address 192.168.20.1 255.255.255.0
no shutdown
An SVI only comes up when the VLAN exists on the switch and at least one port in that VLAN (or a trunk carrying it) is up.
Still not working?
- The subinterface uses VLAN 1 or the native VLAN: write
encapsulation dot1Q 1 native, or move the PCs to a different VLAN. - In GNS3 with real Windows or Linux PCs, the PC firewall may drop ping. Test with the firewall off for a moment.
- The very first ping often loses one packet while ARP runs. That is normal. Try again before you change anything.