There are many network utilities that are ready to use out of Linux box.
ping is one of them:
pings are ECHO_REQUEST datagrams.
For a quick usage:
% ping localhost PING localhost (127.0.0.1) 56(84) bytes of data. 64 bytes from localhost (127.0.0.1): icmp_req=1 ttl=64 time=0.034 ms 64 bytes from localhost (127.0.0.1): icmp_req=2 ttl=64 time=0.045 ms 64 bytes from localhost (127.0.0.1): icmp_req=3 ttl=64 time=0.039 ms ^C --- localhost ping statistics --- 3 packets transmitted, 3 received, 0% packet loss, time 1999ms rtt min/avg/max/mdev = 0.034/0.039/0.045/0.006 ms
rrt is the round-trip time in milliseconds. The statistics includes minimum, average, maximum and mean deviation times.
The manual page explains many options. Here are onces I found helpful to me:
ping -D -n -q -c 100 localhost
-D: UNIX timestamp + microseconds
-n: no lookup symbolic names for host addresses (faster)
-c: number of pings to send
-q: result only
Ping localhost to verify that the local network interface is up and running:
% ping -d -n -q -c 100 localhost PING localhost (127.0.0.1) 56(84) bytes of data. --- localhost ping statistics --- 100 packets transmitted, 100 received, 0% packet loss, time 99005ms rtt min/avg/max/mdev = 0.029/0.047/0.059/0.007 ms
Ping local gateway, usually router:
% ping -D -n -q -c 100 192.168.1.1 PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data. --- 192.168.1.1 ping statistics --- 100 packets transmitted, 100 received, 0% packet loss, time 98997ms rtt min/avg/max/mdev = 0.416/0.502/1.448/0.100 ms
If we ping a remote server without using
-n option, it will be slower due to the host address lookup:
% ping -c 20 baidu.com 20 packets transmitted, 20 received, 0% packet loss, time 96034ms rtt min/avg/max/mdev = 46.061/49.096/92.912/10.061 ms
% ping -c 20 -n baidu.com 20 packets transmitted, 20 received, 0% packet loss, time 19029ms rtt min/avg/max/mdev = 45.802/46.428/47.391/0.458 ms
Look up the actual IP address of the domain:
% nslookup baidu.com Server: 127.0.0.1 Address: 127.0.0.1#53 Non-authoritative answer: Name: baidu.com Address: 188.8.131.52 Name: baidu.com Address: 184.108.40.206 Name: baidu.com Address: 220.127.116.11
We can send pings by using IP address directly, which is almost the same as using
-n option. It is faster:
% ping -c 20 18.104.22.168 --- 22.214.171.124 ping statistics --- 20 packets transmitted, 20 received, 0% packet loss, time 19026ms rtt min/avg/max/mdev = 46.103/53.019/86.077/12.831 ms
But not all servers support ping, pings might be dropped altogether. Also, even a server does support ping, it does not mean that you can browser the website hosted by the server. The port might get blocked, or server is down.
Pinging an IP address is fun, but what is more exciting to actually find out more information about the address, such as the geographical location of the IP. What Is My IP Address is good tool to use.