How to debug network issues in Unix — “ping”
In my day-by-day job, I started to use lots of BASH commands to debug network issues, and I did never not many of them. This is why I decided to write here all those commands and how do I use usually.
This will be a series. Here the table of contents:
dig
ping
(this story)whois
openssl
nslookup
traceroute
andmtr
iptables
- network configuration and statistics
tcpdump
Here a second command I frequently use to check network issues: ping
.
With ping
you could test, more or less, host reachability. I am saying more or less because it depends on the internals of ping
and the configuration of host.
As Wikipedia said
Ping operates by sending Internet Control Message Protocol (ICMP) echo request packets to the target host and waiting for an ICMP echo reply. The program reports errors, packet loss, and a statistical summary of the results, typically including the minimum, maximum, the mean round-trip times, and standard deviation of the mean. So if the host’s configuration blocks ICMP protocol,
ping
packet will be lost or rejected.
The behavior of ping
command will be different among Unix/Mac OS and Windows system.
On Windows, ping
will automatically interrupt after 4 ICMP packages sent and received, while on Unix and Mac OS the command will continue to send ICMP packages until the program will interrupt if there is no threshold parameter.
$ ping www.example.com
PING www.example.com (93.184.216.34) 56(84) bytes of data.
64 bytes from 93.184.216.34: icmp_seq=1 ttl=53 time=114 ms
64 bytes from 93.184.216.34: icmp_seq=2 ttl=53 time=116 ms
64 bytes from 93.184.216.34: icmp_seq=3 ttl=53 time=116 ms
64 bytes from 93.184.216.34: icmp_seq=4 ttl=53 time=540 ms
64 bytes from 93.184.216.34: icmp_seq=5 ttl=53 time=114 ms
64 bytes from 93.184.216.34: icmp_seq=6 ttl=53 time=115 ms
64 bytes from 93.184.216.34: icmp_seq=7 ttl=53 time=114 ms
64 bytes from 93.184.216.34: icmp_seq=8 ttl=53 time=115 ms
64 bytes from 93.184.216.34: icmp_seq=9 ttl=53 time=114 ms
64 bytes from 93.184.216.34: icmp_seq=10 ttl=53 time=115 ms
^C
--- www.example.com ping statistics ---
10 packets transmitted, 10 received, 0% packet loss, time 18224ms
rtt min/avg/max/mdev = 114.564/157.908/540.775/127.624 ms
Originally published at https://gabriele-decapoa.github.io.