Network switching fundamentals are required for CCNP Enterprise Core studies. We’ll review the MAC address table on a Cisco switch to learn how a device to port mapping is created and why it is needed.
We don’t think much about connecting our hosts to a Cisco switch. Whether 1 Gbps or 10 Gbps Ethernet ports, MAC address learning is performed the same way.
Each host connecting to a switch port will have its MAC address entered into the switch’s MAC address table.
The MAC address table is a way to map each port to a MAC address. This makes it efficient to forward traffic directly to a host. Without the MAC address table, traffic would be forwarded out each port, like a hub (hopefully you haven’t used one of those in a long time.)
Host A has a fictitious MAC address of AA:AA:AA:AA:AA:AA and it wants to send traffic to Host B with a fictitious MAC address of BB:BB:BB:BB:BB:BB. When the network switch receives the traffic destined for Host B, it knows to forward that traffic destined to interface g1/0/27 because the MAC address table lists Host B’s MAC address for interface g1/0/27. Assume they are also on the same VLAN.
What happens if a destination MAC address is not in the MAC address table? The switch must flood the traffic out of all ports in what’s called unknown unicast flooding. The switch wants the host with the destination MAC address to respond.
What happens if the host is no longer connected? The host’s MAC address remains in the table until it ages out. There is a default aging timer.
What happens if the host changes to a different port? The MAC address table is updated accordingly.
How to view the Cisco MAC address table
First, let’s see what’s connected to my Cisco switch.
sw1#show interface status | include connected Gi1/0/1 connected 129 a-full a-100 10/100/1000BaseTX Gi1/0/3 connected trunk a-full a-1000 10/100/1000BaseTX Gi1/0/9 3504 connected trunk a-full a-1000 10/100/1000BaseTX Gi1/0/14 connected trunk a-full a-1000 10/100/1000BaseTX
Next, we use a show command to view the MAC address table of all dynamically learned addresses:
show mac address-table dynamic
The dynamic MAC addresses on my switch:
sw1#show mac address-table dynamic Mac Address Table ------------------------------------------- Vlan Mac Address Type Ports ---- – ------- – – ------ – --- 129 0017.88a9.b5dc DYNAMIC Gi1/0/1 129 7483.c279.3a4c DYNAMIC Gi1/0/14 129 c869.cd81.2307 DYNAMIC Gi1/0/14 103 000c.2979.60af DYNAMIC Gi1/0/14 103 38f9.d329.a785 DYNAMIC Gi1/0/14 103 3c52.82af.08b6 DYNAMIC Gi1/0/14 103 5032.37d2.9089 DYNAMIC Gi1/0/14 103 6cae.f6b0.3fd2 DYNAMIC Gi1/0/14 103 701f.53b7.da81 DYNAMIC Gi1/0/9 103 7483.c279.3a4c DYNAMIC Gi1/0/14 103 8e0a.c4f3.5e49 DYNAMIC Gi1/0/14 103 9c20.7bb9.6f35 DYNAMIC Gi1/0/14 103 b02a.4357.9868 DYNAMIC Gi1/0/14 120 18e8.29b0.84b8 DYNAMIC Gi1/0/14 140 000c.2979.60a5 DYNAMIC Gi1/0/14 140 000c.2979.60b9 DYNAMIC Gi1/0/14 140 0011.329f.c5a1 DYNAMIC Gi1/0/14 1 18e8.29b0.84b8 DYNAMIC Gi1/0/14 1 18e8.29b0.84b9 DYNAMIC Gi1/0/14 1 7483.c273.d835 DYNAMIC Gi1/0/14 3 5c5b.3550.0776 DYNAMIC Gi1/0/3 3 7483.c279.3a4c DYNAMIC Gi1/0/14 Total Mac Addresses for this criterion: 22
Viewing the MAC address seen on a specific interface
What if we want to verify what MAC address is seen off an individual port. This is useful for troubleshooting and verifying where a host might be located. The command syntax is:
show mac address-table <interface-name>
Here’s the output on my switch for interface g1/0/9:
sw1#show mac address-table interface g1/0/9 Mac Address Table Vlan Mac Address Type Ports – – – ------- – – ---- – – --- 103 701f.53b7.da81 DYNAMIC Gi1/0/9
View MAC addresses for a specific VLAN
It’s possible to view all learned MAC addresses for a specific VLAN. I use this command to ensure I’ve trunked a VLAN across all necessary uplinks. The command syntax is:
show mac address-table vlan <vlan-id>
The output on my switch for vlan 103:
sw1#show mac address-table dynamic vlan 103 Mac Address Table Vlan Mac Address Type Ports – – – ------- – – ---- – – --- 103 000c.2979.60af DYNAMIC Gi1/0/14 103 38f9.d329.a785 DYNAMIC Gi1/0/14 103 5032.37d2.9089 DYNAMIC Gi1/0/14 103 6cae.f6b0.3fd2 DYNAMIC Gi1/0/14 103 701f.53b7.da81 DYNAMIC Gi1/0/9 103 7483.c279.3a4c DYNAMIC Gi1/0/14 103 8e0a.c4f3.5e49 DYNAMIC Gi1/0/14 103 b02a.4357.9868 DYNAMIC Gi1/0/14 103 f65a.0212.e051 DYNAMIC Gi1/0/14 Total Mac Addresses for this criterion: 9