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