# How does a switch learn MAC Addresses

**URL:** https://forum.networklessons.com/t/how-does-a-switch-learn-mac-addresses/865
**Category:** Lessons Discussion
**Created:** [December 20, 2016, 10:01pm UTC](https://forum.networklessons.com/t/how-does-a-switch-learn-mac-addresses/865 "2016-12-20T22:01:58Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![ReneMolenaar](https://cdn-forum.networklessons.com/user_avatar/forum.networklessons.com/renemolenaar/32/488_2.png) [@ReneMolenaar](https://forum.networklessons.com/u/ReneMolenaar)
#### Post date: [December 20, 2016, 10:01pm UTC](https://forum.networklessons.com/t/how-does-a-switch-learn-mac-addresses/865/1 "2016-12-20T22:01:58Z")

</div>

This topic is to discuss the following lesson:

> **[How does a switch learn MAC Addresses](https://networklessons.com/switching/how-does-a-switch-learn-mac-addresses)**
>
> This lesson explains how a switch learns MAC address and why it floods frames when it doesn't know the destination MAC address.

---

<div class="post-metadata">

### Author: ![system](https://cdn-forum.networklessons.com/uploads/default/original/1X/1d2ef66728c7fbac8377748594345a3f474fce5f.png) [@system](https://forum.networklessons.com/u/system)
#### Post date: [July 31, 2013, 12:56pm UTC](https://forum.networklessons.com/t/how-does-a-switch-learn-mac-addresses/865/2 "2013-07-31T12:56:45Z")

</div>

How does ComputerA know the mac address of ComputerB?

---

<div class="post-metadata">

### Author: ![ReneMolenaar](https://cdn-forum.networklessons.com/user_avatar/forum.networklessons.com/renemolenaar/32/488_2.png) [@ReneMolenaar](https://forum.networklessons.com/u/ReneMolenaar)
#### Post date: [July 31, 2013, 1:03pm UTC](https://forum.networklessons.com/t/how-does-a-switch-learn-mac-addresses/865/3 "2013-07-31T13:03:58Z")

</div>

Good question, take a look at this tutorial and you’ll find the answer:

[https://networklessons.com/ciscoarp-address-resolution-protocol-explained/](https://networklessons.com/ciscoarp-address-resolution-protocol-explained/)

---

<div class="post-metadata">

### Author: ![system](https://cdn-forum.networklessons.com/uploads/default/original/1X/1d2ef66728c7fbac8377748594345a3f474fce5f.png) [@system](https://forum.networklessons.com/u/system)
#### Post date: [August 1, 2013, 6:58pm UTC](https://forum.networklessons.com/t/how-does-a-switch-learn-mac-addresses/865/4 "2013-08-01T18:58:59Z")

</div>

I had read that tutorial before this one and I asked the question because we were working in layer 2 here (not using IP address)

---

<div class="post-metadata">

### Author: ![ReneMolenaar](https://cdn-forum.networklessons.com/user_avatar/forum.networklessons.com/renemolenaar/32/488_2.png) [@ReneMolenaar](https://forum.networklessons.com/u/ReneMolenaar)
#### Post date: [August 1, 2013, 7:04pm UTC](https://forum.networklessons.com/t/how-does-a-switch-learn-mac-addresses/865/5 "2013-08-01T19:04:17Z")

</div>

Ah I see. The switch doesn’t care whatever is in the ethernet frame…only interesting thing for it are the source MAC addresses (to learn) and the destination MAC addresses (to forward).

---

<div class="post-metadata">

### Author: ![system](https://cdn-forum.networklessons.com/uploads/default/original/1X/1d2ef66728c7fbac8377748594345a3f474fce5f.png) [@system](https://forum.networklessons.com/u/system)
#### Post date: [August 19, 2013, 8:43pm UTC](https://forum.networklessons.com/t/how-does-a-switch-learn-mac-addresses/865/6 "2013-08-19T20:43:22Z")

</div>

What about when show mac add-table shows no mac for a port. But you know their is  
a device on the other end

---

<div class="post-metadata">

### Author: ![ReneMolenaar](https://cdn-forum.networklessons.com/user_avatar/forum.networklessons.com/renemolenaar/32/488_2.png) [@ReneMolenaar](https://forum.networklessons.com/u/ReneMolenaar)
#### Post date: [August 28, 2013, 2:10pm UTC](https://forum.networklessons.com/t/how-does-a-switch-learn-mac-addresses/865/7 "2013-08-28T14:10:21Z")

</div>

The switch won’t know a thing until it receives an incoming Ethernet frame, only then it can learn a MAC address. The good thing is that most devices always generate some traffic…just enable Wireshark for fun to see what a windows computer does on the background even though you are not actively running any programs.

---

<div class="post-metadata">

### Author: ![system](https://cdn-forum.networklessons.com/uploads/default/original/1X/1d2ef66728c7fbac8377748594345a3f474fce5f.png) [@system](https://forum.networklessons.com/u/system)
#### Post date: [October 24, 2013, 10:04pm UTC](https://forum.networklessons.com/t/how-does-a-switch-learn-mac-addresses/865/8 "2013-10-24T22:04:50Z")

</div>

But how computer A knows the MAC address of computer B. can you please help. I am confused.

---

<div class="post-metadata">

### Author: ![ReneMolenaar](https://cdn-forum.networklessons.com/user_avatar/forum.networklessons.com/renemolenaar/32/488_2.png) [@ReneMolenaar](https://forum.networklessons.com/u/ReneMolenaar)
#### Post date: [October 25, 2013, 8:49am UTC](https://forum.networklessons.com/t/how-does-a-switch-learn-mac-addresses/865/9 "2013-10-25T08:49:47Z")

</div>

This is a separate process that doesn’t have anything to do with the switch. The computers use ARP. You can read about it here:

> **[ARP (Address Resolution Protocol) explained](https://networklessons.com/ip-services/arp-address-resolution-protocol-explained)**
>
> This lesson explains Address Resolution Protocol (ARP) to you. Network devices use ARP to find the MAC address of the IP address they want to reach.

---

<div class="post-metadata">

### Author: ![system](https://cdn-forum.networklessons.com/uploads/default/original/1X/1d2ef66728c7fbac8377748594345a3f474fce5f.png) [@system](https://forum.networklessons.com/u/system)
#### Post date: [November 21, 2013, 2:40am UTC](https://forum.networklessons.com/t/how-does-a-switch-learn-mac-addresses/865/10 "2013-11-21T02:40:22Z")

</div>

Great lesson. Thanks for you showing this visual example and being clear in explaining the process!

---

<div class="post-metadata">

### Author: ![ReneMolenaar](https://cdn-forum.networklessons.com/user_avatar/forum.networklessons.com/renemolenaar/32/488_2.png) [@ReneMolenaar](https://forum.networklessons.com/u/ReneMolenaar)
#### Post date: [November 25, 2013, 1:15pm UTC](https://forum.networklessons.com/t/how-does-a-switch-learn-mac-addresses/865/11 "2013-11-25T13:15:19Z")

</div>

You are welcome.

---

<div class="post-metadata">

### Author: ![system](https://cdn-forum.networklessons.com/uploads/default/original/1X/1d2ef66728c7fbac8377748594345a3f474fce5f.png) [@system](https://forum.networklessons.com/u/system)
#### Post date: [November 30, 2013, 1:02pm UTC](https://forum.networklessons.com/t/how-does-a-switch-learn-mac-addresses/865/12 "2013-11-30T13:02:30Z")

</div>

Hi Rene,

Great lesson.  
I have faced some cases in the past that when I can connect a computer to the wall socket port and tried to generate some traffic from it even though the switch doesn’t show any mac address.

Please any help on this.

Thanks

---

<div class="post-metadata">

### Author: ![system](https://cdn-forum.networklessons.com/uploads/default/original/1X/1d2ef66728c7fbac8377748594345a3f474fce5f.png) [@system](https://forum.networklessons.com/u/system)
#### Post date: [January 11, 2014, 7:04pm UTC](https://forum.networklessons.com/t/how-does-a-switch-learn-mac-addresses/865/13 "2014-01-11T19:04:29Z")

</div>

thank you.it was informative

---

<div class="post-metadata">

### Author: ![ReneMolenaar](https://cdn-forum.networklessons.com/user_avatar/forum.networklessons.com/renemolenaar/32/488_2.png) [@ReneMolenaar](https://forum.networklessons.com/u/ReneMolenaar)
#### Post date: [January 14, 2014, 7:29pm UTC](https://forum.networklessons.com/t/how-does-a-switch-learn-mac-addresses/865/14 "2014-01-14T19:29:01Z")

</div>

Hi Samir,

It’s difficult to tell what was wrong with your scenario. Normally any switch will start learning MAC addresses even without configuring anything…

Rene

---

<div class="post-metadata">

### Author: ![system](https://cdn-forum.networklessons.com/uploads/default/original/1X/1d2ef66728c7fbac8377748594345a3f474fce5f.png) [@system](https://forum.networklessons.com/u/system)
#### Post date: [January 30, 2014, 6:58am UTC](https://forum.networklessons.com/t/how-does-a-switch-learn-mac-addresses/865/15 "2014-01-30T06:58:45Z")

</div>

Hi! Could you share me which app to draw the network diagram like in your website?

---

<div class="post-metadata">

### Author: ![system](https://cdn-forum.networklessons.com/uploads/default/original/1X/1d2ef66728c7fbac8377748594345a3f474fce5f.png) [@system](https://forum.networklessons.com/u/system)
#### Post date: [February 19, 2014, 9:03am UTC](https://forum.networklessons.com/t/how-does-a-switch-learn-mac-addresses/865/16 "2014-02-19T09:03:23Z")

</div>

Wouldn’t the switch learn the MAC addresses during the ARP process, or even when the DHCP discovery happens?

---

<div class="post-metadata">

### Author: ![ReneMolenaar](https://cdn-forum.networklessons.com/user_avatar/forum.networklessons.com/renemolenaar/32/488_2.png) [@ReneMolenaar](https://forum.networklessons.com/u/ReneMolenaar)
#### Post date: [March 10, 2014, 2:05pm UTC](https://forum.networklessons.com/t/how-does-a-switch-learn-mac-addresses/865/17 "2014-03-10T14:05:29Z")

</div>

Hi Callum,

On a real network, an ARP or DHCP discovery is probably the first packet that a computer sends on the network but it could be anything.

Rene

---

<div class="post-metadata">

### Author: ![njrusmc](https://cdn-forum.networklessons.com/letter_avatar_proxy/v4/letter/n/4af34b/32.png) [@njrusmc](https://forum.networklessons.com/u/njrusmc)
#### Post date: [March 15, 2014, 1:10am UTC](https://forum.networklessons.com/t/how-does-a-switch-learn-mac-addresses/865/18 "2014-03-15T01:10:06Z")

</div>

Any Ethernet frame received on a switchport will have its source MAC written to CAM for the VLAN on which the frame was received. This could be ARP or a DHCPDISCOVER message, it does not matter. It could be IPv6, IPX, or FCoE! Does not matter.

---

<div class="post-metadata">

### Author: ![system](https://cdn-forum.networklessons.com/uploads/default/original/1X/1d2ef66728c7fbac8377748594345a3f474fce5f.png) [@system](https://forum.networklessons.com/u/system)
#### Post date: [March 21, 2014, 6:07am UTC](https://forum.networklessons.com/t/how-does-a-switch-learn-mac-addresses/865/19 "2014-03-21T06:07:45Z")

</div>

What if stations 2 and 3 switch ports? Entries in mac table for ports 2 and 3 become invalid. How does the switch correct this?

---

<div class="post-metadata">

### Author: ![ReneMolenaar](https://cdn-forum.networklessons.com/user_avatar/forum.networklessons.com/renemolenaar/32/488_2.png) [@ReneMolenaar](https://forum.networklessons.com/u/ReneMolenaar)
#### Post date: [March 21, 2014, 9:17am UTC](https://forum.networklessons.com/t/how-does-a-switch-learn-mac-addresses/865/20 "2014-03-21T09:17:34Z")

</div>

Good question, once you disconnect an interface the MAC addresses learned on that interface are flushed. Also, the default “aging time” is 300 seconds. That means that if there is no activity for that MAC address for 5 minutes then it will be flushed from the MAC address table.

[Next page](https://forum.networklessons.com/t/how-does-a-switch-learn-mac-addresses/865.md?page=2)
