Does a switch memorize the computers MAC addresses that are connected to the ports?

Good question. I'll answer it with an animation:

Does a switch memorize the computers MAC addresses that are connected to the ports?

When Host A sends the frame, the switch does not have anything in its MAC address table. Upon receiving the frame, it records Host A's MAC Address to Switch Port mapping. Since it doesn't know where the destination MAC address is, it floods the frame out all ports.

This assures that if host B exists (which at this point, the switch does not know yet), that it will receive it. Hopefully, upon receiving the frame, Host B will generate a response frame, which will allow the Switch to learn the MAC address mapping from the return frame.

You can read more about how a Switch works here (where I took the animation from). I would also suggest reading the entire article series for a closer look at how a packet moves through a network.

One last note regarding the terms Flooding vs Broadcast. A switch never broadcasts frames, a broadcast is not an action a switch can take. A switch can only flood a frame. A broadcast is simply a frame with a destination MAC address of ffff.ffff.ffff. This is often confused because the end effect is the same, but they are actually different.

Hi

No, CDP and LLDP are not included on this case (you can disable them and it can learn the MAC address dynamically), now the switches could send frames to ports but it is not always. In the real life and to be more specific when you are using a PC with Window OS the NIC has a default behavior (obtain an IP address automatically) with this the PC will search a DHCP server using a broadcast here the PC is sending frame so the switch will learn the MAC Address, BUT if the PC never send a frame the switch will never learn the MAC address.

Usually a host (it can be a PC, IP printer, IP camera, etc) cannot send BPDU's, the BPDUs are actually the language used by the switches to exchange information to select a root bridge, now if you connect a switch to access port it can exchange BPDU and generate problems. A proof of this is you configure spanning-tree portfast bpduguard enable under the interface it will not be disabled. (if it is always a host)

>> Marcar como útil o contestado, si la respuesta resolvió la duda, esto ayuda a futuras consultas de otros miembros de la comunidad. <<

Each network card has a unique identifier called a Media Access Control (MAC) address. This address is used in LANs for communication between devices on the same network segment. Devices that want to communicate need to know each other MAC addresses before sending out packets.

Switches also use MAC addresses to make accurate forwarding or filtering decision. When a switch receives a frame, it associates the media access control (MAC) address of the sending device with the port on which it was received. The table that stores such associations is called a MAC address table. This table is stored in the volatile memory, so associations are erased after the switch is rebooted.

Switches usually perform these three functions in a LAN:

  • address learning – switches learn MAC addresses by examining the source MAC address of each received frame.
  • forward/filter decisions – switches decide whether to forward or filter a frame, based on the destination MAC address.
  • loop avoidance – switches use Spanning Tree Protocol (STP) to prevent network loops while still permitting redundancy.

To better how a network switch works, take a look at the following example:

How a switch works

Let’s say that host A wants to communicate with host B for the first time. Host A knows the IP address of host B, but since this is the first time the two hosts communicate, the hardware (MAC) addresses are not known. Host A uses the ARP process to find out the MAC address of host B. The switch forwards the ARP request out all ports except the port the host A is connected to. Host B receives the ARP request and responds with its MAC address. Host B also learns the MAC address of host A (because host A sent its MAC address in the ARP request). Host C receives the ARP request, but doesn’t respond since the IP address listed in the request is not its own.

As mentioned above, a switch learns which MAC addresses are associated with which port by examining the source MAC address of each received frame. Because host B responded with the ARP reply that included its MAC address, the switch knows the MAC address of host B and stores that address in its MAC address table. For host A, the switch knows its MAC address because of the ARP request that included it.

Now, when host A sends a packet to host B, the switch looks up in its MAC address table and forwards the frame only out the Fa0/2 port – the port on which host B is connected to. Other hosts on the network will not be involved in the communication:

How switch forwards unicast frames

NOTE
By default, MAC addresses stay in the switch’s MAC address table for 5 minutes. So if host A and host B decide to communicate inside the next 5 minutes, a new ARP process will not be necessary.

You can display the MAC address table of the switch by using the show mac-address-table command:

Switch#show mac-address-table
          Mac Address Table
-------------------------------------------

Vlan    Mac Address       Type        Ports
----    -----------       --------    -----

   1    0003.e489.513e    DYNAMIC     Fa0/2
   1    00e0.8f13.6970    DYNAMIC     Fa0/1

The output is pretty much self-explanatory: all ports belong to VLAN 1 and MAC addresses associated with specific ports are listed. DYNAMIC means that the address were learned dynamically by using the source MAC address of the received frames.


Download our Free CCNA Study Guide PDF for complete notes on all the CCNA 200-301 exam topics in one book.

We recommend the Cisco CCNA Gold Bootcamp as your main CCNA training course. It’s the highest rated Cisco course online with an average rating of 4.8 from over 30,000 public reviews and is the gold standard in CCNA training:

How does a switch know which MAC addresses are attached to which ports?

A switch builds its MAC address table by recording the MAC address of each device connected to each of its ports. The switch uses the information in the MAC address table to send frames destined for a specific device out the port, which has been assigned to that device.

Does a switch change the source MAC address?

Switches do not change MAC addresses. The L2 header only changes when a packet crosses a router.

Does every port on a switch have a MAC address?

Like all Ethernet interfaces, every port on a switch has a unique factory-assigned MAC address.

How does the switch know the destination MAC address?

Every time a frame comes into a switch interface, the switch will update or create a MAC address table entry of the source MAC address and the interface on which it arrived. The switch will use this MAC address table to look up the destination MAC address to see if it has a destination interface for the frame.