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
Useful options
-
Limit count:
-
Specify interval:
-
Large packet size (for testing network stress):
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
If traceroute is not installed:
Useful options
-
Use ICMP instead of UDP:
-
Use TCP SYN packets (good for blocked networks):
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.