Tuesday, December 23, 2014

Resolve the hostname in ping command

In Linux, we use the "ping" command to ping the hostname or the IP address directly. But what if you wanted to know the hostname of the system when you ping using the IP address? This would be very useful in resolving the IP to hostname while debugging in a local network.

$ ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=57 time=40.4 ms
Just use an additional '.' at the end of the IP to resolve it to hostname.

$ ping 8.8.8.8.
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from google-public-dns-a.google.com (8.8.8.8): icmp_seq=1 ttl=57 time=25.0 ms
64 bytes from google-public-dns-a.google.com (8.8.8.8): icmp_seq=2 ttl=57 time=36.9 ms

Page Counter