Do routers change MAC address of packets when forwarding

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











up vote
3
down vote

favorite
1












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























  • It may help to frame this question in terms of the data payload traveling up and down the layer stack, with headers added or removed at each step.
    – chrylis
    Sep 20 at 4:05










  • Changed the title to resolve the ambiguity, as at first it sounded to me like the routers change their own MAC addresses. I hope it reflects the intended meaning of the question.
    – Raimund Krämer
    Sep 20 at 6:52














up vote
3
down vote

favorite
1












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























  • It may help to frame this question in terms of the data payload traveling up and down the layer stack, with headers added or removed at each step.
    – chrylis
    Sep 20 at 4:05










  • Changed the title to resolve the ambiguity, as at first it sounded to me like the routers change their own MAC addresses. I hope it reflects the intended meaning of the question.
    – Raimund Krämer
    Sep 20 at 6:52












up vote
3
down vote

favorite
1









up vote
3
down vote

favorite
1






1





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 Sep 20 at 13:10









Raimund Krämer

1032




1032










asked Sep 19 at 14:31









amjad

755




755











  • It may help to frame this question in terms of the data payload traveling up and down the layer stack, with headers added or removed at each step.
    – chrylis
    Sep 20 at 4:05










  • Changed the title to resolve the ambiguity, as at first it sounded to me like the routers change their own MAC addresses. I hope it reflects the intended meaning of the question.
    – Raimund Krämer
    Sep 20 at 6:52
















  • It may help to frame this question in terms of the data payload traveling up and down the layer stack, with headers added or removed at each step.
    – chrylis
    Sep 20 at 4:05










  • Changed the title to resolve the ambiguity, as at first it sounded to me like the routers change their own MAC addresses. I hope it reflects the intended meaning of the question.
    – Raimund Krämer
    Sep 20 at 6:52















It may help to frame this question in terms of the data payload traveling up and down the layer stack, with headers added or removed at each step.
– chrylis
Sep 20 at 4:05




It may help to frame this question in terms of the data payload traveling up and down the layer stack, with headers added or removed at each step.
– chrylis
Sep 20 at 4:05












Changed the title to resolve the ambiguity, as at first it sounded to me like the routers change their own MAC addresses. I hope it reflects the intended meaning of the question.
– Raimund Krämer
Sep 20 at 6:52




Changed the title to resolve the ambiguity, as at first it sounded to me like the routers change their own MAC addresses. I hope it reflects the intended meaning of the question.
– Raimund Krämer
Sep 20 at 6:52










3 Answers
3






active

oldest

votes

















up vote
2
down vote



