2

I'm using ping from package iputils-ping (3:20121221-4ubuntu1.1) on Ubuntu 14.04.

When pinging a host host2.lan with IP 192.168.1.20 that is down initially but comes up during the run of ping, I see this when host2.lan comes online (between sequence number 56 and 57):

From host1.lan (192.168.1.1) icmp_seq=49 Destination Host Unreachable
From host1.lan (192.168.1.1) icmp_seq=50 Destination Host Unreachable
From host1.lan (192.168.1.1) icmp_seq=51 Destination Host Unreachable
From host1.lan (192.168.1.1) icmp_seq=52 Destination Host Unreachable
From host1.lan (192.168.1.1) icmp_seq=53 Destination Host Unreachable
From host1.lan (192.168.1.1) icmp_seq=54 Destination Host Unreachable
From host1.lan (192.168.1.1) icmp_seq=55 Destination Host Unreachable
From host1.lan (192.168.1.1) icmp_seq=56 Destination Host Unreachable
64 bytes from host1.lan (192.168.1.1): icmp_seq=57 ttl=64 time=0.303 ms
64 bytes from host1.lan (192.168.1.1): icmp_seq=58 ttl=64 time=0.165 ms
64 bytes from host1.lan (192.168.1.1): icmp_seq=60 ttl=64 time=0.284 ms
64 bytes from host1.lan (192.168.1.1): icmp_seq=61 ttl=64 time=0.181 ms
64 bytes from host1.lan (192.168.1.1): icmp_seq=62 ttl=64 time=0.136 ms
64 bytes from host1.lan (192.168.1.1): icmp_seq=63 ttl=64 time=0.180 ms

What's going on here? Am I receiving an echo from host1.lan here or from host2.lan and it just gets shown as host1.lan erroneously?


Description for search engines: pinging offline host2 from host1 yields Destination Host Unreachable initially, but switches to an echo reply from host1 as soon as host2 comes up.

  • Could you do "route -n" please – alpa May 18 '15 at 17:11
  • Can you log into host2.lan and trace traffic from its point of view? Can you reach it with protocols other than ping? Are you absolutely completely sure that this can in no way be an IP address conflict? If so, what makes you believe it can't be one? – Gilles May 18 '15 at 20:48
  • @Gilles: I don't know how I would do that. I noticed this during a reboot of host2 and the only way I could synthesize a similar behavior is ifdown, I reckon. Need to see what I have in OpenWRT. Will tell tomorrow. – 0xC0000022L May 18 '15 at 22:27
1

Simplified:

  1. your host sends ARP requests for "who has host2.lan";
  2. when it doesn't receive any response, it sends an "echo-request for host2.lan" to its gateway (presumably host1.lan);
  3. the gateway answers with a host-unreachable;
  4. when host2.lan wakes up it replies to the ARP requests, and gets registered in the ARP tables on all machines in your LAN;
  5. your host then starts sending the icmp-echo packets to host2.lan instead of sending them to the gateway;
  6. the gateway stops replying with host-unreachable and forwards the few icmp-echo it has still has in transit to the (now known by ARP) host2.lan;
  7. finally, host2.lan replies with echo-reply.

By the way, this is exactly what is supposed to happen. It isn't specific to Linux in any way.

  • Thank you! I'll try to check this tomorrow. This sounds like a very logical explanation for the situation I encounter. – 0xC0000022L May 18 '15 at 19:13
1

I doubt ping is printing the wrong IP address—I'm pretty sure it'll print what's actually in the packet. I'd suggest tcpdump/wireshark to investigate further. Things that come to mind:

  • Firewall NAT rules. On both the machine you're pinging from, the machine you're pinging, and (especially if its a hop between you and to host2!) host1.
  • DNS confusion. Your DNS entries are wrong, and you're not pinging what you think you are. Or your reverse entries are wrong.
  • IP conflict (does the other host have the wrong IP?)

It does appear to have come from a remote host, guessing by the timestamps. Here 0.1 ms is remote over gig-e, 0.02 ms is local.

  • Option 2 is not possible, since the lookup of the name when I invoke ping host2.lan proves that DNS works fine (similarly getent hosts). If I cancel ping and re-run the exact same command after host2.lan comes online, it will work just fine. This kind of rules out number 3. Both are on the same network segment and make no use of NAT in their local netfilter tables (both are Linux hosts, one Ubuntu the other OpenWRT). – 0xC0000022L May 18 '15 at 19:12

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.