Do routers change MAC address when forwarding

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
1
down vote

favorite












enter image description here



Lets say host A wants to send a packet to host B through R1(interface 1 then 2) and R2 (interface 3), so my questions is:



When the packet is forwarded inside R1 (from interface 1 to interface 2), ready to be sent to R2, does the pack's source MAC(A's MAC address) and destination MAC(interface 1's MAC address) get changed to interface 2's MAC address as new source address and interface 3(of R2) as new destination MAC address? If they do get changed, why router need to change source and destination MAC address?










share|improve this question



























    up vote
    1
    down vote

    favorite












    enter image description here



    Lets say host A wants to send a packet to host B through R1(interface 1 then 2) and R2 (interface 3), so my questions is:



    When the packet is forwarded inside R1 (from interface 1 to interface 2), ready to be sent to R2, does the pack's source MAC(A's MAC address) and destination MAC(interface 1's MAC address) get changed to interface 2's MAC address as new source address and interface 3(of R2) as new destination MAC address? If they do get changed, why router need to change source and destination MAC address?










    share|improve this question

























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      enter image description here



      Lets say host A wants to send a packet to host B through R1(interface 1 then 2) and R2 (interface 3), so my questions is:



      When the packet is forwarded inside R1 (from interface 1 to interface 2), ready to be sent to R2, does the pack's source MAC(A's MAC address) and destination MAC(interface 1's MAC address) get changed to interface 2's MAC address as new source address and interface 3(of R2) as new destination MAC address? If they do get changed, why router need to change source and destination MAC address?










      share|improve this question















      enter image description here



      Lets say host A wants to send a packet to host B through R1(interface 1 then 2) and R2 (interface 3), so my questions is:



      When the packet is forwarded inside R1 (from interface 1 to interface 2), ready to be sent to R2, does the pack's source MAC(A's MAC address) and destination MAC(interface 1's MAC address) get changed to interface 2's MAC address as new source address and interface 3(of R2) as new destination MAC address? If they do get changed, why router need to change source and destination MAC address?







      router mac-address






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 4 hours ago









      Zac67

      19.7k21047




      19.7k21047










      asked 4 hours ago









      amjad

      634




      634




















          3 Answers
          3






          active

          oldest

          votes

















          up vote
          3
          down vote













          When a frame comes into a router, the router strips off and discards the frame, losing any layer-2 addressing, including MAC addresses. The router will build a new frame for the next interface.



          Not all layer-2 protocols use MAC addresses, and of those that do, some are 48-bit MAC addresses, and some are 64-bit MAC addresses. It is the IEEE LAN protocols that use MAC addressing, but, for example, frame relay uses DLCI number, or ATM uses VPI/VCI. Point-to-point protocols may not use any addressing because there is only one other device on the link.



          If the next router interface also uses MAC addresses, the router will build a new frame with the MAC address of its interface as the source address, and the MAC address of the destination on the link as the destination MAC address. If the next interface doesn't use MAC addressing, the router builds a frame for the protocol on the interface.






          share|improve this answer



























            up vote
            2
            down vote














            isn't a router only deal with IP address




            A router with Ethernet (or Ethernet-like) interfaces needs to deal with MAC addresses because it needs to send and receive IP packets over those Ethernet interfaces and MAC addresses are a core part of Ethernet.



            MAC addresses only have meaning within an Ethernet network.



            Logically what happens at R1 is.



            1. The destination MAC address is checked. For a Unicast MAC address* if it doesn't match the frame is dropped by the network card, if it does match the Ethernet frame is stripped and the packet is passed up to the IP stack. This check is important to prevent packet duplication.

            2. The IP address is examined and determined to not be one of the local interfaces of the router.

            3. The IP address is looked up in the routing table and an interface and next-hop IP address is chosen.

            4. What happens next depends on the nature of the connection between R1 and R2. If the connection is Ethernet then the IP packet will be encapsulated in an Ethernet frame with the router's interface as source MAC and a MAC address looked up using the next-hop IP address as destination MAC address. On the other hand if the link is a serial point to point interface then there may be no MAC addresses involved at all and other protocols may have their own addressing scheme.

            * Broadcast and multicast packets need more special handling, but that is outside the scope of this question.






            share|improve this answer






















            • do those MAC address do get changed?
              – amjad
              4 hours ago










            • Will expand my answer, it's not so much a case of "changed" as "re-generated"
              – Peter Green
              4 hours ago

















            up vote
            2
            down vote













            It's only rewording what others have already said, but the way I usually explain this is with a thought experiment:



            • Suppose there's no ethernet, and all of the hosts and routers have a direct point-to-point links (with the same connectivity, ie A to R1)

            • Many point to point links have no link addressing: just send the packet in some kind of framing and the other end receives it.

            • Then, exactly as you imagine, packets just have fixed IP source and destination address from host A to host B.

            • If it's convenient, a given set of links might be replaced by ethernet

            • To pass a packet in ethernet, it must have ethernet source and destination addresses in order to get to just the right node on the ethernet

            • On ethernet the frame says "I have this for you", where "I" and "you" are defined by the source and destination ethernet addresses

            • As the IP packet goes from hop to hop, different routers are saying "I have this for you", so of course the frame would have different source and destination addresses

            • If it's not ethernet, you get the appropriate kind of MAC addressing for that medium; 48-bit, 64-bit, none.





            share|improve this answer




















              Your Answer







              StackExchange.ready(function()
              var channelOptions =
              tags: "".split(" "),
              id: "496"
              ;
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function()
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled)
              StackExchange.using("snippets", function()
              createEditor();
              );

              else
              createEditor();

              );

              function createEditor()
              StackExchange.prepareEditor(
              heartbeatType: 'answer',
              convertImagesToLinks: false,
              noModals: false,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: null,
              bindNavPrevention: true,
              postfix: "",
              noCode: true, onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              );



              );













               

              draft saved


              draft discarded


















              StackExchange.ready(
              function ()
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fnetworkengineering.stackexchange.com%2fquestions%2f53379%2fdo-routers-change-mac-address-when-forwarding%23new-answer', 'question_page');

              );

              Post as a guest






























              3 Answers
              3






              active

              oldest

              votes








              3 Answers
              3






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes








              up vote
              3
              down vote













              When a frame comes into a router, the router strips off and discards the frame, losing any layer-2 addressing, including MAC addresses. The router will build a new frame for the next interface.



              Not all layer-2 protocols use MAC addresses, and of those that do, some are 48-bit MAC addresses, and some are 64-bit MAC addresses. It is the IEEE LAN protocols that use MAC addressing, but, for example, frame relay uses DLCI number, or ATM uses VPI/VCI. Point-to-point protocols may not use any addressing because there is only one other device on the link.



              If the next router interface also uses MAC addresses, the router will build a new frame with the MAC address of its interface as the source address, and the MAC address of the destination on the link as the destination MAC address. If the next interface doesn't use MAC addressing, the router builds a frame for the protocol on the interface.






              share|improve this answer
























                up vote
                3
                down vote













                When a frame comes into a router, the router strips off and discards the frame, losing any layer-2 addressing, including MAC addresses. The router will build a new frame for the next interface.



                Not all layer-2 protocols use MAC addresses, and of those that do, some are 48-bit MAC addresses, and some are 64-bit MAC addresses. It is the IEEE LAN protocols that use MAC addressing, but, for example, frame relay uses DLCI number, or ATM uses VPI/VCI. Point-to-point protocols may not use any addressing because there is only one other device on the link.



                If the next router interface also uses MAC addresses, the router will build a new frame with the MAC address of its interface as the source address, and the MAC address of the destination on the link as the destination MAC address. If the next interface doesn't use MAC addressing, the router builds a frame for the protocol on the interface.






                share|improve this answer






















                  up vote
                  3
                  down vote










                  up vote
                  3
                  down vote









                  When a frame comes into a router, the router strips off and discards the frame, losing any layer-2 addressing, including MAC addresses. The router will build a new frame for the next interface.



                  Not all layer-2 protocols use MAC addresses, and of those that do, some are 48-bit MAC addresses, and some are 64-bit MAC addresses. It is the IEEE LAN protocols that use MAC addressing, but, for example, frame relay uses DLCI number, or ATM uses VPI/VCI. Point-to-point protocols may not use any addressing because there is only one other device on the link.



                  If the next router interface also uses MAC addresses, the router will build a new frame with the MAC address of its interface as the source address, and the MAC address of the destination on the link as the destination MAC address. If the next interface doesn't use MAC addressing, the router builds a frame for the protocol on the interface.






                  share|improve this answer












                  When a frame comes into a router, the router strips off and discards the frame, losing any layer-2 addressing, including MAC addresses. The router will build a new frame for the next interface.



                  Not all layer-2 protocols use MAC addresses, and of those that do, some are 48-bit MAC addresses, and some are 64-bit MAC addresses. It is the IEEE LAN protocols that use MAC addressing, but, for example, frame relay uses DLCI number, or ATM uses VPI/VCI. Point-to-point protocols may not use any addressing because there is only one other device on the link.



                  If the next router interface also uses MAC addresses, the router will build a new frame with the MAC address of its interface as the source address, and the MAC address of the destination on the link as the destination MAC address. If the next interface doesn't use MAC addressing, the router builds a frame for the protocol on the interface.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered 4 hours ago









                  Ron Maupin♦

                  56.4k94795




                  56.4k94795




















                      up vote
                      2
                      down vote














                      isn't a router only deal with IP address




                      A router with Ethernet (or Ethernet-like) interfaces needs to deal with MAC addresses because it needs to send and receive IP packets over those Ethernet interfaces and MAC addresses are a core part of Ethernet.



                      MAC addresses only have meaning within an Ethernet network.



                      Logically what happens at R1 is.



                      1. The destination MAC address is checked. For a Unicast MAC address* if it doesn't match the frame is dropped by the network card, if it does match the Ethernet frame is stripped and the packet is passed up to the IP stack. This check is important to prevent packet duplication.

                      2. The IP address is examined and determined to not be one of the local interfaces of the router.

                      3. The IP address is looked up in the routing table and an interface and next-hop IP address is chosen.

                      4. What happens next depends on the nature of the connection between R1 and R2. If the connection is Ethernet then the IP packet will be encapsulated in an Ethernet frame with the router's interface as source MAC and a MAC address looked up using the next-hop IP address as destination MAC address. On the other hand if the link is a serial point to point interface then there may be no MAC addresses involved at all and other protocols may have their own addressing scheme.

                      * Broadcast and multicast packets need more special handling, but that is outside the scope of this question.






                      share|improve this answer






















                      • do those MAC address do get changed?
                        – amjad
                        4 hours ago










                      • Will expand my answer, it's not so much a case of "changed" as "re-generated"
                        – Peter Green
                        4 hours ago














                      up vote
                      2
                      down vote














                      isn't a router only deal with IP address




                      A router with Ethernet (or Ethernet-like) interfaces needs to deal with MAC addresses because it needs to send and receive IP packets over those Ethernet interfaces and MAC addresses are a core part of Ethernet.



                      MAC addresses only have meaning within an Ethernet network.



                      Logically what happens at R1 is.



                      1. The destination MAC address is checked. For a Unicast MAC address* if it doesn't match the frame is dropped by the network card, if it does match the Ethernet frame is stripped and the packet is passed up to the IP stack. This check is important to prevent packet duplication.

                      2. The IP address is examined and determined to not be one of the local interfaces of the router.

                      3. The IP address is looked up in the routing table and an interface and next-hop IP address is chosen.

                      4. What happens next depends on the nature of the connection between R1 and R2. If the connection is Ethernet then the IP packet will be encapsulated in an Ethernet frame with the router's interface as source MAC and a MAC address looked up using the next-hop IP address as destination MAC address. On the other hand if the link is a serial point to point interface then there may be no MAC addresses involved at all and other protocols may have their own addressing scheme.

                      * Broadcast and multicast packets need more special handling, but that is outside the scope of this question.






                      share|improve this answer






















                      • do those MAC address do get changed?
                        – amjad
                        4 hours ago










                      • Will expand my answer, it's not so much a case of "changed" as "re-generated"
                        – Peter Green
                        4 hours ago












                      up vote
                      2
                      down vote










                      up vote
                      2
                      down vote










                      isn't a router only deal with IP address




                      A router with Ethernet (or Ethernet-like) interfaces needs to deal with MAC addresses because it needs to send and receive IP packets over those Ethernet interfaces and MAC addresses are a core part of Ethernet.



                      MAC addresses only have meaning within an Ethernet network.



                      Logically what happens at R1 is.



                      1. The destination MAC address is checked. For a Unicast MAC address* if it doesn't match the frame is dropped by the network card, if it does match the Ethernet frame is stripped and the packet is passed up to the IP stack. This check is important to prevent packet duplication.

                      2. The IP address is examined and determined to not be one of the local interfaces of the router.

                      3. The IP address is looked up in the routing table and an interface and next-hop IP address is chosen.

                      4. What happens next depends on the nature of the connection between R1 and R2. If the connection is Ethernet then the IP packet will be encapsulated in an Ethernet frame with the router's interface as source MAC and a MAC address looked up using the next-hop IP address as destination MAC address. On the other hand if the link is a serial point to point interface then there may be no MAC addresses involved at all and other protocols may have their own addressing scheme.

                      * Broadcast and multicast packets need more special handling, but that is outside the scope of this question.






                      share|improve this answer















                      isn't a router only deal with IP address




                      A router with Ethernet (or Ethernet-like) interfaces needs to deal with MAC addresses because it needs to send and receive IP packets over those Ethernet interfaces and MAC addresses are a core part of Ethernet.



                      MAC addresses only have meaning within an Ethernet network.



                      Logically what happens at R1 is.



                      1. The destination MAC address is checked. For a Unicast MAC address* if it doesn't match the frame is dropped by the network card, if it does match the Ethernet frame is stripped and the packet is passed up to the IP stack. This check is important to prevent packet duplication.

                      2. The IP address is examined and determined to not be one of the local interfaces of the router.

                      3. The IP address is looked up in the routing table and an interface and next-hop IP address is chosen.

                      4. What happens next depends on the nature of the connection between R1 and R2. If the connection is Ethernet then the IP packet will be encapsulated in an Ethernet frame with the router's interface as source MAC and a MAC address looked up using the next-hop IP address as destination MAC address. On the other hand if the link is a serial point to point interface then there may be no MAC addresses involved at all and other protocols may have their own addressing scheme.

                      * Broadcast and multicast packets need more special handling, but that is outside the scope of this question.







                      share|improve this answer














                      share|improve this answer



                      share|improve this answer








                      edited 4 hours ago

























                      answered 4 hours ago









                      Peter Green

                      6,6302922




                      6,6302922











                      • do those MAC address do get changed?
                        – amjad
                        4 hours ago










                      • Will expand my answer, it's not so much a case of "changed" as "re-generated"
                        – Peter Green
                        4 hours ago
















                      • do those MAC address do get changed?
                        – amjad
                        4 hours ago










                      • Will expand my answer, it's not so much a case of "changed" as "re-generated"
                        – Peter Green
                        4 hours ago















                      do those MAC address do get changed?
                      – amjad
                      4 hours ago




                      do those MAC address do get changed?
                      – amjad
                      4 hours ago












                      Will expand my answer, it's not so much a case of "changed" as "re-generated"
                      – Peter Green
                      4 hours ago




                      Will expand my answer, it's not so much a case of "changed" as "re-generated"
                      – Peter Green
                      4 hours ago










                      up vote
                      2
                      down vote













                      It's only rewording what others have already said, but the way I usually explain this is with a thought experiment:



                      • Suppose there's no ethernet, and all of the hosts and routers have a direct point-to-point links (with the same connectivity, ie A to R1)

                      • Many point to point links have no link addressing: just send the packet in some kind of framing and the other end receives it.

                      • Then, exactly as you imagine, packets just have fixed IP source and destination address from host A to host B.

                      • If it's convenient, a given set of links might be replaced by ethernet

                      • To pass a packet in ethernet, it must have ethernet source and destination addresses in order to get to just the right node on the ethernet

                      • On ethernet the frame says "I have this for you", where "I" and "you" are defined by the source and destination ethernet addresses

                      • As the IP packet goes from hop to hop, different routers are saying "I have this for you", so of course the frame would have different source and destination addresses

                      • If it's not ethernet, you get the appropriate kind of MAC addressing for that medium; 48-bit, 64-bit, none.





                      share|improve this answer
























                        up vote
                        2
                        down vote













                        It's only rewording what others have already said, but the way I usually explain this is with a thought experiment:



                        • Suppose there's no ethernet, and all of the hosts and routers have a direct point-to-point links (with the same connectivity, ie A to R1)

                        • Many point to point links have no link addressing: just send the packet in some kind of framing and the other end receives it.

                        • Then, exactly as you imagine, packets just have fixed IP source and destination address from host A to host B.

                        • If it's convenient, a given set of links might be replaced by ethernet

                        • To pass a packet in ethernet, it must have ethernet source and destination addresses in order to get to just the right node on the ethernet

                        • On ethernet the frame says "I have this for you", where "I" and "you" are defined by the source and destination ethernet addresses

                        • As the IP packet goes from hop to hop, different routers are saying "I have this for you", so of course the frame would have different source and destination addresses

                        • If it's not ethernet, you get the appropriate kind of MAC addressing for that medium; 48-bit, 64-bit, none.





                        share|improve this answer






















                          up vote
                          2
                          down vote










                          up vote
                          2
                          down vote









                          It's only rewording what others have already said, but the way I usually explain this is with a thought experiment:



                          • Suppose there's no ethernet, and all of the hosts and routers have a direct point-to-point links (with the same connectivity, ie A to R1)

                          • Many point to point links have no link addressing: just send the packet in some kind of framing and the other end receives it.

                          • Then, exactly as you imagine, packets just have fixed IP source and destination address from host A to host B.

                          • If it's convenient, a given set of links might be replaced by ethernet

                          • To pass a packet in ethernet, it must have ethernet source and destination addresses in order to get to just the right node on the ethernet

                          • On ethernet the frame says "I have this for you", where "I" and "you" are defined by the source and destination ethernet addresses

                          • As the IP packet goes from hop to hop, different routers are saying "I have this for you", so of course the frame would have different source and destination addresses

                          • If it's not ethernet, you get the appropriate kind of MAC addressing for that medium; 48-bit, 64-bit, none.





                          share|improve this answer












                          It's only rewording what others have already said, but the way I usually explain this is with a thought experiment:



                          • Suppose there's no ethernet, and all of the hosts and routers have a direct point-to-point links (with the same connectivity, ie A to R1)

                          • Many point to point links have no link addressing: just send the packet in some kind of framing and the other end receives it.

                          • Then, exactly as you imagine, packets just have fixed IP source and destination address from host A to host B.

                          • If it's convenient, a given set of links might be replaced by ethernet

                          • To pass a packet in ethernet, it must have ethernet source and destination addresses in order to get to just the right node on the ethernet

                          • On ethernet the frame says "I have this for you", where "I" and "you" are defined by the source and destination ethernet addresses

                          • As the IP packet goes from hop to hop, different routers are saying "I have this for you", so of course the frame would have different source and destination addresses

                          • If it's not ethernet, you get the appropriate kind of MAC addressing for that medium; 48-bit, 64-bit, none.






                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered 4 hours ago









                          jonathanjo

                          5,725323




                          5,725323



























                               

                              draft saved


                              draft discarded















































                               


                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function ()
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fnetworkengineering.stackexchange.com%2fquestions%2f53379%2fdo-routers-change-mac-address-when-forwarding%23new-answer', 'question_page');

                              );

                              Post as a guest













































































                              Comments

                              Popular posts from this blog

                              Long meetings (6-7 hours a day): Being “babysat” by supervisor

                              Is the Concept of Multiple Fantasy Races Scientifically Flawed? [closed]

                              Confectionery