Cisco Support Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Announcements

Welcome to Cisco Support Community. We would love to have your feedback.

For an introduction to the new site, click here. And see here for current known issues.

New Member

How a switch learn MAC address????

switch.jpg       

hi every one

i have one simple quesion but i had no answer on that Q.

if PC A sent PING to PC B and PC B reply for PING. when issuing SHOW MAC-ADDRESS TABLE command on switch0 the result will be the MAC Addresses for PC A ,PC B , and switch1.

now my Quesion is:::: how does switch0 learnd PC B MAC???           because i know that the swich learn MAC address by looking at the source MAC and when PC B reply for PING it will send the frame with its mac as source and switch1 as dest.  and switch1 will send the frame as his MAC is the source MAC and switch0 MAC is the Dest.    so how switch0 learn PC B MAC Address???????

Thank you

3 ACCEPTED SOLUTIONS

Accepted Solutions
Purple

How a switch learn MAC address????

Hi,

No it doesn't modify the frame when forwarding it so the src and dst MAC as well as the src/dst IP aren't modified when L2 switching is involved.It would change the src MAC if it was doing routing but not when it is doing switching.

switching is just passing the frame from one interface to another based on dst MAC address and MAC table mapping.

Regards

Alain

Don't forget to rate helpful posts.

Don't forget to rate helpful posts.
Super Bronze

Re: How a switch learn MAC address????

Disclaimer

The Author of this posting offers the information contained within this posting without consideration and with the reader's understanding that there's no implied or expressed suitability or fitness for any purpose. Information provided is for informational purposes only and should not be construed as rendering professional advice of any kind. Usage of this posting's information is solely at reader's own risk.

Liability Disclaimer

In no event shall Author be liable for any damages whatsoever (including, without limitation, damages for loss of use, data or profit) arising out of the use or inability to use the posting's information even if Author has been advised of the possibility of such damage.

Posting 

now my Quesion is:::: how does switch0 learnd PC B MAC???           because i know that the swich learn MAC address by looking at the source MAC and when PC B reply for PING it will send the frame with its mac as source and switch1 as dest.  and switch1 will send the frame as his MAC is the source MAC and switch0 MAC is the Dest.    so how switch0 learn PC B MAC Address???????

No, incorrect.

PC A and PC B, at L2, do not use either switch 0 or switch 1's MACs.  They send frames to other PC using that PC's MAC.

Only if the switches were L3 switches, then the PCs would use their gateway L3 switch's MAC.  If that case neither switch would "know" far side PC MAC.

Cisco Employee

Re: How a switch learn MAC address????

Hi Ali,

To answer your question

but if sw1 forward the frame to sw0 it send the frame with sw1 as source  mac and sw0 as dest. mac. so how does sw0 learn pc B mac???

Nope, if PCA and PCB are in same vlan then irrespective of the number of switches it crosses the mac-address will be retained and the same mac-address will be learned on each ingress port.

Thanks & Regards,
Karthick Murugan
CCIE#39285

Thanks & Regards, Karthick Murugan CCIE#39285
9 REPLIES
Cisco Employee

How a switch learn MAC address????

Hi Ali,

On a Layer 2 environment, mac-address doesn't get rewritten.

Lets consider the scenario:PC(A) and PC(B) are in same VLAN 10

PC(A)---(F0/0)SW-1(F0/1)--(Fa0/1)SW2(Fa0/0)--PC(B)

PC(A) send ARP request with a frame with source-mac of PC-A which will be learned on Fa0/0(SW1), FA0/1(SW2)

PC(B) send ARP Response with a frame with source-mac of PC-B which will be learned on F0/0(SW2) FA0/1(SW1)

As long as those ports are in forwarding state in STP for that VLAN.

Try doing the same scenario with different VLAN(PCA in one vlan and PCB in other vlan), you should see a difference.

Hope it helps

Thanks & regards,

Karthick Murugan

CCIE#39285

Thanks & Regards, Karthick Murugan CCIE#39285
New Member

How a switch learn MAC address????

thanks for answering but how sw1 learn PC B mac address????

