]>
Commit | Line | Data |
---|---|---|
2b484d24 A |
1 | .\" Copyright (c) 1985, 1991, 1993\r |
2 | .\" The Regents of the University of California. All rights reserved.\r | |
3 | .\"\r | |
4 | .\" Redistribution and use in source and binary forms, with or without\r | |
5 | .\" modification, are permitted provided that the following conditions\r | |
6 | .\" are met:\r | |
7 | .\" 1. Redistributions of source code must retain the above copyright\r | |
8 | .\" notice, this list of conditions and the following disclaimer.\r | |
9 | .\" 2. Redistributions in binary form must reproduce the above copyright\r | |
10 | .\" notice, this list of conditions and the following disclaimer in the\r | |
11 | .\" documentation and/or other materials provided with the distribution.\r | |
12 | .\" 4. Neither the name of the University nor the names of its contributors\r | |
13 | .\" may be used to endorse or promote products derived from this software\r | |
14 | .\" without specific prior written permission.\r | |
15 | .\"\r | |
16 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND\r | |
17 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r | |
18 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r | |
19 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE\r | |
20 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\r | |
21 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\r | |
22 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\r | |
23 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r | |
24 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\r | |
25 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\r | |
26 | .\" SUCH DAMAGE.\r | |
27 | .\"\r | |
28 | .\" @(#)ping.8 8.2 (Berkeley) 12/11/93\r | |
29 | .\" $FreeBSD: /repoman/r/ncvs/src/sbin/ping/ping.8,v 1.51 2004/04/09 19:58:34 markm Exp $\r | |
30 | .\"\r | |
31 | .Dd October 2, 2002\r | |
32 | .Dt PING 8\r | |
33 | .Os\r | |
34 | .Sh NAME\r | |
35 | .Nm ping\r | |
36 | .Nd send\r | |
37 | .Tn ICMP ECHO_REQUEST\r | |
38 | packets to network hosts\r | |
39 | .Sh SYNOPSIS\r | |
40 | .Nm\r | |
41 | .Op Fl AaDdfnoQqRrv\r | |
42 | .Op Fl c Ar count\r | |
43 | .Op Fl i Ar wait\r | |
44 | .Op Fl l Ar preload\r | |
45 | .Op Fl M Cm mask | time\r | |
46 | .Op Fl m Ar ttl\r | |
47 | .Op Fl P Ar policy\r | |
48 | .Op Fl p Ar pattern\r | |
49 | .Op Fl S Ar src_addr\r | |
50 | .Op Fl s Ar packetsize\r | |
51 | .Op Fl t Ar timeout\r | |
52 | .Op Fl z Ar tos\r | |
53 | .Ar host\r | |
54 | .Nm\r | |
55 | .Op Fl AaDdfLnoQqRrv\r | |
56 | .Op Fl c Ar count\r | |
57 | .Op Fl I Ar iface\r | |
58 | .Op Fl i Ar wait\r | |
59 | .Op Fl l Ar preload\r | |
60 | .Op Fl M Cm mask | time\r | |
61 | .Op Fl m Ar ttl\r | |
62 | .Op Fl P Ar policy\r | |
63 | .Op Fl p Ar pattern\r | |
64 | .Op Fl S Ar src_addr\r | |
65 | .Op Fl s Ar packetsize\r | |
66 | .Op Fl T Ar ttl\r | |
67 | .Op Fl t Ar timeout\r | |
68 | .Op Fl z Ar tos\r | |
69 | .Ar mcast-group\r | |
70 | .Sh DESCRIPTION\r | |
71 | The\r | |
72 | .Nm\r | |
73 | utility uses the\r | |
74 | .Tn ICMP\r | |
75 | .No protocol Ap s mandatory\r | |
76 | .Tn ECHO_REQUEST\r | |
77 | datagram to elicit an\r | |
78 | .Tn ICMP ECHO_RESPONSE\r | |
79 | from a host or gateway.\r | |
80 | .Tn ECHO_REQUEST\r | |
81 | datagrams\r | |
82 | .Pq Dq pings\r | |
83 | have an IP and\r | |
84 | .Tn ICMP\r | |
85 | header, followed by a\r | |
86 | .Dq struct timeval\r | |
87 | and then an arbitrary number of\r | |
88 | .Dq pad\r | |
89 | bytes used to fill out the packet.\r | |
90 | The options are as follows:\r | |
91 | .Bl -tag -width indent\r | |
92 | .It Fl A\r | |
93 | Audible.\r | |
94 | Output a bell\r | |
95 | .Tn ( ASCII\r | |
96 | 0x07)\r | |
97 | character when no packet is received before the next packet\r | |
98 | is transmitted.\r | |
99 | To cater for round-trip times that are longer than the interval\r | |
100 | between transmissions, further missing packets cause a bell only\r | |
101 | if the maximum number of unreceived packets has increased.\r | |
102 | .It Fl a\r | |
103 | Audible.\r | |
104 | Include a bell\r | |
105 | .Tn ( ASCII\r | |
106 | 0x07)\r | |
107 | character in the output when any packet is received.\r | |
108 | This option is ignored\r | |
109 | if other format options are present.\r | |
110 | .It Fl c Ar count\r | |
111 | Stop after sending\r | |
112 | (and receiving)\r | |
113 | .Ar count\r | |
114 | .Tn ECHO_RESPONSE\r | |
115 | packets.\r | |
116 | If this option is not specified,\r | |
117 | .Nm\r | |
118 | will operate until interrupted.\r | |
119 | .It Fl D\r | |
120 | Set the Don't Fragment bit.\r | |
121 | .It Fl d\r | |
122 | Set the\r | |
123 | .Dv SO_DEBUG\r | |
124 | option on the socket being used.\r | |
125 | .It Fl f\r | |
126 | Flood ping.\r | |
127 | Outputs packets as fast as they come back or one hundred times per second,\r | |
128 | whichever is more.\r | |
129 | For every\r | |
130 | .Tn ECHO_REQUEST\r | |
131 | sent a period\r | |
132 | .Dq .\&\r | |
133 | is printed, while for every\r | |
134 | .Tn ECHO_REPLY\r | |
135 | received a backspace is printed.\r | |
136 | This provides a rapid display of how many packets are being dropped.\r | |
137 | Only the super-user may use this option.\r | |
138 | .Bf -emphasis\r | |
139 | This can be very hard on a network and should be used with caution.\r | |
140 | .Ef\r | |
141 | .It Fl I Ar iface\r | |
142 | Source multicast packets with the given interface address.\r | |
143 | This flag only applies if the ping destination is a multicast address.\r | |
144 | .It Fl i Ar wait\r | |
145 | Wait\r | |
146 | .Ar wait\r | |
147 | seconds\r | |
148 | .Em between sending each packet .\r | |
149 | The default is to wait for one second between each packet.\r | |
150 | The wait time may be fractional, but only the super-user may specify\r | |
151 | values less than 1 second.\r | |
152 | This option is incompatible with the\r | |
153 | .Fl f\r | |
154 | option.\r | |
155 | .It Fl L\r | |
156 | Suppress loopback of multicast packets.\r | |
157 | This flag only applies if the ping destination is a multicast address.\r | |
158 | .It Fl l Ar preload\r | |
159 | If\r | |
160 | .Ar preload\r | |
161 | is specified,\r | |
162 | .Nm\r | |
163 | sends that many packets as fast as possible before falling into its normal\r | |
164 | mode of behavior.\r | |
165 | Only the super-user may use this option.\r | |
166 | .It Fl M Cm mask | time\r | |
167 | Use\r | |
168 | .Dv ICMP_MASKREQ\r | |
169 | or\r | |
170 | .Dv ICMP_TSTAMP\r | |
171 | instead of\r | |
172 | .Dv ICMP_ECHO .\r | |
173 | For\r | |
174 | .Cm mask ,\r | |
175 | print the netmask of the remote machine.\r | |
176 | Set the\r | |
177 | .Va net.inet.icmp.maskrepl\r | |
178 | MIB variable to enable\r | |
179 | .Dv ICMP_MASKREPLY .\r | |
180 | For\r | |
181 | .Cm time ,\r | |
182 | print the origination, reception and transmission timestamps.\r | |
183 | .It Fl m Ar ttl\r | |
184 | Set the IP Time To Live for outgoing packets.\r | |
185 | If not specified, the kernel uses the value of the\r | |
186 | .Va net.inet.ip.ttl\r | |
187 | MIB variable.\r | |
188 | .It Fl n\r | |
189 | Numeric output only.\r | |
190 | No attempt will be made to lookup symbolic names for host addresses.\r | |
191 | .It Fl o\r | |
192 | Exit successfully after receiving one reply packet.\r | |
193 | .It Fl P Ar policy\r | |
194 | .Ar policy\r | |
195 | specifies IPsec policy for the ping session.\r | |
196 | For details please refer to\r | |
197 | .Xr ipsec 4\r | |
198 | and\r | |
199 | .Xr ipsec_set_policy 3 .\r | |
200 | .It Fl p Ar pattern\r | |
201 | You may specify up to 16\r | |
202 | .Dq pad\r | |
203 | bytes to fill out the packet you send.\r | |
204 | This is useful for diagnosing data-dependent problems in a network.\r | |
205 | For example,\r | |
206 | .Dq Li \-p ff\r | |
207 | will cause the sent packet to be filled with all\r | |
208 | ones.\r | |
209 | .It Fl Q\r | |
210 | Somewhat quiet output.\r | |
211 | .No Don Ap t\r | |
212 | display ICMP error messages that are in response to our query messages.\r | |
213 | Originally, the\r | |
214 | .Fl v\r | |
215 | flag was required to display such errors, but\r | |
216 | .Fl v\r | |
217 | displays all ICMP error messages.\r | |
218 | On a busy machine, this output can be overbearing.\r | |
219 | Without the\r | |
220 | .Fl Q\r | |
221 | flag,\r | |
222 | .Nm\r | |
223 | prints out any ICMP error messages caused by its own ECHO_REQUEST\r | |
224 | messages.\r | |
225 | .It Fl q\r | |
226 | Quiet output.\r | |
227 | Nothing is displayed except the summary lines at startup time and\r | |
228 | when finished.\r | |
229 | .It Fl R\r | |
230 | Record route.\r | |
231 | Includes the\r | |
232 | .Tn RECORD_ROUTE\r | |
233 | option in the\r | |
234 | .Tn ECHO_REQUEST\r | |
235 | packet and displays\r | |
236 | the route buffer on returned packets.\r | |
237 | Note that the IP header is only large enough for nine such routes;\r | |
238 | the\r | |
239 | .Xr traceroute 8\r | |
240 | command is usually better at determining the route packets take to a\r | |
241 | particular destination.\r | |
242 | If more routes come back than should, such as due to an illegal spoofed\r | |
243 | packet, ping will print the route list and then truncate it at the correct\r | |
244 | spot.\r | |
245 | Many hosts ignore or discard the\r | |
246 | .Tn RECORD_ROUTE\r | |
247 | option.\r | |
248 | .It Fl r\r | |
249 | Bypass the normal routing tables and send directly to a host on an attached\r | |
250 | network.\r | |
251 | If the host is not on a directly-attached network, an error is returned.\r | |
252 | This option can be used to ping a local host through an interface\r | |
253 | that has no route through it\r | |
254 | (e.g., after the interface was dropped by\r | |
255 | .Xr routed 8 ) .\r | |
256 | .It Fl S Ar src_addr\r | |
257 | Use the following IP address as the source address in outgoing packets.\r | |
258 | On hosts with more than one IP address, this option can be used to\r | |
259 | force the source address to be something other than the IP address\r | |
260 | of the interface the probe packet is sent on.\r | |
261 | If the IP address\r | |
262 | is not one of this machine's interface addresses, an error is\r | |
263 | returned and nothing is sent.\r | |
264 | .It Fl s Ar packetsize\r | |
265 | Specify the number of data bytes to be sent.\r | |
266 | The default is 56, which translates into 64\r | |
267 | .Tn ICMP\r | |
268 | data bytes when combined\r | |
269 | with the 8 bytes of\r | |
270 | .Tn ICMP\r | |
271 | header data.\r | |
272 | .It Fl T Ar ttl\r | |
273 | Set the IP Time To Live for multicasted packets.\r | |
274 | This flag only applies if the ping destination is a multicast address.\r | |
275 | .It Fl t Ar timeout\r | |
276 | Specify a timeout, in seconds, before ping exits regardless of how\r | |
277 | many packets have been received.\r | |
278 | .It Fl v\r | |
279 | Verbose output.\r | |
280 | .Tn ICMP\r | |
281 | packets other than\r | |
282 | .Tn ECHO_RESPONSE\r | |
283 | that are received are listed.\r | |
284 | .It Fl z Ar tos\r | |
285 | Use the specified type of service.\r | |
286 | .El\r | |
287 | .Pp\r | |
288 | When using\r | |
289 | .Nm\r | |
290 | for fault isolation, it should first be run on the local host, to verify\r | |
291 | that the local network interface is up and running.\r | |
292 | Then, hosts and gateways further and further away should be\r | |
293 | .Dq pinged .\r | |
294 | Round-trip times and packet loss statistics are computed.\r | |
295 | If duplicate packets are received, they are not included in the packet\r | |
296 | loss calculation, although the round trip time of these packets is used\r | |
297 | in calculating the round-trip time statistics.\r | |
298 | When the specified number of packets have been sent\r | |
299 | (and received)\r | |
300 | or if the program is terminated with a\r | |
301 | .Dv SIGINT ,\r | |
302 | a brief summary is displayed, showing the number of packets sent and\r | |
303 | received, and the minimum, mean, maximum, and standard deviation of\r | |
304 | the round-trip times.\r | |
305 | .Pp\r | |
306 | If\r | |
307 | .Nm\r | |
308 | receives a\r | |
309 | .Dv SIGINFO\r | |
310 | (see the\r | |
311 | .Cm status\r | |
312 | argument for\r | |
313 | .Xr stty 1 )\r | |
314 | signal, the current number of packets sent and received, and the\r | |
315 | minimum, mean, and maximum of the round-trip times will be written to\r | |
316 | the standard error output.\r | |
317 | .Pp\r | |
318 | This program is intended for use in network testing, measurement and\r | |
319 | management.\r | |
320 | Because of the load it can impose on the network, it is unwise to use\r | |
321 | .Nm\r | |
322 | during normal operations or from automated scripts.\r | |
323 | .Sh ICMP PACKET DETAILS\r | |
324 | An IP header without options is 20 bytes.\r | |
325 | An\r | |
326 | .Tn ICMP\r | |
327 | .Tn ECHO_REQUEST\r | |
328 | packet contains an additional 8 bytes worth of\r | |
329 | .Tn ICMP\r | |
330 | header followed by an arbitrary amount of data.\r | |
331 | When a\r | |
332 | .Ar packetsize\r | |
333 | is given, this indicated the size of this extra piece of data\r | |
334 | (the default is 56).\r | |
335 | Thus the amount of data received inside of an IP packet of type\r | |
336 | .Tn ICMP\r | |
337 | .Tn ECHO_REPLY\r | |
338 | will always be 8 bytes more than the requested data space\r | |
339 | (the\r | |
340 | .Tn ICMP\r | |
341 | header).\r | |
342 | .Pp\r | |
343 | If the data space is at least eight bytes large,\r | |
344 | .Nm\r | |
345 | uses the first eight bytes of this space to include a timestamp which\r | |
346 | it uses in the computation of round trip times.\r | |
347 | If less than eight bytes of pad are specified, no round trip times are\r | |
348 | given.\r | |
349 | .Sh DUPLICATE AND DAMAGED PACKETS\r | |
350 | The\r | |
351 | .Nm\r | |
352 | utility will report duplicate and damaged packets.\r | |
353 | Duplicate packets should never occur when pinging a unicast address,\r | |
354 | and seem to be caused by\r | |
355 | inappropriate link-level retransmissions.\r | |
356 | Duplicates may occur in many situations and are rarely\r | |
357 | (if ever)\r | |
358 | a good sign, although the presence of low levels of duplicates may not\r | |
359 | always be cause for alarm.\r | |
360 | Duplicates are expected when pinging a broadcast or multicast address,\r | |
361 | since they are not really duplicates but replies from different hosts\r | |
362 | to the same request.\r | |
363 | .Pp\r | |
364 | Damaged packets are obviously serious cause for alarm and often\r | |
365 | indicate broken hardware somewhere in the\r | |
366 | .Nm\r | |
367 | packet's path (in the network or in the hosts).\r | |
368 | .Sh TRYING DIFFERENT DATA PATTERNS\r | |
369 | The\r | |
370 | (inter)network\r | |
371 | layer should never treat packets differently depending on the data\r | |
372 | contained in the data portion.\r | |
373 | Unfortunately, data-dependent problems have been known to sneak into\r | |
374 | networks and remain undetected for long periods of time.\r | |
375 | In many cases the particular pattern that will have problems is something\r | |
376 | that does not have sufficient\r | |
377 | .Dq transitions ,\r | |
378 | such as all ones or all zeros, or a pattern right at the edge, such as\r | |
379 | almost all zeros.\r | |
380 | It is not\r | |
381 | necessarily enough to specify a data pattern of all zeros (for example)\r | |
382 | on the command line because the pattern that is of interest is\r | |
383 | at the data link level, and the relationship between what you type and\r | |
384 | what the controllers transmit can be complicated.\r | |
385 | .Pp\r | |
386 | This means that if you have a data-dependent problem you will probably\r | |
387 | have to do a lot of testing to find it.\r | |
388 | If you are lucky, you may manage to find a file that either\r | |
389 | cannot\r | |
390 | be sent across your network or that takes much longer to transfer than\r | |
391 | other similar length files.\r | |
392 | You can then examine this file for repeated patterns that you can test\r | |
393 | using the\r | |
394 | .Fl p\r | |
395 | option of\r | |
396 | .Nm .\r | |
397 | .Sh TTL DETAILS\r | |
398 | The\r | |
399 | .Tn TTL\r | |
400 | value of an IP packet represents the maximum number of IP routers\r | |
401 | that the packet can go through before being thrown away.\r | |
402 | In current practice you can expect each router in the Internet to decrement\r | |
403 | the\r | |
404 | .Tn TTL\r | |
405 | field by exactly one.\r | |
406 | .Pp\r | |
407 | The\r | |
408 | .Tn TCP/IP\r | |
409 | specification recommends setting the\r | |
410 | .Tn TTL\r | |
411 | field for\r | |
412 | .Tn IP\r | |
413 | packets to 64, but many systems use smaller values\r | |
414 | .No ( Bx 4.3\r | |
415 | uses 30,\r | |
416 | .Bx 4.2\r | |
417 | used 15).\r | |
418 | .Pp\r | |
419 | The maximum possible value of this field is 255, and most\r | |
420 | .Ux\r | |
421 | systems set\r | |
422 | the\r | |
423 | .Tn TTL\r | |
424 | field of\r | |
425 | .Tn ICMP ECHO_REQUEST\r | |
426 | packets to 255.\r | |
427 | This is why you will find you can\r | |
428 | .Dq ping\r | |
429 | some hosts, but not reach them with\r | |
430 | .Xr telnet 1\r | |
431 | or\r | |
432 | .Xr ftp 1 .\r | |
433 | .Pp\r | |
434 | In normal operation\r | |
435 | .Nm\r | |
436 | prints the ttl value from the packet it receives.\r | |
437 | When a remote system receives a ping packet, it can do one of three things\r | |
438 | with the\r | |
439 | .Tn TTL\r | |
440 | field in its response:\r | |
441 | .Bl -bullet\r | |
442 | .It\r | |
443 | Not change it; this is what\r | |
444 | .Bx\r | |
445 | systems did before the\r | |
446 | .Bx 4.3 tahoe\r | |
447 | release.\r | |
448 | In this case the\r | |
449 | .Tn TTL\r | |
450 | value in the received packet will be 255 minus the\r | |
451 | number of routers in the round-trip path.\r | |
452 | .It\r | |
453 | Set it to 255; this is what current\r | |
454 | .Bx\r | |
455 | systems do.\r | |
456 | In this case the\r | |
457 | .Tn TTL\r | |
458 | value in the received packet will be 255 minus the\r | |
459 | number of routers in the path\r | |
460 | .Em from\r | |
461 | the remote system\r | |
462 | .Em to\r | |
463 | the\r | |
464 | .Nm Ns Em ing\r | |
465 | host.\r | |
466 | .It\r | |
467 | Set it to some other value.\r | |
468 | Some machines use the same value for\r | |
469 | .Tn ICMP\r | |
470 | packets that they use for\r | |
471 | .Tn TCP\r | |
472 | packets, for example either 30 or 60.\r | |
473 | Others may use completely wild values.\r | |
474 | .El\r | |
475 | .Sh RETURN VALUES\r | |
476 | The\r | |
477 | .Nm\r | |
478 | utility returns an exit status of zero if at least one response was\r | |
479 | heard from the specified\r | |
480 | .Ar host ;\r | |
481 | a status of two if the transmission was successful but no responses\r | |
482 | were received; or another value\r | |
483 | (from\r | |
484 | .In sysexits.h )\r | |
485 | if an error occurred.\r | |
486 | .Sh SEE ALSO\r | |
487 | .Xr netstat 1 ,\r | |
488 | .Xr ifconfig 8 ,\r | |
489 | .Xr routed 8 ,\r | |
490 | .Xr traceroute 8\r | |
491 | .Sh HISTORY\r | |
492 | The\r | |
493 | .Nm\r | |
494 | utility appeared in\r | |
495 | .Bx 4.3 .\r | |
496 | .Sh AUTHORS\r | |
497 | The original\r | |
498 | .Nm\r | |
499 | utility was written by\r | |
500 | .An Mike Muuss\r | |
501 | while at the US Army Ballistics\r | |
502 | Research Laboratory.\r | |
503 | .Sh BUGS\r | |
504 | Many Hosts and Gateways ignore the\r | |
505 | .Tn RECORD_ROUTE\r | |
506 | option.\r | |
507 | .Pp\r | |
508 | The maximum IP header length is too small for options like\r | |
509 | .Tn RECORD_ROUTE\r | |
510 | to be completely useful.\r | |
511 | .No There Ap s\r | |
512 | not much that can be done about this, however.\r | |
513 | .Pp\r | |
514 | Flood pinging is not recommended in general, and flood pinging the\r | |
515 | broadcast address should only be done under very controlled conditions.\r | |
516 | .Pp\r | |
517 | The\r | |
518 | .Fl v\r | |
519 | option is not worth much on busy hosts.\r |