ping - Network Connectivity Check
The ping command is a basic network diagnostic command that sends ICMP Echo Request packets and checks whether Echo Reply packets come back.
It is often the first step for telling apart “Can I connect?”, “How long does a response take?”, and “Is host name resolution working?”.
Basic syntax of the ping command
ping <destination IP address or hostname>
ping [/t] [/a] [/n <count>] [/l <size>] [/f] [/i <TTL>] [/v <TOS>] [/r <count>] [/s <count>] [{/j <hostlist> | /k <hostlist>}] [/w <timeout>] [/R] [/S <Srcaddr>] [/4] [/6] <destination>
Basic usage
ping www.google.com
This result shows that name resolution succeeded and that ICMP replies were returned by the destination.
Commonly used options
| Option | Description |
|---|---|
/n <count> | Number of requests to send. The default is 4 |
/t | Keep sending until you stop it |
/w <ms> | Time to wait for each reply, in milliseconds |
/a | Try to resolve the host name from the IP address |
/4 | Use IPv4 |
/6 | Use IPv6 |
Send only 10 requests
ping /n 10 example.com
Keep sending until stopped
ping /t 192.168.1.1
Press Ctrl + C to stop. Press Ctrl + Break to display the statistics so far while it keeps sending.
Shorten the timeout
ping /w 1000 192.168.1.1
If no reply arrives within one second, the request is treated as timed out.
How to read the results of ping
When replies come back
- The destination is reachable
- ICMP is not blocked by the destination or along the route
- You can see a rough response time
When Request timed out. is displayed
A timeout does not necessarily mean the destination is down.
It can also occur for reasons such as:
- The destination or a firewall along the route blocks ICMP
- Packets are being dropped along the route
- The destination is too busy to respond
- The specified timeout value is too short
When Destination host unreachable. is displayed
There may be a problem with your own network settings (IP address or default gateway) or with the route to the destination. This message is an error returned by your own computer or by an intermediate router, not a reply from the destination.
When it fails with a host name but succeeds with an IP address
In this case, the cause is likely DNS or name resolution rather than the network itself.
A successful ping does not guarantee that web services or database connections are healthy. It only checks whether the destination is reachable at the ICMP level.
Practical uses
Check whether you can reach the default gateway
ping 192.168.1.1
This is the basic way to check whether the problem is on the local network side.
Check host name resolution
ping /a 8.8.8.8
ping example.com
The former checks reverse lookup, and the latter checks forward lookup.
Check in this order: your own computer (ping 127.0.0.1), the default gateway, an internal server, an external IP address (such as 8.8.8.8), and an external host name. The first place where it fails is a hint to where the cause is.