Assume I have following connections: [HostA] - - - - R1---- Internet - - - - R2---- [HostB]

Now, I want to communicate from HostA to HostB,

Does HostA really resolve the HostB IP address, or if it has a gateway, e.g. R1, does it resolve the default gateway MAC address for the HostB IP address, or the HostB MAC address?

I assume if the destination IP subnet is part of Router's routing table, then it resolves the next hop router MAC address for the destination IP adress. Am I correct?

  • Did any answer help you? If so, you should accept the answer so that the question doesn't keep popping up forever, looking for an answer. Alternatively, you can provide your own answer and accept it.
    – Ron Maupin
    Sep 6, 2017 at 14:34

2 Answers 2


A source host will compare the destination address to that of its own network. If it is on the same network, it will use something like ARP to resolve the layer-3 (e.g. IP) address to the layer-2 (e.g. MAC) address. Then, it will encapsulate the layer-3 packet with a layer-2 frame and send it directly to the local destination host.

If the destination address is on a different network. The host will use the layer-2 address of its configured gateway (the host on the network that knows how to reach other networks; usually a router) to encapsulate the layer-3 packets with a layer-2 frame. The host may need to use something like ARP to resolve the gateway layer-3 address to a layer-2 address.

A router will strip off the layer-2 frame, look at the layer-3 destination address, look in its routing table to see if it has a route to the destination network. If it has no route, it will drop the packet. If it has a route, it will create a layer-2 frame for the interface to which it must send the packet to reach the destination, and it forward the new frame out the interface toward the destination.


To forward a packet a host or router looks up the destination IP address in it's routing table.

Routes can either point to just an interface or to an interface and a next-hop IP address. If the route specifies a next hop IP address then it will be used, otherwise the destination address will be used as the next hop IP address.

What happens next depends on the L2 encapsulation in use on the outgoing interface. If it is Ethernet or similar then the IP address will be mapped to a MAC address using the ARP table and if needed an arp lookup. If the interface is a true point to point then the next hop IP address is likely to be ignored.

Normally the only routes without a next hop specified are those for directly connected networks (usually created implicitly as part of configuring the interface address).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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