I thought it would be useful to demonstrate
the actual process of a switch learning
the layer 2 addresses of the devices
that are connected to it.
And although the vendors vary and the commands
may be slightly different on displaying information
about the dynamically learned MAC addresses,
the concept remains the same regarding
the layer 2 switches learning, dynamically, the MAC addresses
of those devices that are connected to the switch.
So in our topology, we have these three PCs on these three
ports on the switch.
And these three PCs have these respective IP addresses
at layer 3.
And they have these three respective layer 2 addresses,
or at least the last four characters
of those MAC addresses, at layer 2.
So when we start off, if these PCs have been absolutely quiet,
not one single frame, we can look at the MAC address table
and the switch, if these PCs have not sent any frames,
should not yet know about any of their respective MAC addresses
on any of these ports.
However, once we generate some traffic,
we should be able to go back and see
this table is being populated.
So we're going to begin on the switch.
Now this happens to be a switch module that's
a module inside of a router, a Cisco router.
And so based on even the type of Cisco switch you have,
the commands may be slightly different to show
the MAC address table.
So on this switch module in this router
the command to show the MAC address table
is show mac-address-table.
So we'll enter that and press Enter.
And at the moment, the switch knows about itself.
It has a management interface.
But it hasn't dynamically learned
about any of the PCs that are connected to ports 1/1, 1/2,
or 1/3 yet.
Let's fix that right now.
Let's bring up a console window for PC 1.
And if we simply do a ping of PC 2 and a ping of PC 3,
if they reply back to PC 1, that's going
to allow the switch to learn all three devices'
MAC addresses because each of the devices,
when they respond and use their source layer 2 MAC address,
the switch goes, boom, gotcha.
And it will add that to the MAC address table.
So here on PC 1, let's do a ping over to 10.0.0.22.
That's the IP address of PC 2.
That looks good.
And let's also do a ping over to PC 3 at 10.0.0.33.
Press Enter.
That looks good as well.
We'll let that complete.
And then let's go back to the switch.
And now we're just going to use the Up Arrow
key to do the same command again to look at the MAC address
table, and press Enter.
And we can now see that the switch has dynamically
learned three MAC addresses on three respective ports.
PC 1, ending in 6800, being learned off port Fa1/1,
or fast ethernet 1/1.
PC 2's MAC address of 6801, learned off of port 1/2.
And PC 3's MAC address ending in 6802, dynamically
learned off switch port 1/3.
And the beautiful thing now is that if the switch needs
to forward frames to any of those MAC addresses,
it knows exactly how to do it.
And it can forward those frames directly
based on the learning it did as opposed
to just sending a frame to all other ports on the switch.
In this Nugget, we've demonstrated
how a switch can dynamically learn the layer
2 addresses of those devices that are
connected to the switch ports.
I hope this has been informative for you.
And I'd like to thank you for viewing.