---
layout: page
category-page: intermediate
category-title: Intermediate commands
author: Joy Albertini
tags: server ping latency
title: ping
previous-page: pages/cmd/interm/passwd.html
next-page: pages/cmd/interm/ps.html
---
The ping
command, is used to test connection between a local server/computer
to a remote UNIX server.
The ping command sends ICMP Echo Request packets to the remote server for accessing it.
Each packet echoed back (via an ICMP Echo Response packet) is written to the shell output.
ping [-flag] server
The main usages for the ping
command are:
- Test whether remote server if working.
- Check the network connectivity from your local machine to a remote one.
- Check for general network issues.
ping theshell.ch
The shell will output something like this:
64 bytes from 98.138.219.232: icmp_seq=0 ttl=49 time=144.781 ms for each packet
that returns (echoed back).
To stop the ping command press control + c
.
Flags
- -c: send limited number of packets with ping -c (nr of packets)
Example: ping -c 4 yahoo.com, the shell will display the first 4 packets returned,
and then stop.
- -n: avoid dns lookup, avoid to lookup symbolic names for host addresses,
so only numeric output.
- -a: get an audio warning, when the remote server comes online
Example: ping -a yahoo.com, server comes online audio signal for every
packets that returns.
- -b: Allow pinging a broadcast address (broadcast network, is a network
with many devices on it).
- -m: (mark) tag the packets going out.
- -f: (Flood ping) For every ECHO_REQUEST sent (.) is printed,
for every ECHO_REPLY received, a backspace is printed.
With this command you can easily understand how many packets are being dropped.
- -i: (interval) set the interval between seending each packet (default 1 second);
only super-user can set interval values less than 0.2 seconds.
- -I: (interface-address) set souce adress to a specific interface adress,
example the name of the device or IP. When pinging local adresses IPV6, is a needed flag.
- -l: (preload) ping send packets but don't wait for reply.
Admin permissions are required to use this flag.
- -L: Remove loopback of multicast packets.
- -N: (Nioption) send ICMpv6 request, instead of Echo requests
- ipv6: request Ipv6 adresses.
- ipv4-all: request Ipv4 adresses.
- -p: (pattern) specify up to 16 number to fill out the packets sent.
- -D: print timestamp (unix time + microseconds) in each line.
- -q: (Quiet output) Nothing displayed except the summary lines at the start
and at the end.
- -R: (Record route), displays the route buffer on the packets that include
RECORD_ROUTE in the ECHO_REQUEST.
- -r: bypass the normal routing in a directly-attached network.
- -s: (packetsize) Specifies the data bytes to send (default is 56 that
+ 8 byte of ICMP = 64 ICMP data bytes).
- -t: set IP time-to-live (set how long execute ping in seconds).
- -U: print full user-to-user latency (legacy ping behaviour).
- -v: output verbose on output
- -V: Display verion of command
- -w: (deadline) Timeout in seconds of ping command, regardless of how\
many packets have been sent.
- -W: (timeout), time waiting for a response from the server, if the server
dosen't reply in the time set, the ping command will stop.