1PING(8) iputils PING(8)
2
3
4
6 ping - send ICMP ECHO_REQUEST to network hosts
7
9 ping [-aAbBdCDefhLnOqrRUvV46] [-c count] [-F flowlabel] [-i interval]
10 [-I interface] [-l preload] [-m mark] [-M pmtudisc_option]
11 [-N nodeinfo_option] [-w deadline] [-W timeout] [-p pattern]
12 [-Q tos] [-s packetsize] [-S sndbuf] [-t ttl]
13 [-T timestamp option] [hop...] {destination}
14
16 ping uses the ICMP protocol's mandatory ECHO_REQUEST datagram to elicit
17 an ICMP ECHO_RESPONSE from a host or gateway. ECHO_REQUEST datagrams
18 (“pings”) have an IP and ICMP header, followed by a struct timeval and
19 then an arbitrary number of “pad” bytes used to fill out the packet.
20
21 ping works with both IPv4 and IPv6. Using only one of them explicitly
22 can be enforced by specifying -4 or -6.
23
24 ping can also send IPv6 Node Information Queries (RFC4620).
25 Intermediate hops may not be allowed, because IPv6 source routing was
26 deprecated (RFC5095).
27
29 -4
30 Use IPv4 only.
31
32 -6
33 Use IPv6 only.
34
35 -a
36 Audible ping.
37
38 -A
39 Adaptive ping. Interpacket interval adapts to round-trip time, so
40 that effectively not more than one (or more, if preload is set)
41 unanswered probe is present in the network. Minimal interval is
42 200msec unless super-user. On networks with low RTT this mode is
43 essentially equivalent to flood mode.
44
45 -b
46 Allow pinging a broadcast address.
47
48 -B
49 Do not allow ping to change source address of probes. The address
50 is bound to one selected when ping starts.
51
52 -c count
53 Stop after sending count ECHO_REQUEST packets. With deadline
54 option, ping waits for count ECHO_REPLY packets, until the timeout
55 expires.
56
57 -C
58 Call connect() syscall on socket creation.
59
60 -d
61 Set the SO_DEBUG option on the socket being used. Essentially, this
62 socket option is not used by Linux kernel.
63
64 -e
65 Set the identification field of ECHO_REQUEST. Value 0 implies using
66 raw socket (not supported on ICMP datagram socket). The value of
67 the field may be printed with -v option.
68
69 -D
70 Print timestamp (unix time + microseconds as in gettimeofday)
71 before each line.
72
73 -f
74 Flood ping. For every ECHO_REQUEST sent a period “.” is printed,
75 while for every ECHO_REPLY received a backspace is printed. This
76 provides a rapid display of how many packets are being dropped. If
77 interval is not given, it sets interval to zero and outputs packets
78 as fast as they come back or one hundred times per second,
79 whichever is more. Only the super-user may use this option with
80 zero interval.
81
82 -F flow label
83 IPv6 only. Allocate and set 20 bit flow label (in hex) on echo
84 request packets. If value is zero, kernel allocates random flow
85 label.
86
87 -h
88 Show help.
89
90 -i interval
91 Wait interval seconds between sending each packet. Real number
92 allowed with dot as a decimal separator (regardless locale setup).
93 The default is to wait for one second between each packet normally,
94 or not to wait in flood mode. Only super-user may set interval to
95 values less than 2 ms.
96
97 -I interface
98 interface is either an address, an interface name or a VRF name. If
99 interface is an address, it sets source address to specified
100 interface address. If interface is an interface name, it sets
101 source interface to specified interface. If interface is a VRF
102 name, each packet is routed using the corresponding routing table;
103 in this case, the -I option can be repeated to specify a source
104 address. NOTE: For IPv6, when doing ping to a link-local scope
105 address, link specification (by the '%'-notation in destination, or
106 by this option) can be used but it is no longer required.
107
108 -l preload
109 If preload is specified, ping sends that many packets not waiting
110 for reply. Only the super-user may select preload more than 3.
111
112 -L
113 Suppress loopback of multicast packets. This flag only applies if
114 the ping destination is a multicast address.
115
116 -m mark
117 use mark to tag the packets going out. This is useful for variety
118 of reasons within the kernel such as using policy routing to select
119 specific outbound processing.
120
121 -M pmtudisc_opt
122 Select Path MTU Discovery strategy. pmtudisc_option may be either
123 do (prohibit fragmentation, even local one), want (do PMTU
124 discovery, fragment locally when packet size is large), or dont (do
125 not set DF flag).
126
127 -N nodeinfo_option
128 IPv6 only. Send ICMPv6 Node Information Queries (RFC4620), instead
129 of Echo Request. CAP_NET_RAW capability is required.
130
131 help
132 Show help for NI support.
133
134 name
135 Queries for Node Names.
136
137 ipv6
138 Queries for IPv6 Addresses. There are several IPv6 specific
139 flags.
140
141 ipv6-global
142 Request IPv6 global-scope addresses.
143
144 ipv6-sitelocal
145 Request IPv6 site-local addresses.
146
147 ipv6-linklocal
148 Request IPv6 link-local addresses.
149
150 ipv6-all
151 Request IPv6 addresses on other interfaces.
152
153 ipv4
154 Queries for IPv4 Addresses. There is one IPv4 specific flag.
155
156 ipv4-all
157 Request IPv4 addresses on other interfaces.
158
159 subject-ipv6=ipv6addr
160 IPv6 subject address.
161
162 subject-ipv4=ipv4addr
163 IPv4 subject address.
164
165 subject-name=nodename
166 Subject name. If it contains more than one dot, fully-qualified
167 domain name is assumed.
168
169 subject-fqdn=nodename
170 Subject name. Fully-qualified domain name is always assumed.
171
172 -n
173 Numeric output only. No attempt will be made to lookup symbolic
174 names for host addresses.
175
176 -O
177 Report outstanding ICMP ECHO reply before sending next packet. This
178 is useful together with the timestamp -D to log output to a
179 diagnostic file and search for missing answers.
180
181 -p pattern
182 You may specify up to 16 “pad” bytes to fill out the packet you
183 send. This is useful for diagnosing data-dependent problems in a
184 network. For example, -p ff will cause the sent packet to be filled
185 with all ones.
186
187 -q
188 Quiet output. Nothing is displayed except the summary lines at
189 startup time and when finished.
190
191 -Q tos
192 Set Quality of Service -related bits in ICMP datagrams. tos can be
193 decimal (ping only) or hex number.
194
195 In RFC2474, these fields are interpreted as 8-bit Differentiated
196 Services (DS), consisting of: bits 0-1 (2 lowest bits) of separate
197 data, and bits 2-7 (highest 6 bits) of Differentiated Services
198 Codepoint (DSCP). In RFC2481 and RFC3168, bits 0-1 are used for
199 ECN.
200
201 Historically (RFC1349, obsoleted by RFC2474), these were
202 interpreted as: bit 0 (lowest bit) for reserved (currently being
203 redefined as congestion control), 1-4 for Type of Service and bits
204 5-7 (highest bits) for Precedence.
205
206 -r
207 Bypass the normal routing tables and send directly to a host on an
208 attached interface. If the host is not on a directly-attached
209 network, an error is returned. This option can be used to ping a
210 local host through an interface that has no route through it
211 provided the option -I is also used.
212
213 -R
214 ping only. Record route. Includes the RECORD_ROUTE option in the
215 ECHO_REQUEST packet and displays the route buffer on returned
216 packets. Note that the IP header is only large enough for nine such
217 routes. Many hosts ignore or discard this option.
218
219 -s packetsize
220 Specifies the number of data bytes to be sent. The default is 56,
221 which translates into 64 ICMP data bytes when combined with the 8
222 bytes of ICMP header data.
223
224 -S sndbuf
225 Set socket sndbuf. If not specified, it is selected to buffer not
226 more than one packet.
227
228 -t ttl
229 ping only. Set the IP Time to Live.
230
231 -T timestamp option
232 Set special IP timestamp options. timestamp option may be either
233 tsonly (only timestamps), tsandaddr (timestamps and addresses) or
234 tsprespec host1 [host2 [host3 [host4]]] (timestamp prespecified
235 hops).
236
237 -U
238 Print full user-to-user latency (the old behaviour). Normally ping
239 prints network round trip time, which can be different f.e. due to
240 DNS failures.
241
242 -v
243 Verbose output. Do not suppress DUP replies when pinging multicast
244 address.
245
246 -V
247 Show version and exit.
248
249 -w deadline
250 Specify a timeout, in seconds, before ping exits regardless of how
251 many packets have been sent or received. In this case ping does not
252 stop after count packet are sent, it waits either for deadline
253 expire or until count probes are answered or for some error
254 notification from network.
255
256 -W timeout
257 Time to wait for a response, in seconds. The option affects only
258 timeout in absence of any responses, otherwise ping waits for two
259 RTTs. Real number allowed with dot as a decimal separator
260 (regardless locale setup). 0 means infinite timeout.
261
262 When using ping for fault isolation, it should first be run on the
263 local host, to verify that the local network interface is up and
264 running. Then, hosts and gateways further and further away should be
265 “pinged”. Round-trip times and packet loss statistics are computed. If
266 duplicate packets are received, they are not included in the packet
267 loss calculation, although the round trip time of these packets is used
268 in calculating the minimum/average/maximum/mdev round-trip time
269 numbers.
270
271 Population standard deviation (mdev), essentially an average of how far
272 each ping RTT is from the mean RTT. The higher mdev is, the more
273 variable the RTT is (over time). With a high RTT variability, you will
274 have speed issues with bulk transfers (they will take longer than is
275 strictly speaking necessary, as the variability will eventually cause
276 the sender to wait for ACKs) and you will have middling to poor VoIP
277 quality.
278
279 When the specified number of packets have been sent (and received) or
280 if the program is terminated with a SIGINT, a brief summary is
281 displayed. Shorter current statistics can be obtained without
282 termination of process with signal SIGQUIT.
283
284 If ping does not receive any reply packets at all it will exit with
285 code 1. If a packet count and deadline are both specified, and fewer
286 than count packets are received by the time the deadline has arrived,
287 it will also exit with code 1. On other error it exits with code 2.
288 Otherwise it exits with code 0. This makes it possible to use the exit
289 code to see if a host is alive or not.
290
291 This program is intended for use in network testing, measurement and
292 management. Because of the load it can impose on the network, it is
293 unwise to use ping during normal operations or from automated scripts.
294
296 For IPv6, when the destination address has link-local scope and ping is
297 using ICMP datagram sockets, the output interface must be specified.
298 When ping is using raw sockets, it is not strictly necessary to specify
299 the output interface but it should be done to avoid ambiguity when
300 there are multiple possible output interfaces.
301
302 There are two ways to specify the output interface:
303
304 • using the % notation
305 The destination address is postfixed with % and the output
306 interface name or ifindex, for example:
307
308 ping fe80::5054:ff:fe70:67bc%eth0
309
310 ping fe80::5054:ff:fe70:67bc%2
311
312 • using the -I option
313 When using ICMP datagram sockets, this method is supported since
314 the following kernel versions: 5.17, 5.15.19, 5.10.96, 5.4.176,
315 4.19.228, 4.14.265. Also it is not supported on musl libc.
316
318 An IP header without options is 20 bytes. An ICMP ECHO_REQUEST packet
319 contains an additional 8 bytes worth of ICMP header followed by an
320 arbitrary amount of data. When a packetsize is given, this indicates
321 the size of this extra piece of data (the default is 56). Thus the
322 amount of data received inside of an IP packet of type ICMP ECHO_REPLY
323 will always be 8 bytes more than the requested data space (the ICMP
324 header).
325
326 If the data space is at least of size of struct timeval ping uses the
327 beginning bytes of this space to include a timestamp which it uses in
328 the computation of round trip times. If the data space is shorter, no
329 round trip times are given.
330
332 ping will report duplicate and damaged packets. Duplicate packets
333 should never occur, and seem to be caused by inappropriate link-level
334 retransmissions. Duplicates may occur in many situations and are rarely
335 (if ever) a good sign, although the presence of low levels of
336 duplicates may not always be cause for alarm.
337
338 Damaged packets are obviously serious cause for alarm and often
339 indicate broken hardware somewhere in the ping packet's path (in the
340 network or in the hosts).
341
343 The (inter)network layer should never treat packets differently
344 depending on the data contained in the data portion. Unfortunately,
345 data-dependent problems have been known to sneak into networks and
346 remain undetected for long periods of time. In many cases the
347 particular pattern that will have problems is something that doesn't
348 have sufficient “transitions”, such as all ones or all zeros, or a
349 pattern right at the edge, such as almost all zeros. It isn't
350 necessarily enough to specify a data pattern of all zeros (for example)
351 on the command line because the pattern that is of interest is at the
352 data link level, and the relationship between what you type and what
353 the controllers transmit can be complicated.
354
355 This means that if you have a data-dependent problem you will probably
356 have to do a lot of testing to find it. If you are lucky, you may
357 manage to find a file that either can't be sent across your network or
358 that takes much longer to transfer than other similar length files. You
359 can then examine this file for repeated patterns that you can test
360 using the -p option of ping.
361
363 The TTL value of an IP packet represents the maximum number of IP
364 routers that the packet can go through before being thrown away. In
365 current practice you can expect each router in the Internet to
366 decrement the TTL field by exactly one.
367
368 The TCP/IP specification states that the TTL field for TCP packets
369 should be set to 60, but many systems use smaller values (4.3 BSD uses
370 30, 4.2 used 15).
371
372 The maximum possible value of this field is 255, and most Unix systems
373 set the TTL field of ICMP ECHO_REQUEST packets to 255. This is why you
374 will find you can “ping” some hosts, but not reach them with telnet(1)
375 or ftp(1).
376
377 In normal operation ping prints the TTL value from the packet it
378 receives. When a remote system receives a ping packet, it can do one of
379 three things with the TTL field in its response:
380
381 • Not change it; this is what Berkeley Unix systems did before the
382 4.3BSD Tahoe release. In this case the TTL value in the received
383 packet will be 255 minus the number of routers in the round-trip
384 path.
385
386 • Set it to 255; this is what current Berkeley Unix systems do. In
387 this case the TTL value in the received packet will be 255 minus
388 the number of routers in the path from the remote system to the
389 pinging host.
390
391 • Set it to some other value. Some machines use the same value for
392 ICMP packets that they use for TCP packets, for example either 30
393 or 60. Others may use completely wild values.
394
396 • Many Hosts and Gateways ignore the RECORD_ROUTE option.
397
398 • The maximum IP header length is too small for options like
399 RECORD_ROUTE to be completely useful. There's not much that can be
400 done about this, however.
401
402 • Flood pinging is not recommended in general, and flood pinging
403 the broadcast address should only be done under very controlled
404 conditions.
405
407 ip(8), ss(8).
408
410 The ping command appeared in 4.3BSD.
411
412 The version described here is its descendant specific to Linux.
413
414 As of version s20150815, the ping6 binary doesn't exist anymore. It has
415 been merged into ping. Creating a symlink named ping6 pointing to ping
416 will result in the same functionality as before.
417
419 ping requires CAP_NET_RAW capability to be executed 1) if the program
420 is used for non-echo queries (see -N option) or when the identification
421 field set to 0 for ECHO_REQUEST (see -e), or 2) if kernel does not
422 support ICMP datagram sockets, or 3) if the user is not allowed to
423 create an ICMP echo socket. The program may be used as set-uid root.
424
426 ping is part of iputils package.
427
428
429
430iputils 20221126 PING(8)