Skip to content
We areTOP 1%

What happens, step by step, when you ping a host on another network?

MediumConceptScenario Questions
Track your progress
First attempt
Re-solve after a few days
Final pass before interviews

Answer

The sender first decides whether the destination is local, then hands the packet to its default gateway, and each router forwards it hop by hop. The source and destination IP addresses stay the same end to end, while the MAC addresses change at every hop.

  • Local or remote: the host ANDs its own address and the destination with its subnet mask. Different results mean the packet must go through the default gateway.
  • ARP for the gateway: the host needs the router's MAC address, not the destination's, so it ARPs for the gateway's IP address unless it is already cached.
  • Hop by hop: each router removes the frame, decrements the TTL, chooses the next hop by longest prefix match and builds a new frame. The last router ARPs for the destination host itself, and the ICMP Echo Reply returns the same way.

Example: PC A 192.168.1.10/24 pings server B 10.0.5.20/24 through router R (192.168.1.1 on A's side, 10.0.5.1 on B's side):

1. A: 192.168.1.10 AND mask = 192.168.1.0; 10.0.5.20 AND mask = 10.0.5.0 -> remote
2. A: ARP "who has 192.168.1.1?"  -> R replies with its MAC address
3. A -> R: [dst MAC = R][IP 192.168.1.10 -> 10.0.5.20][ICMP Echo Request]
4. R: TTL 64 -> 63, ARP for 10.0.5.20, new frame [dst MAC = B]
5. B -> A: ICMP Echo Reply along the reverse path

More in Scenario Questions

Sign in to track your progress

Your checkboxes, streak and activity heatmap are saved to your account and sync across devices. It is free.
Sign in with email

New here? Create an account