Open In App

MAC Learning in CCNA

Improve
Improve
Like Article
Like
Save
Share
Report

The MAC (Media Access Control) address is a 48-bit physical identity of a device used to uniquely identify a device in layer 2 of the OSI model. It is represented in hexadecimal. The 3 bytes of the address represent the OUI and the last 3 bytes are unique to the device itself.

MAC Learning:

Switches only learn the source MAC address from a frame. The switch stores the MAC information in a table called the CAM table or the MAC table. CAM Table Stores:

  1.  MAC address
  2. The interface
  3. VLAN MAC address belongs to
  4. How the MAC address is learned is statically or dynamically.

Whenever a frame hits the interface of the switch it first checks the source MAC address and tries to find an entry for it in its CAM table if the entry doesn’t exist an entry is created, if it already exists then the aging timer for that entry is refreshed.

Dynamic Learning of MAC Addresses:

Dynamic MAC learning occurs when a frame whose source MAC entry does not exist in the CAM table. Consider the topology given below:

 

In this topology when we ping PC2 using PC1 then the following events occur:

  1.  Since PC1 doesn’t have the MAC address of PC2 to generate an ICMP request, an ARP request is generated.
  2. When the ARP request hits the switch e0/0 interface, the switch first looks at the source mac address. Since the switch doesn’t have an entry for the PC1 MAC address the switch it adds an entry for PC1 and floods the request on all of its interfaces with the same VLAN.
  3. When PC2 generates a reply to the PC1 ARP request the same event occurs but this time the switch performs unicast switching instead of flooding the packet.

Dynamically learned MAC addresses are flushed after 5 minutes of no communication. You can check the dynamically learned MAC address with this command:

show mac address-table dynamic

 

Static Learning of MAC addresses:

You can also statically bind a MAC address to a switch interface. Statically learned MAC addresses must never be flushed, they must be removed dynamically. To bind a MAC address to a switch interface, you can do so with the following command:

mac address-table static <MAC address> 
vlan <1-4094> interface <interface type> <module>

 

You can check the statically bounded MAC address with this command:

show mac address-table dynamic

 


Last Updated : 28 Oct, 2022
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads