Linux - Ping & Traceroute

1. What is ping?

ping is a basic network troubleshooting command used to check:

  • If a host is reachable

  • How long it takes to send/receive packets (latency)

  • Packet loss

How ping works

  • Sends ICMP Echo Request packets to a destination.

  • Waits for ICMP Echo Reply packets.

Common usage

 
ping google.com

Useful options

  • Limit count:

     
    ping -c 4 google.com
  • Specify interval:

     
    ping -i 0.5 google.com
  • Large packet size (for testing network stress):

     
    ping -s 1000 google.com

What ping helps you diagnose

  • Internet not working → check basic connectivity

  • High latency → network congestion

  • Packet loss → poor connection or faulty router

  • DNS issues → try pinging IP instead of domain


2. What is traceroute?

traceroute shows the path a packet takes from your computer to a destination.

It helps you identify:

  • Where delay (latency) is happening

  • Where packet loss occurs

  • Which router/hop is causing issues

How traceroute works

  • Sends packets with increasing TTL (Time To Live) values.

  • Each router on the path decreases TTL and sends back an ICMP Time Exceeded message.

  • You see each “hop” between you and the destination.

Common usage

 
traceroute google.com

If traceroute is not installed:

 
sudo apt install traceroute # Ubuntu/Debian sudo yum install traceroute # RHEL/CentOS

Useful options

  • Use ICMP instead of UDP:

     
    traceroute -I google.com
  • Use TCP SYN packets (good for blocked networks):

     
    traceroute -T google.com

Ping vs Traceroute — Key Difference

Feature ping traceroute
Checks host availability
Shows path/hops
Measures latency ✔ (per hop)
Packet loss detection Partial
Protocol used ICMP UDP/ICMP/TCP

When to use what?

Use ping when:

  • You want to quickly check if a server is reachable.

  • You want to know latency.

  • You want to check for packet loss.

Use traceroute when:

 

  • Network is slow and you want to find where the delay happens.

  • Path between two servers is changing.

  • You want to detect where packets are getting dropped.