A switch is called an intelligent device, but how does it actually learn which device is on which port?
Let's find out with a simple example.Step 1 – Learn the Source MAC Address

Figure 1 – Switch Learning MAC Addresses (Initial Topology)
In the diagram above, three devices are connected to switch SW1:
PC1 → MAC address AAA
PC2 → MAC address BBB
PC3 → MAC address CCC
PC1 sends an Ethernet frame to PC3 with source MAC AAA and destination MAC CCC.

Figure 2 – Switch Learns the Source MAC Address
To keep the focus on the switch, we assume PC1 already knows PC3's MAC address. How a device learns it is covered in the next lesson, on ARP.
When this frame arrives on interface G0/1, the switch reads the source MAC address (AAA) and creates its first entry in the MAC address table: AAA → G0/1. A switch learns MAC addresses dynamically by associating incoming source addresses with their arrival ports.
Answer the question below
What is the source MAC in the first frame?
On which interface does the switch learn MAC AAA?
Step 2 – Flood the Unknown Destination

Figure 3 – MAC Address Table Check
The switch needs to forward the frame to destination CCC, but its MAC address table currently has no entry for it.

Figure 4 – Frame Flooding and Delivery
When a destination is unknown, the switch floods the frame out of all ports except the one it arrived on (G0/1). Both PC2 and PC3 receive the frame. PC2 drops it because the destination MAC does not match BBB. PC3 accepts the frame and prepares a reply with source MAC CCC and destination MAC AAA.
Step 3 – Learn the Reply and Forward

Figure 5 – Switch Learns the MAC Address of PC3
When PC3's reply arrives on interface G0/3, the switch reads source MAC CCC and adds a second entry to its table: CCC → G0/3.

Figure 6 – MAC Address Table
Now that the table contains both entries, the switch inspects the destination MAC (AAA), finds AAA → G0/1, and forwards the reply directly to PC1 without flooding.

Figure 7 – Frame Delivery
Answer the question below
Enter the flag you got from completing the scenario.
Now let's take a look at some Cisco CLI commands to see how the switch builds its MAC address table in real time.
Answer the question below
True or false: a switch learns the destination MAC address from each frame.
In this example, you will use real MAC addresses for PC1 and PC3.

