2

so if I send a packet from a host to another from the same network we know the mac address of both the source and destination.

However if the receiver is in a remote network the destination mac address will be first the router's mac then changed to the actual destination (let's assume there's one router connecting the networks).

My Question is: if the final mac address is not mentioned in the initial packet (but instead replaced with the router), how does the router know it?

Now I know there's the arp protocol that translate the IP address into a mac address, but from my understanding the mac address is associated with the nic and I think that a single device can have multiple nics and thus multiple mac addresses, so how does it choose the correct one? unless each nic is connected to a different network, and in that case what's even the use of a mac address?

  • Router works on Layer 3, works on IP , doesn't care for MAC – engineerbaz Apr 6 at 18:50
4

A router doesn't know nor does it care about the MAC address of a remote destination. MAC addresses are used only for delivery in layer-2 segments like Ethernet within a directly attached network. Those addresses are of no consequence to any node outside that segment.

Instead, communication across separate segments uses layer-3 addresses (IP) with routers. Routers forward based on the destination's layer-3 address. They look up the destination address in their routing table and then forward to the next gateway - a router leading further towards the destination or the destination itself if it is connected locally.

Forwarding to the next gateway over a MAC-based network means using the gateway's destination MAC address (determined by ARP/v4 or NDP/v6) in the frame encapsulating the actual IP packet.

Only when the destination is local to a router - on the last hop - does the router resolve the destination's MAC/L2 address, encapsulate the L3 packet in a frame addressed to the L2 address and send it over.

Intermediate routers (using MAC-based network segments) resolve the next hop router's IP address and encapsulate the packet in a frame addressed to the next hop's MAC address instead.

| improve this answer | |
4

The router is a host on the LAN, and it does the same thing as any other host to resolve the layer-3 (IP) address to the layer-2 address (MAC for IEEE protocols). For IPv4 on an IEEE network, that would be ARP (Address Resolution Protocol), or for IPv6 on an IEEE network, that would be NDP (Neighbor Discovery Protocol).


See this question and this question for related answers.


Remember that not all layer-2 protocols use MAC addressing. Some use something else, like DLCI or VPI/VCI, and some do not use any addressing, like PPP.

| improve this answer | |
0

If layer 3 interface for that specific network is configured on router then router will discover physical address of compute,

Arp works as fallows

When a new computer joins a LAN, it is assigned a unique IP address to use for identification and communication. When an incoming packet destined for a host machine on a particular LAN arrives at a gateway of router . Router looks for ARP table to find a MAC address that matches the IP address and forwards the traffic .By flooding the broadcast message to all host connected in systems a ARP table is created in router belong to layer 3 gateway configuration on router . A table called the ARP cache maintains a record of each IP address and its corresponding MAC address.if gateway is not configured on router mean it will just forward traffic on basis of routing table to next hop

enter image description here https://i.stack.imgur.com/XxOgj.png If layer 3 interface for that specific network is configured on router then router will discover physical address of compute,

Arp works as fallows

When a new computer joins a LAN, it is assigned a unique IP address to use for identification and communication. When an incoming packet destined for a host machine on a particular LAN arrives at a gateway of router . Router looks for ARP table to find a MAC address that matches the IP address and forwards the traffic .By flooding the broadcast message to all host connected in systems a ARP table is created in router belong to layer 3 gateway configuration on router . A table called the ARP cache maintains a record of each IP address and its corresponding MAC address.if gateway is not configured on router mean it will just forward traffic on basis of routing table to next hop

enter image description here https://i.stack.imgur.com/XxOgj.png Router#sh ip arp Protocol Address Age (min) Hardware Addr Type Interface Internet 172.16.10.1 - 00D0.5839.C102 ARPA GigabitEthernet0/1 Internet 172.16.10.2 1 0060.478D.1107 ARPA GigabitEthernet0/1 Internet 192.168.10.1 - 00D0.5839.C101 ARPA GigabitEthernet0/0 Internet 192.168.10.2 0 0060.2F0A.B64D ARPA GigabitEthernet0/0 Router#sh ip arp Protocol Address Age (min) Hardware Addr Type Interface Internet 172.16.10.1 - 00D0.5839.C102 ARPA GigabitEthernet0/1 Internet 172.16.10.2 1 0060.478D.1107 ARPA GigabitEthernet0/1 Internet 192.168.10.1 - 00D0.5839.C101 ARPA GigabitEthernet0/0 Internet 192.168.10.2 0 0060.2F0A.B64D ARPA GigabitEthernet0/0

| improve this answer | |
-1

If layer 3 interface for that specific network is configured on router then router will discover physical address of compute,

Arp works as fallows

When a new computer joins a LAN, it is assigned a unique IP address to use for identification and communication. When an incoming packet destined for a host machine on a particular LAN arrives at a gateway of router . Router looks for ARP table to find a MAC address that matches the IP address and forwards the traffic .By flooding the broadcast message to all host connected in systems a ARP table is created in router belong to layer 3 gateway configuration on router . A table called the ARP cache maintains a record of each IP address and its corresponding MAC address.if gateway is not configured on router mean it will just forward traffic on basis of routing table to next hop

enter image description here

Router#sh ip arp Protocol Address Age (min) Hardware Addr Type Interface Internet 172.16.10.1 - 00D0.5839.C102 ARPA GigabitEthernet0/1 Internet 172.16.10.2 1 0060.478D.1107 ARPA GigabitEthernet0/1 Internet 192.168.10.1 - 00D0.5839.C101 ARPA GigabitEthernet0/0 Internet 192.168.10.2 0 0060.2F0A.B64D ARPA GigabitEthernet0/0

  • 2
    While you are generally correct, your answer has some inconsistencies and misleading details. For example, first you say ARP is a protocol, then you say it is a program. Please consider editing your answer. – Ron Trunk Jul 17 at 12:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.