Course contents

Chapter 4: VLANs and TrunksLesson 10 of 18

Packet Tracer lab: VLANs and a trunk

Build two switches and four PCs in Packet Tracer, create VLANs, trunk them, verify with ping, then break and fix the trunk.

Beginner · 20 min read

Technical definition

Packet Tracer VLAN lab is a hands-on exercise in Cisco Packet Tracer that builds two switches with two VLANs, assigns access ports, trunks the switches together and proves that VLAN members can talk across the trunk while members of other VLANs cannot.

What you will build

This walkthrough was written from Cisco IOS documentation and Packet Tracer behaviour as generally described. It has not been run in Packet Tracer here, so port names and prompts can differ slightly on your version.

Two Catalyst 2960 switches, four PCs and one trunk. VLAN 10 (Sales) and VLAN 20 (Support) each have one PC on each switch. By the end, PCs in the same VLAN reach each other through the trunk, and PCs in different VLANs do not.

Packet Tracer topology: two switches, two VLANs, one trunk
Packet Tracer topology: two switches, two VLANs, one trunkSW1 and SW2 are joined by a trunk on Gi0/1. PC1 and PC3 are in VLAN 10 on Fa0/1 of each switch. PC2 and PC4 are in VLAN 20 on Fa0/2 of each switch.Fa0/1Fa0/2Gi0/1 trunkFa0/1Fa0/2SW12960SW22960PC1VLAN 10 · .11PC2VLAN 20 · .21PC3VLAN 10 · .12PC4VLAN 20 · .22
Addressing: VLAN 10 uses 192.168.10.0/24 (PC1 .11, PC3 .12). VLAN 20 uses 192.168.20.0/24 (PC2 .21, PC4 .22). The mask is 255.255.255.0 everywhere.

Step 1: place and cable the devices

  1. Add two 2960 switches and four PCs. Rename them SW1, SW2 and PC1 to PC4.
  2. Use copper straight-through cables from each PC to Fa0/1 or Fa0/2 as shown.
  3. Connect SW1 Gi0/1 to SW2 Gi0/1 with a copper straight-through cable too: the 2960 detects the cable type automatically (auto MDI-X).
  4. Wait for the link lights to turn green. They are amber for about 30 seconds while spanning tree settles.

Step 2: give the PCs their addresses

Click a PC, open Desktop, then IP Configuration, choose Static and enter the address and mask from the figure. Leave the gateway empty: there is no router in this lab.

Baseline: before any VLANs

All ports are in VLAN 1 right now. From PC1's Command Prompt, ping 192.168.10.12 should work (same subnet, through the trunk), and ping 192.168.20.21 should fail, because that is another subnet and nothing routes. Note the results; the VLANs will change the first.

Step 3: create VLANs and assign ports

On both switches, click the switch, open the CLI tab and enter:

enable configure terminal vlan 10 name SALES vlan 20 name SUPPORT exit interface FastEthernet0/1 switchport mode access switchport access vlan 10 interface FastEthernet0/2 switchport mode access switchport access vlan 20 end

VLANs are local to each switch until a trunk carries them, so create them on SW1 and on SW2. Fa0/1 goes to VLAN 10 and Fa0/2 to VLAN 20 on both.

Step 4: configure the trunk

configure terminal interface GigabitEthernet0/1 switchport mode trunk switchport trunk allowed vlan 10,20 end copy running-config startup-config

Run on both switches. Limiting the allowed list to 10 and 20 is good practice; the default allows all VLANs.

If your Packet Tracer version rejects switchport mode trunk with a message about encapsulation, enter switchport trunk encapsulation dot1q first.

Step 5: verify

Example output · based on Cisco documentation; exact format varies by platform and software version
SW1#show vlan brief
VLAN Name                             Status    Ports
---- -------------------------------- --------- -------------------------------
1    default                          active    Fa0/3, Fa0/4, ... Gi0/2
10   SALES                            active    Fa0/1
20   SUPPORT                          active    Fa0/2
Example output. Fa0/1 is in VLAN 10 and Fa0/2 in VLAN 20. The trunk port Gi0/1 is not listed under any VLAN because trunks are not access members.
Example output · based on Cisco documentation; exact format varies by platform and software version
SW1#show interfaces trunk
Port        Mode         Encapsulation  Status        Native vlan
Gi0/1       on           802.1q         trunking      1

Port        Vlans allowed on trunk
Gi0/1       10,20
Example output. The trunk is up, uses 802.1q and carries VLANs 10 and 20.
Expected ping results
Expected ping resultsFrom; To; Result; Why. PC1 (VLAN 10): PC3 (VLAN 10, other switch) Succeeds Same VLAN, carried over the trunk PC2 (VLAN 20): PC4 (VLAN 20, other switch) Succeeds Same VLAN, carried over the trunk PC1 (VLAN 10): PC2 (VLAN 20) Fails Different VLANs and subnets; no router PC1 (VLAN 10): PC4 (VLAN 20) Fails Different VLANs and subnets; no routerFromToResultWhyPC1 (VLAN 10)PC3 (VLAN 10, otherswitch)SucceedsSame VLAN, carried overthe trunkPC2 (VLAN 20)PC4 (VLAN 20, otherswitch)SucceedsSame VLAN, carried overthe trunkPC1 (VLAN 10)PC2 (VLAN 20)FailsDifferent VLANs andsubnets; no routerPC1 (VLAN 10)PC4 (VLAN 20)FailsDifferent VLANs andsubnets; no router

On small screens, swipe sideways or focus the diagram and use the arrow keys.

The first ping may time out while ARP resolves; repeat it before deciding.

Step 6: break it and fix it

  1. On SW1, run switchport trunk allowed vlan remove 10 on Gi0/1. PC1 can no longer reach PC3, while VLAN 20 still works.
  2. Find it with show interfaces trunk: VLAN 10 is missing from the allowed list.
  3. Fix with switchport trunk allowed vlan add 10 and ping again.
  4. Optional: switch to Simulation mode, ping across the trunk and click the frame to see the 802.1Q tag added when it leaves SW1.

Common Packet Tracer problems

  • Links stay amber for ages: wait for spanning tree, or use the fast-forward button.
  • A PC is in the wrong VLAN: check show vlan brief and the access port assignment.
  • Pings across the trunk fail: compare the allowed VLAN lists and the native VLAN on both ends.
  • Nothing saved: use copy running-config startup-config and save the .pkt file.

Test yourself

Predict · scenario 1

In this lab, why must the VLANs be created on both switches?

Predict · scenario 2

After the configuration, PC1 pings PC2 and fails. Why?

Predict · scenario 3

Which command lists which ports belong to which VLAN?

Predict · scenario 4

The ping across the trunk fails only for VLAN 10. What do you check?

Predict · scenario 5

Why do the link lights start amber?

FAQ

Which Packet Tracer switch should I use?
A Catalyst 2960 is the usual choice. Its ports are FastEthernet 0/1-24 and GigabitEthernet 0/1-2, which this walkthrough uses. Another model has different port names.
Why does the first ping fail?
The first ping has to wait for ARP to find the MAC address, so one or two requests time out. Ping again; later pings succeed.
Why can't PC1 ping PC2 at the end?
They are in different VLANs and different subnets, and there is no router. Moving traffic between VLANs needs a router or a Layer 3 switch, which the router-on-a-stick lab adds.