Figure 8 – Topology Used for the CLI Example
First, inspect the initial MAC address table:
SW1# show mac address-table dynamic Vlan Mac Address Type Ports ---- ----------- -------- -----The table is currently empty because no traffic has traversed the switch yet.
Now, send a ping from PC1 to PC3 (192.168.1.30) to generate network traffic:
C:\> ping 192.168.1.30 Pinging 192.168.1.30 with 32 bytes of data: Reply from 192.168.1.30: bytes=32 time<1ms TTL=128 Reply from 192.168.1.30: bytes=32 time<1ms TTL=128 Reply from 192.168.1.30: bytes=32 time<1ms TTL=128 Reply from 192.168.1.30: bytes=32 time<1ms TTL=128Check the MAC address table after PC1 sends its ICMP Request:
SW1# show mac address-table dynamic Mac Address Table ------------------------------------------- Vlan Mac Address Type Ports ---- ----------- -------- ----- 1 0011.22aa.33bb DYNAMIC Gi0/1 Total Mac Addresses for this criterion: 1PC1's source MAC address (0011.22aa.33bb) is now associated with interface Gi0/1.
Answer the question below
Which port did the switch learn PC1's MAC address on?
Because PC3's address was unknown, the switch flooded the frame. Once PC3 replied, the switch learned its source MAC address as well. Check the updated table:
SW1# show mac address-table dynamic Mac Address Table ------------------------------------------- Vlan Mac Address Type Ports ---- ----------- -------- ----- 1 0011.22aa.33bb DYNAMIC Gi0/1 1 0077.88ee.99ff DYNAMIC Gi0/3 Total Mac Addresses for this criterion: 2The table is now complete. The switch will forward subsequent frames between PC1 and PC3 directly without flooding.
Answer the question below
Which command shows the learned MAC addresses?
Dynamically learned MAC entries do not remain in the table indefinitely.
What Is the Aging Time
By default, the switch retains learned MAC addresses for 300 seconds (5 minutes). This duration is known as the aging time:
SW1# show mac address-table aging-time Global Aging Time: 300 Vlan Aging Time ---- ----------Changing the Aging Time
To modify the default aging time, adjust the timer in global configuration mode:
SW1# configure terminal Enter configuration commands, one per line. End with CNTL/Z. SW1(config)# mac address-table aging-time 600 SW1(config)# end %SYS-5-CONFIG_I: Configured from console by consoleVerify the updated configuration:
SW1# show mac address-table aging-time Global Aging Time: 600 Vlan Aging Time ---- ----------Answer the question below
What is the default aging time for MAC addresses on Cisco switches (in seconds)?
On large networks with hundreds of MAC entries, you can filter the output by MAC address or interface.
Filtering by Address or Interface
To view the entry for a specific MAC address:
SW1# show mac address-table dynamic address 0077.88ee.99ff Mac Address Table ------------------------------------------- Vlan Mac Address Type Ports ---- ----------- -------- ----- 1 0077.88ee.99ff DYNAMIC Gi0/3 Total Mac Addresses for this criterion: 1To display only entries learned on a specific interface:
SW1# show mac address-table dynamic interface Gi0/1 Mac Address Table ------------------------------------------- Vlan Mac Address Type Ports ---- ----------- -------- ----- 1 0011.22aa.33bb DYNAMIC Gi0/1 Total Mac Addresses for this criterion: 1Clearing and Relearning Entries
During troubleshooting, clear dynamic entries to force the switch to relearn them:
SW1# clear mac address-table dynamicVerify that all dynamic entries have been removed:
SW1# show mac address-table dynamic Mac Address Table ------------------------------------------- Vlan Mac Address Type Ports ---- ----------- -------- -----Answer the question below
Which command clears all dynamic MAC entries?
Right after the clear, PC3 pings PC1: which MAC address lands first in SW1's dynamic table?
A switch port can learn multiple MAC addresses if it connects to an intermediate device like another switch or an access point.

Figure 9 – Learning Multiple MAC Addresses on One Port
SW1's Perspective
SW1 sees both PC3 and PC4 behind interface Gi0/0 because they connect through SW2:
SW1# show mac address-table dynamic Mac Address Table ------------------------------------------- Vlan Mac Address Type Ports ---- ----------- -------- ----- 1 fa16.3e12.a1b2 DYNAMIC Gi0/1 ← PC1 1 fa16.3e23.c3d4 DYNAMIC Gi0/2 ← PC2 1 fa16.3e34.e5f6 DYNAMIC Gi0/0 ← PC3 1 fa16.3e45.789a DYNAMIC Gi0/0 ← PC4 Total Mac Addresses for this criterion: 4SW1 learns multiple MAC addresses on Gi0/0 because all traffic from devices behind SW2 arrives on that same uplink interface.
SW2's Perspective
Conversely, SW2 learns both PC1 and PC2 on its Gi0/0 interface connected to SW1:
SW2# show mac address-table dynamic Mac Address Table ------------------------------------------- Vlan Mac Address Type Ports ---- ----------- -------- ----- 1 fa16.3e12.a1b2 DYNAMIC Gi0/0 ← PC1 1 fa16.3e23.c3d4 DYNAMIC Gi0/0 ← PC2 1 fa16.3e34.e5f6 DYNAMIC Gi0/1 ← PC3 1 fa16.3e45.789a DYNAMIC Gi0/2 ← PC4 Total Mac Addresses for this criterion: 4Answer the question below
On which interface were multiple MAC addresses learned?
Which MAC address does SW2 hold on its Gi0/2 port?
The switch learns MAC addresses by mapping the frame's source MAC to its arrival port
Unknown destination frames trigger flooding on all ports except the receiving port as standard behavior
A single interface can learn multiple MAC addresses when connected to a trunk or downstream switch
Dynamic MAC table entries expire automatically after the aging time limit (300 seconds by default)
You now know how the switch learns MAC addresses.
But how does PC1 even know PC3's MAC in the first place? That's where ARP comes in.Answer the question below
Can a switch learn multiple MAC addresses on one port?