There are many reasons why ping
could fail. Firewalls are a major source of problems; for instance if the ICMP echo requests (what ping
sends) are simply dropped by a firewall (here iptables
on a Linux test virt) then that produces your first case of 100% packet loss:
[root@localhost]~# iptables-save
...
[root@localhost]~# iptables -I INPUT 1 -p icmp --icmp-type echo-request -j DROP
[root@localhost]~# ping localhost
PING localhost (127.0.0.1) 56(84) bytes of data.
^C
--- localhost ping statistics ---
5 packets transmitted, 0 received, 100% packet loss, time 4004ms
Your second case may be legitimate, but can also be caused by a firewall rule that returns a suitable ICMP response, as simulated on the same test host:
[root@localhost]~# iptables -p icmp -h | grep host-unreach
host-unreachable
TOS-host-unreachable
[root@localhost]~# iptables -D INPUT 1
[root@localhost]~# iptables-save
...
[root@localhost]~# iptables -I INPUT 1 -p icmp --icmp-type echo-request -j REJECT --reject-with icmp-host-unreachable
[root@localhost]~# ping localhost
PING localhost (127.0.0.1) 56(84) bytes of data.
From localhost (127.0.0.1) icmp_seq=1 Destination Host Unreachable
From localhost (127.0.0.1) icmp_seq=2 Destination Host Unreachable
^C
--- localhost ping statistics ---
2 packets transmitted, 0 received, +2 errors, 100% packet loss, time 1000ms
So, 100% packet loss means that the echo requests (or maybe the responses on their way back) are being dropped by a firewall (or any network device) somewhere along the network route between the source and destination. "Host unreachable" means a firewall (or any network device anywhere along the route) is rejecting the echo requests with a specific ICMP response type.
Resolving the issue will involve figuring out the network topology (traceroute
, checking the documentation, etc), using tcpdump
or similar packet tracers, reviewing the firewall rules and logs, etc. This should be done from both the source and destination hosts, and may come to involve anyone who maintains the network systems (routers, firewall, load balancers that can fake network traffic, etc) between the source and destination.