accepted











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
    Sep 19 at 14:42










  • Will expand my answer, it's not so much a case of "changed" as "re-generated"
    – Peter Green
    Sep 19 at 14:46










  • So how does a router know next router's MAC address? Isn't that routing algorithm just update each routers IP address?
    – amjad
    Sep 19 at 22:36










  • The routing table contains an IP address for the next hop, the router looks up that address in it's arp table for the interface to find the destination MAC address. If there is no arp table entry the packets will be set aside while the arp process takes place to find one.
    – Peter Green
    Sep 19 at 23:30






  • 1




    Think of the Ethernet frame as being a truck/van (Ethernet) carrying your parcel (IP packet) from depot to depot (router). The MAC address is the depot address. Not all transports use trucks. There are planes, bicycles, pneumatic tubes etc (ATM, infiniband, PPP etc). Not all of them use MAC addresses (a plane might use Lang/Long, a pneumatic tube is point to point so don't use addressing etc).
    – Aron
    Sep 20 at 1:50

















up vote
8
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




















  • So how does a router know next router's MAC address? Isn't that routing algorithm just update each routers IP address forwarding table?
    – amjad
    Sep 19 at 23:06










  • A router is just another host on a link at layer-2, and it uses ARP just like any other host. For interfaces that use IEEE protocols (the ones that use MAC addresses), a router will maintain ARP tables, and it will send ARP requests for hosts connected to that interface for which it has no ARP table entry, the same way that your PC does.
    – Ron Maupin♦
    Sep 19 at 23:13







  • 1




    @amjad, your drawing isn't clear on the protocol used between the routers. It may be frame relay, or it may be PPP or some other protocol. In the case of such a non-IEEE protocol, there would be no MAC addresses on the router interfaces, and no ARP or MAC addresses on the frames, which would use frame headers and addressing (or not) for the protocol on the interface..
    – Ron Maupin♦
    Sep 19 at 23:17











  • @amjad, in any case, the frame, including any layer-2 addresses, would be stripped off the layer-3 packet as it enters the router, losing any of the layer-2 addresses that were on the frame, then the packet is switched to the next interface, and a new frame for the new interface is built.
    – Ron Maupin♦
    Sep 19 at 23:20

















up vote
3
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-of-packets-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
    2
    down vote



    accepted











    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
      Sep 19 at 14:42










    • Will expand my answer, it's not so much a case of "changed" as "re-generated"
      – Peter Green
      Sep 19 at 14:46










    • So how does a router know next router's MAC address? Isn't that routing algorithm just update each routers IP address?
      – amjad
      Sep 19 at 22:36










    • The routing table contains an IP address for the next hop, the router looks up that address in it's arp table for the interface to find the destination MAC address. If there is no arp table entry the packets will be set aside while the arp process takes place to find one.
      – Peter Green
      Sep 19 at 23:30






    • 1




      Think of the Ethernet frame as being a truck/van (Ethernet) carrying your parcel (IP packet) from depot to depot (router). The MAC address is the depot address. Not all transports use trucks. There are planes, bicycles, pneumatic tubes etc (ATM, infiniband, PPP etc). Not all of them use MAC addresses (a plane might use Lang/Long, a pneumatic tube is point to point so don't use addressing etc).
      – Aron
      Sep 20 at 1:50














    up vote
    2
    down vote



    accepted











    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
      Sep 19 at 14:42










    • Will expand my answer, it's not so much a case of "changed" as "re-generated"
      – Peter Green
      Sep 19 at 14:46










    • So how does a router know next router's MAC address? Isn't that routing algorithm just update each routers IP address?
      – amjad
      Sep 19 at 22:36










    • The routing table contains an IP address for the next hop, the router looks up that address in it's arp table for the interface to find the destination MAC address. If there is no arp table entry the packets will be set aside while the arp process takes place to find one.
      – Peter Green
      Sep 19 at 23:30






    • 1




      Think of the Ethernet frame as being a truck/van (Ethernet) carrying your parcel (IP packet) from depot to depot (router). The MAC address is the depot address. Not all transports use trucks. There are planes, bicycles, pneumatic tubes etc (ATM, infiniband, PPP etc). Not all of them use MAC addresses (a plane might use Lang/Long, a pneumatic tube is point to point so don't use addressing etc).
      – Aron
      Sep 20 at 1:50












    up vote
    2
    down vote



    accepted







    up vote
    2
    down vote



    accepted







    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 Sep 19 at 14:56

























    answered Sep 19 at 14:38









    Peter Green

    6,7352923




    6,7352923











    • do those MAC address do get changed?
      – amjad
      Sep 19 at 14:42










    • Will expand my answer, it's not so much a case of "changed" as "re-generated"
      – Peter Green
      Sep 19 at 14:46










    • So how does a router know next router's MAC address? Isn't that routing algorithm just update each routers IP address?
      – amjad
      Sep 19 at 22:36










    • The routing table contains an IP address for the next hop, the router looks up that address in it's arp table for the interface to find the destination MAC address. If there is no arp table entry the packets will be set aside while the arp process takes place to find one.
      – Peter Green
      Sep 19 at 23:30






    • 1




      Think of the Ethernet frame as being a truck/van (Ethernet) carrying your parcel (IP packet) from depot to depot (router). The MAC address is the depot address. Not all transports use trucks. There are planes, bicycles, pneumatic tubes etc (ATM, infiniband, PPP etc). Not all of them use MAC addresses (a plane might use Lang/Long, a pneumatic tube is point to point so don't use addressing etc).
      – Aron
      Sep 20 at 1:50
















    • do those MAC address do get changed?
      – amjad
      Sep 19 at 14:42










    • Will expand my answer, it's not so much a case of "changed" as "re-generated"
      – Peter Green
      Sep 19 at 14:46










    • So how does a router know next router's MAC address? Isn't that routing algorithm just update each routers IP address?
      – amjad
      Sep 19 at 22:36










    • The routing table contains an IP address for the next hop, the router looks up that address in it's arp table for the interface to find the destination MAC address. If there is no arp table entry the packets will be set aside while the arp process takes place to find one.
      – Peter Green
      Sep 19 at 23:30






    • 1




      Think of the Ethernet frame as being a truck/van (Ethernet) carrying your parcel (IP packet) from depot to depot (router). The MAC address is the depot address. Not all transports use trucks. There are planes, bicycles, pneumatic tubes etc (ATM, infiniband, PPP etc). Not all of them use MAC addresses (a plane might use Lang/Long, a pneumatic tube is point to point so don't use addressing etc).
      – Aron
      Sep 20 at 1:50















    do those MAC address do get changed?
    – amjad
    Sep 19 at 14:42




    do those MAC address do get changed?
    – amjad
    Sep 19 at 14:42












    Will expand my answer, it's not so much a case of "changed" as "re-generated"
    – Peter Green
    Sep 19 at 14:46




    Will expand my answer, it's not so much a case of "changed" as "re-generated"
    – Peter Green
    Sep 19 at 14:46












    So how does a router know next router's MAC address? Isn't that routing algorithm just update each routers IP address?
    – amjad
    Sep 19 at 22:36




    So how does a router know next router's MAC address? Isn't that routing algorithm just update each routers IP address?
    – amjad
    Sep 19 at 22:36












    The routing table contains an IP address for the next hop, the router looks up that address in it's arp table for the interface to find the destination MAC address. If there is no arp table entry the packets will be set aside while the arp process takes place to find one.
    – Peter Green
    Sep 19 at 23:30




    The routing table contains an IP address for the next hop, the router looks up that address in it's arp table for the interface to find the destination MAC address. If there is no arp table entry the packets will be set aside while the arp process takes place to find one.
    – Peter Green
    Sep 19 at 23:30




    1




    1




    Think of the Ethernet frame as being a truck/van (Ethernet) carrying your parcel (IP packet) from depot to depot (router). The MAC address is the depot address. Not all transports use trucks. There are planes, bicycles, pneumatic tubes etc (ATM, infiniband, PPP etc). Not all of them use MAC addresses (a plane might use Lang/Long, a pneumatic tube is point to point so don't use addressing etc).
    – Aron
    Sep 20 at 1:50




    Think of the Ethernet frame as being a truck/van (Ethernet) carrying your parcel (IP packet) from depot to depot (router). The MAC address is the depot address. Not all transports use trucks. There are planes, bicycles, pneumatic tubes etc (ATM, infiniband, PPP etc). Not all of them use MAC addresses (a plane might use Lang/Long, a pneumatic tube is point to point so don't use addressing etc).
    – Aron
    Sep 20 at 1:50










    up vote
    8
    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




















    • So how does a router know next router's MAC address? Isn't that routing algorithm just update each routers IP address forwarding table?
      – amjad
      Sep 19 at 23:06










    • A router is just another host on a link at layer-2, and it uses ARP just like any other host. For interfaces that use IEEE protocols (the ones that use MAC addresses), a router will maintain ARP tables, and it will send ARP requests for hosts connected to that interface for which it has no ARP table entry, the same way that your PC does.
      – Ron Maupin♦
      Sep 19 at 23:13







    • 1




      @amjad, your drawing isn't clear on the protocol used between the routers. It may be frame relay, or it may be PPP or some other protocol. In the case of such a non-IEEE protocol, there would be no MAC addresses on the router interfaces, and no ARP or MAC addresses on the frames, which would use frame headers and addressing (or not) for the protocol on the interface..
      – Ron Maupin♦
      Sep 19 at 23:17











    • @amjad, in any case, the frame, including any layer-2 addresses, would be stripped off the layer-3 packet as it enters the router, losing any of the layer-2 addresses that were on the frame, then the packet is switched to the next interface, and a new frame for the new interface is built.
      – Ron Maupin♦
      Sep 19 at 23:20














    up vote
    8
    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




















    • So how does a router know next router's MAC address? Isn't that routing algorithm just update each routers IP address forwarding table?
      – amjad
      Sep 19 at 23:06










    • A router is just another host on a link at layer-2, and it uses ARP just like any other host. For interfaces that use IEEE protocols (the ones that use MAC addresses), a router will maintain ARP tables, and it will send ARP requests for hosts connected to that interface for which it has no ARP table entry, the same way that your PC does.
      – Ron Maupin♦
      Sep 19 at 23:13







    • 1




      @amjad, your drawing isn't clear on the protocol used between the routers. It may be frame relay, or it may be PPP or some other protocol. In the case of such a non-IEEE protocol, there would be no MAC addresses on the router interfaces, and no ARP or MAC addresses on the frames, which would use frame headers and addressing (or not) for the protocol on the interface..
      – Ron Maupin♦
      Sep 19 at 23:17











    • @amjad, in any case, the frame, including any layer-2 addresses, would be stripped off the layer-3 packet as it enters the router, losing any of the layer-2 addresses that were on the frame, then the packet is switched to the next interface, and a new frame for the new interface is built.
      – Ron Maupin♦
      Sep 19 at 23:20












    up vote
    8
    down vote










    up vote
    8
    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 Sep 19 at 14:49









    Ron Maupin♦

    56.9k953100




    56.9k953100











    • So how does a router know next router's MAC address? Isn't that routing algorithm just update each routers IP address forwarding table?
      – amjad
      Sep 19 at 23:06










    • A router is just another host on a link at layer-2, and it uses ARP just like any other host. For interfaces that use IEEE protocols (the ones that use MAC addresses), a router will maintain ARP tables, and it will send ARP requests for hosts connected to that interface for which it has no ARP table entry, the same way that your PC does.
      – Ron Maupin♦
      Sep 19 at 23:13







    • 1




      @amjad, your drawing isn't clear on the protocol used between the routers. It may be frame relay, or it may be PPP or some other protocol. In the case of such a non-IEEE protocol, there would be no MAC addresses on the router interfaces, and no ARP or MAC addresses on the frames, which would use frame headers and addressing (or not) for the protocol on the interface..
      – Ron Maupin♦
      Sep 19 at 23:17











    • @amjad, in any case, the frame, including any layer-2 addresses, would be stripped off the layer-3 packet as it enters the router, losing any of the layer-2 addresses that were on the frame, then the packet is switched to the next interface, and a new frame for the new interface is built.
      – Ron Maupin♦
      Sep 19 at 23:20
















    • So how does a router know next router's MAC address? Isn't that routing algorithm just update each routers IP address forwarding table?
      – amjad
      Sep 19 at 23:06










    • A router is just another host on a link at layer-2, and it uses ARP just like any other host. For interfaces that use IEEE protocols (the ones that use MAC addresses), a router will maintain ARP tables, and it will send ARP requests for hosts connected to that interface for which it has no ARP table entry, the same way that your PC does.
      – Ron Maupin♦
      Sep 19 at 23:13







    • 1




      @amjad, your drawing isn't clear on the protocol used between the routers. It may be frame relay, or it may be PPP or some other protocol. In the case of such a non-IEEE protocol, there would be no MAC addresses on the router interfaces, and no ARP or MAC addresses on the frames, which would use frame headers and addressing (or not) for the protocol on the interface..
      – Ron Maupin♦
      Sep 19 at 23:17











    • @amjad, in any case, the frame, including any layer-2 addresses, would be stripped off the layer-3 packet as it enters the router, losing any of the layer-2 addresses that were on the frame, then the packet is switched to the next interface, and a new frame for the new interface is built.
      – Ron Maupin♦
      Sep 19 at 23:20















    So how does a router know next router's MAC address? Isn't that routing algorithm just update each routers IP address forwarding table?
    – amjad
    Sep 19 at 23:06




    So how does a router know next router's MAC address? Isn't that routing algorithm just update each routers IP address forwarding table?
    – amjad
    Sep 19 at 23:06












    A router is just another host on a link at layer-2, and it uses ARP just like any other host. For interfaces that use IEEE protocols (the ones that use MAC addresses), a router will maintain ARP tables, and it will send ARP requests for hosts connected to that interface for which it has no ARP table entry, the same way that your PC does.
    – Ron Maupin♦
    Sep 19 at 23:13





    A router is just another host on a link at layer-2, and it uses ARP just like any other host. For interfaces that use IEEE protocols (the ones that use MAC addresses), a router will maintain ARP tables, and it will send ARP requests for hosts connected to that interface for which it has no ARP table entry, the same way that your PC does.
    – Ron Maupin♦
    Sep 19 at 23:13





    1




    1




    @amjad, your drawing isn't clear on the protocol used between the routers. It may be frame relay, or it may be PPP or some other protocol. In the case of such a non-IEEE protocol, there would be no MAC addresses on the router interfaces, and no ARP or MAC addresses on the frames, which would use frame headers and addressing (or not) for the protocol on the interface..
    – Ron Maupin♦
    Sep 19 at 23:17





    @amjad, your drawing isn't clear on the protocol used between the routers. It may be frame relay, or it may be PPP or some other protocol. In the case of such a non-IEEE protocol, there would be no MAC addresses on the router interfaces, and no ARP or MAC addresses on the frames, which would use frame headers and addressing (or not) for the protocol on the interface..
    – Ron Maupin♦
    Sep 19 at 23:17













    @amjad, in any case, the frame, including any layer-2 addresses, would be stripped off the layer-3 packet as it enters the router, losing any of the layer-2 addresses that were on the frame, then the packet is switched to the next interface, and a new frame for the new interface is built.
    – Ron Maupin♦
    Sep 19 at 23:20




    @amjad, in any case, the frame, including any layer-2 addresses, would be stripped off the layer-3 packet as it enters the router, losing any of the layer-2 addresses that were on the frame, then the packet is switched to the next interface, and a new frame for the new interface is built.
    – Ron Maupin♦
    Sep 19 at 23:20










    up vote
    3
    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
      3
      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
        3
        down vote










        up vote
        3
        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 Sep 19 at 15:00









        jonathanjo

        6,170423




        6,170423



























             

            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-of-packets-when-forwarding%23new-answer', 'question_page');

            );

            Post as a guest













































































            Popular posts from this blog

            How to check contact read email or not when send email to Individual?

            Bahrain

            Postfix configuration issue with fips on centos 7; mailgun relay