How to debug network issues in Unix — “ping”

Gabriele de Capoa
2 min readMay 8, 2021

--

Photo by Sai Kiran Anagani on Unsplash

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:

  1. dig
  2. ping (this story)
  3. whois
  4. openssl
  5. nslookup
  6. traceroute and mtr
  7. iptables
  8. network configuration and statistics
  9. 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.

--

--

Gabriele de Capoa
Gabriele de Capoa

Written by Gabriele de Capoa

Cloud software engineer, wanna-be data scientist, former Scrum Master. Agile, DevOps, Kubernetes and SQL are my top topics.

No responses yet