A switch has some intelligence and operates on layer 2 of the OSI model. In this lesson, I’ll demonstrate how a switch learns MAC addresses. Let me show you an example of three computers connected to a switch:
There’s a switch in the middle and we have 3 computers. All computers have a MAC address but I’ve simplified them. Our switch has a MAC address table and it will learn where all the MAC addresses are in the network. Let’s send something from H1 to H2:
H1 is going to send some data meant for H2, thus it will create an Ethernet frame which has a source MAC address (AAA) and a destination MAC address (BBB). Our switch has a MAC address table and here’s what will happen:
How does ComputerA know the mac address of ComputerB?
Good question, take a look at this tutorial and you’ll find the answer:
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)
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).
What about when show mac add-table shows no mac for a port. But you know their is
a device on the other end