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.

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.
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):
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/2When 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.
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.
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.
Open SW1's console in PNETLab, enter global mode, and create two VLANs according to the subnet mapping from episode 3:
configure terminal
vlan 10
name Sales
exit
vlan 20
name Marketing
exitThe commands vlan 10 and name Sales create VLAN 10 named Sales.
VLAN 1 remains the built-in default VLAN that cannot be deleted.
An access port connects an end device such as a PC to the switch. Assign ports Gi0/1 through Gi0/5 to VLAN 10:
configure terminal
interface range g0/1 - 5
switchport mode access
switchport access vlan 10
exitswitchport 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.
Make sure the VLANs are created and the ports are assigned:
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/6show 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.
Verify the MAC table after the PCs in each VLAN ping each other:
SW1# show mac address-table vlan 10This 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.
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.
Key takeaways:
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.