Purple

How a switch learn MAC address????

Hi,

switches lear MAC addresses by looking at source MAC in ingress ethernet frames and they send frames by looking in their MAC table for a MAC-port mapping(constructed when learning), if there is no such mapping they flood the frames out all ports except the one the frame was received.

They never alter any fields in the frames when doing L2 switching.

So when pc B replies SW1 learns the MAC of PC B by looking at the src MAC in the frame and install the mapping in its MAC table, it forwards the frame out the other port(because it already has a mapping for this dst MAC of PC A and even if it hadn't it would flood the frame anyway) then it enters SW0 which does the learning too and forwards the frame out to PC A

Regards

Alain

Don't forget to rate helpful posts.

Don't forget to rate helpful posts.
New Member

Re: How a switch learn MAC address????

thank you for your answer

but if sw1 forward the frame to sw0 it send the frame with sw1 as source mac and sw0 as dest. mac. so how does sw0 learn pc B mac???

Purple

How a switch learn MAC address????

Hi,

No it doesn't modify the frame when forwarding it so the src and dst MAC as well as the src/dst IP aren't modified when L2 switching is involved.It would change the src MAC if it was doing routing but not when it is doing switching.

switching is just passing the frame from one interface to another based on dst MAC address and MAC table mapping.

Regards

Alain

Don't forget to rate helpful posts.

Don't forget to rate helpful posts.
Cisco Employee

Re: How a switch learn MAC address????

Hi Ali,

To answer your question

but if sw1 forward the frame to sw0 it send the frame with sw1 as source  mac and sw0 as dest. mac. so how does sw0 learn pc B mac???

Nope, if PCA and PCB are in same vlan then irrespective of the number of switches it crosses the mac-address will be retained and the same mac-address will be learned on each ingress port.

Thanks & Regards,
Karthick Murugan
CCIE#39285

Thanks & Regards, Karthick Murugan CCIE#39285
New Member

How a switch learn MAC address????

HI Ali,

You need to understand ARP to know how does switch0 learnd PC B MAC.

May be this post help you.

https://learningnetwork.cisco.com/thread/14869

Please rate helpful.

Regards,

Chandu

Regards, Chandu
Cisco Employee

Re: How a switch learn MAC address????

Chandu,

You need to understand ARP to know how does switch0 learnd PC B MAC.

No, ARP is completely irrelevant for switches It just happens that the ARP is the first frame usually sent by a station when it wants to talk to another station, so the switch takes the frame carrying the ARP message and learns the source MAC from the addressing field of this frame. However, any such frame will do, regardless of what it carries.

This is one of the most often and most grave mistakes done when talking about Layer2 switch operation. I can not stress it enough: forget about ARP with relation to Layer2 switches. These switches learn simply by looking at incoming frames. It's as simple as that.

Best regards,

Peter

Super Bronze

Re: How a switch learn MAC address????

Disclaimer

The Author of this posting offers the information contained within this posting without consideration and with the reader's understanding that there's no implied or expressed suitability or fitness for any purpose. Information provided is for informational purposes only and should not be construed as rendering professional advice of any kind. Usage of this posting's information is solely at reader's own risk.

Liability Disclaimer

In no event shall Author be liable for any damages whatsoever (including, without limitation, damages for loss of use, data or profit) arising out of the use or inability to use the posting's information even if Author has been advised of the possibility of such damage.

Posting 

now my Quesion is:::: how does switch0 learnd PC B MAC???           because i know that the swich learn MAC address by looking at the source MAC and when PC B reply for PING it will send the frame with its mac as source and switch1 as dest.  and switch1 will send the frame as his MAC is the source MAC and switch0 MAC is the Dest.    so how switch0 learn PC B MAC Address???????

No, incorrect.

PC A and PC B, at L2, do not use either switch 0 or switch 1's MACs.  They send frames to other PC using that PC's MAC.

Only if the switches were L3 switches, then the PCs would use their gateway L3 switch's MAC.  If that case neither switch would "know" far side PC MAC.

333
Views
0
Helpful
9
Replies
CreatePlease to create content