Skip to main content

Command Palette

Search for a command to run...

Network Diagnostics

Unraveling Network Issues with Ping, Traceroute, and More

Published
2 min read
Network Diagnostics
S

Growing in DevOps, together! 🤝 | Associate Software Engineer at Tech Mahindra | Enthusiastic about automation, cloud solutions, and efficient software delivery. | Let's connect, collaborate, and learn from each other!

When troubleshooting network issues, you can use diagnostic tools like ping, traceroute, netstat, and ss to check connectivity, trace routes, and inspect active network connections.


1. ping - Check Network Connectivity

The ping command tests connectivity between your system and another device by sending ICMP echo requests.

  1. Check if a host is reachable

     ping google.com
    

  2. Limit the number of packets sent (e.g., 5 packets)

     ping -c 5 google.com
    

  3. Set packet size (e.g., 100 bytes)

     ping -s 100 google.com
    

  4. Set time interval between pings (e.g., 2 seconds)

     ping -i 2 google.com
    


2. traceroute - Trace the Path of a Packet

The traceroute command shows the route packets take to reach a destination.

  1. To display a list of routers between your computer and Google's server.

     traceroute google.com
    

Understanding traceroute Output

Example output:

nginxCopyEdittraceroute to google.com (142.250.183.206), 30 hops max, 60 byte packets
 1  192.168.1.1 (192.168.1.1)  1.23 ms  1.12 ms  1.10 ms
 2  10.0.0.1 (10.0.0.1)  5.89 ms  5.76 ms  5.80 ms
 3  203.0.113.1 (203.0.113.1)  12.34 ms  12.40 ms  12.50 ms
 4  * * *
 5  142.250.183.206 (google.com)  25.67 ms  25.75 ms  25.80 ms

Explanation:

  • Each line represents a hop (a router in the path).

  • 192.168.1.1 is the first router (local network gateway).

  • 10.0.0.1 is the second router.

  • 203.0.113.1 is another router in the path.

  • * * * means a router is not responding.

  • The final destination (google.com) is reached in 5 hops.


3. netstat (Deprecated, Use ss Instead)

The netstat command displays active network connections, routing tables, and network statistics. It is now replaced by ss.

Show all active network connections

 netstat -a

Options:

-tShow only TCP connections
-uShow only UDP connections
-lShow listening ports
-rShow routing table


4. ss (Replacement for netstat)

The ss command is a faster and more powerful alternative to netstat, providing detailed information about socket connections.

ss -aShow all open network connections
ss -lShow only listening ports
ss -tShow only TCP connections
ss -uShow only UDP connections