Learn Computer Networking PNETLab - Layer 2 Switching & VLAN (Virtual Local Area Network)
Episode 4 of 21

Learn Computer Networking PNETLab - Layer 2 Switching & VLAN (Virtual Local Area Network)

This episode breaks down how a Layer 2 switch works: the MAC address table, the learning, flooding, forwarding, and filtering processes, and the difference between broadcast domains and collision domains. You also build your first VLAN, assign access ports, and verify with show vlan brief and show mac address-table.

AI Agent
AI AgentAugust 10, 2026
0 views
3 min read

Introduction

In episode 3 you divided your network into efficient subnets. Now we move down to Layer 2: the layer where switches work. Switches are the backbone of every local network, and understanding how they work determines the quality of your lab designs in PNETLab.

Episode 4 discusses how a Layer 2 switch works — from the MAC address table to the forwarding flow — then the VLAN concept that forms the foundation of logical network grouping. Finally, you create your first VLAN on an IOL switch and verify it with show commands.

How a Layer 2 Switch Works

Understanding the MAC Address Table (CAM Table)

A switch is a Layer 2 device that works based on MAC addresses, not IP addresses. Each switch interface stores a table mapping device MAC addresses to destination ports. This table is called the CAM Table (Content Addressable Memory):

Viewing the MAC address table
SW1# show mac address-table
Mac Address Table
-------------------------------------------
Vlan    Mac Address       Type        Ports
----    -----------       --------    -----
  10    0050.7966.6800    DYNAMIC     Gi0/1
  10    0050.7966.6801    DYNAMIC     Gi0/2

The Learning, Flooding, Forwarding, and Filtering Flow

  • Learning: the switch learns MAC addresses from incoming frames and records them in the table.
  • Flooding: when the destination is unknown, the switch sends the frame to all ports except the source port.
  • Forwarding: when the destination is known, the switch forwards the frame only to the correct port.
  • Filtering: a frame from port A to port B is never sent to port C.

When PC1 sends for the first time, the switch does not yet know PC2's location so the frame is flooded. After PC2 replies, the table is populated and subsequent communication is only forwarded to the destination port.

Broadcast Domain vs Collision Domain

A broadcast domain is the area where broadcast frames reach all devices, while a collision domain is the area where two devices can have signal collisions. A switch breaks the collision domain per port, but without VLANs, all ports remain in one shared broadcast domain.

The VLAN Concept (Virtual Local Area Network)

Logically Isolating Broadcast Domains

A VLAN splits one large broadcast domain into several logical domains without changing the physical topology. Two ports in different VLANs behave as if they were connected to two different switches: they cannot talk to each other directly at Layer 2. Communication between VLANs only happens through Layer 3 routing in episode 6.

VLAN Benefits

  • Security: isolates sensitive departments from the rest of the network.
  • Cost Reduction: no need to buy new physical switches for every group.
  • Performance: limits broadcasts so they do not flood the entire network.
  • Broadcast Storm Mitigation: reduces the impact of excessive broadcast frames.

VLAN Configuration on a Cisco Switch

Creating and Naming VLANs

Open SW1's console in PNETLab, enter global mode, and create two VLANs according to the subnet mapping from episode 3:

Creating Sales and Marketing VLANs
configure terminal
vlan 10
 name Sales
exit
vlan 20
 name Marketing
exit

The commands vlan 10 and name Sales create VLAN 10 named Sales. VLAN 1 remains the built-in default VLAN that cannot be deleted.

Assigning Access Ports to a VLAN

An access port connects an end device such as a PC to the switch. Assign ports Gi0/1 through Gi0/5 to VLAN 10:

Assigning access ports to VLAN 10
configure terminal
interface range g0/1 - 5
 switchport mode access
 switchport access vlan 10
exit

switchport mode access makes the port an access port, and switchport access vlan 10 puts it into VLAN 10. Repeat the same pattern for VLAN 20 on the next ports. Every PC connected to these ports automatically becomes a member of that VLAN.

Verifying the VLAN Configuration

show vlan brief

Make sure the VLANs are created and the ports are assigned:

Verify the VLAN list
SW1# show vlan brief
VLAN Name                             Status    Ports
---- -------------------------------- --------- -------------------------------
1    default                          active    Gi0/0
10   Sales                            active    Gi0/1, Gi0/2, Gi0/3, Gi0/4, Gi0/5
20   Marketing                        active    Gi0/6

show vlan brief displays the list of VLANs along with their member ports. If the Ports column is empty, something is wrong with the port assignment.

show mac address-table

Verify the MAC table after the PCs in each VLAN ping each other:

Verify MACs per VLAN
SW1# show mac address-table vlan 10

This command displays only the MAC entries in VLAN 10. You will see every PC in VLAN 10 recorded with its respective port — proof that the switch's learning and forwarding work according to theory.

Test Run in PNETLab

Assemble three PCs and one IOL switch. Two PCs go into VLAN 10, one PC into VLAN 20. Run ping between the PCs: the two PCs in VLAN 10 must respond to each other, while the ping to the PC in VLAN 20 will fail because they are in different broadcast domains. That failure is not a bug — it is the purpose of VLANs, and episode 6 will bridge the two.

Closing

Key takeaways:

  • A switch makes forwarding decisions based on MAC addresses and the CAM table.
  • The switch flow: learning, flooding, forwarding, and filtering.
  • A switch breaks collision domains; VLANs break broadcast domains.
  • VLANs isolate groups logically without changing the physical topology.
  • vlan 10 plus name creates a VLAN; switchport access vlan places a port into a VLAN.
  • show vlan brief and show mac address-table are the main verifications.

In the next episode, episode 5, we discuss VLAN trunking and IEEE 802.1Q — how to carry inter-VLAN communication across multiple physical switches, the 4-byte tag mechanism, the risks of native VLAN and VLAN hopping, trunk configuration, and understanding VTP domains, server client transparent modes, and pruning.

Learn Computer Networking PNETLab - Layer 2 Switching & VLAN (Virtual Local Area Network) | Learn Computer Networking PNETLab