]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sbin/ping6/ping6.8
Use %ju and cast to (uintmax_t) to avoid using PRI* macros.
[FreeBSD/FreeBSD.git] / sbin / ping6 / ping6.8
1 .\"     $KAME: ping6.8,v 1.58 2003/06/20 12:00:22 itojun Exp $
2 .\"
3 .\" Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
4 .\" All rights reserved.
5 .\"
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
8 .\" are met:
9 .\" 1. Redistributions of source code must retain the above copyright
10 .\"    notice, this list of conditions and the following disclaimer.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\"    notice, this list of conditions and the following disclaimer in the
13 .\"    documentation and/or other materials provided with the distribution.
14 .\" 3. Neither the name of the project nor the names of its contributors
15 .\"    may be used to endorse or promote products derived from this software
16 .\"    without specific prior written permission.
17 .\"
18 .\" THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
19 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
22 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 .\" SUCH DAMAGE.
29 .\"
30 .\" $FreeBSD$
31 .\"
32 .Dd September 10, 2020
33 .Dt PING6 8
34 .Os
35 .Sh NAME
36 .Nm ping6
37 .Nd send
38 .Tn ICMPv6 ECHO_REQUEST
39 packets to network hosts
40 .Sh SYNOPSIS
41 .Nm
42 .\" without ipsec, or new ipsec
43 .Op Fl aAdDfHnNoOquvyY
44 .\" old ipsec
45 .\" .Op Fl ADdEfmnNqRtvwW
46 .Bk -words
47 .Op Fl b Ar bufsiz
48 .Ek
49 .Bk -words
50 .Op Fl c Ar count
51 .Ek
52 .Bk -words
53 .Op Fl e Ar gateway
54 .Ek
55 .Bk -words
56 .Op Fl I Ar interface
57 .Ek
58 .Bk -words
59 .Op Fl i Ar wait
60 .Ek
61 .Bk -words
62 .Op Fl k Ar addrtype
63 .Ek
64 .Bk -words
65 .Op Fl l Ar preload
66 .Ek
67 .Bk -words
68 .Op Fl m Ar hoplimit
69 .Ek
70 .Bk -words
71 .\" new ipsec
72 .Op Fl P Ar policy
73 .Ek
74 .Bk -words
75 .Op Fl p Ar pattern
76 .Ek
77 .Bk -words
78 .Op Fl S Ar sourceaddr
79 .Ek
80 .Bk -words
81 .Op Fl s Ar packetsize
82 .Ek
83 .Bk -words
84 .Op Fl t Ar timeout
85 .Ek
86 .Bk -words
87 .Op Fl W Ar waittime
88 .Ek
89 .Bk -words
90 .Op Fl z Ar tclass
91 .Ek
92 .Bk -words
93 .Op Ar hops ...
94 .Ek
95 .Bk -words
96 .Ar host
97 .Ek
98 .Sh DESCRIPTION
99 The
100 .Nm
101 utility uses the
102 .Tn ICMPv6
103 protocol's mandatory
104 .Tn ICMP6_ECHO_REQUEST
105 datagram to elicit an
106 .Tn ICMP6_ECHO_REPLY
107 from a host or gateway.
108 .Tn ICMP6_ECHO_REQUEST
109 datagrams (``pings'') have an IPv6 header,
110 and
111 .Tn ICMPv6
112 header formatted as documented in RFC2463.
113 The options are as follows:
114 .Bl -tag -width Ds
115 .\" old ipsec
116 .\" .It Fl Z
117 .\" Enables transport-mode IPsec authentication header
118 .\" (experimental).
119 .It Fl k Ar addrtype
120 Generate ICMPv6 Node Information Node Addresses query, rather than echo-request.
121 .Ar addrtype
122 must be a string constructed of the following characters.
123 .Bl -tag -width Ds -compact
124 .It Ic a
125 requests unicast addresses from all of the responder's interfaces.
126 If the character is omitted,
127 only those addresses which belong to the interface which has the
128 responder's address are requests.
129 .It Ic c
130 requests responder's IPv4-compatible and IPv4-mapped addresses.
131 .It Ic g
132 requests responder's global-scope addresses.
133 .It Ic s
134 requests responder's site-local addresses.
135 .It Ic l
136 requests responder's link-local addresses.
137 .It Ic A
138 requests responder's anycast addresses.
139 Without this character, the responder will return unicast addresses only.
140 With this character, the responder will return anycast addresses only.
141 Note that the specification does not specify how to get responder's
142 anycast addresses.
143 This is an experimental option.
144 .El
145 .It Fl b Ar bufsiz
146 Set socket buffer size.
147 .It Fl c Ar count
148 Stop after sending
149 (and receiving)
150 .Ar count
151 .Tn ECHO_RESPONSE
152 packets.
153 .It Fl D
154 Disable IPv6 fragmentation.
155 .It Fl d
156 Set the
157 .Dv SO_DEBUG
158 option on the socket being used.
159 .\" .It Fl E
160 .\" Enables transport-mode IPsec encapsulated security payload
161 .\" (experimental).
162 .It Fl f
163 Flood ping.
164 Outputs packets as fast as they come back or one hundred times per second,
165 whichever is more.
166 For every
167 .Tn ECHO_REQUEST
168 sent a period
169 .Dq \&.
170 is printed, while for every
171 .Tn ECHO_REPLY
172 received a backspace is printed.
173 This provides a rapid display of how many packets are being dropped.
174 Only the super-user may use this option.
175 .Bf -emphasis
176 This can be very hard on a network and should be used with caution.
177 .Ef
178 .It Fl e Ar gateway
179 Specifies to use
180 .Ar gateway
181 as the next hop to the destination.
182 The gateway must be a neighbor of the sending node.
183 .It Fl H
184 Specifies to try reverse-lookup of IPv6 addresses.
185 The
186 .Nm
187 utility does not try reverse-lookup unless the option is specified.
188 .It Fl m Ar hoplimit
189 Set the IPv6 hoplimit.
190 .It Fl I Ar interface
191 Source packets with the given interface address.
192 This flag applies if the ping destination is a multicast address,
193 or link-local/site-local unicast address.
194 .It Fl i Ar wait
195 Wait
196 .Ar wait
197 seconds
198 .Em between sending each packet .
199 The default is to wait for one second between each packet.
200 This option is incompatible with the
201 .Fl f
202 option.
203 .It Fl W Ar waittime
204 Time in milliseconds to wait for a reply for each packet sent.
205 If a reply arrives later,
206 the packet is not printed as replied,
207 but considered as replied when calculating statistics.
208 .It Fl t Ar timeout
209 Specify a timeout,
210 in seconds,
211 before ping exits regardless of how many packets have been received.
212 .It Fl l Ar preload
213 If
214 .Ar preload
215 is specified,
216 .Nm
217 sends that many packets as fast as possible before falling into its normal
218 mode of behavior.
219 Only the super-user may use this option.
220 .It Fl u
221 By default,
222 .Nm
223 asks the kernel to fragment packets to fit into the minimum IPv6 MTU.
224 The
225 .Fl u
226 option
227 will suppress the behavior in the following two levels:
228 when the option is specified once, the behavior will be disabled for
229 unicast packets.
230 When the option is more than once, it will be disabled for both
231 unicast and multicast packets.
232 .It Fl n
233 Numeric output only.
234 No attempt will be made to lookup symbolic names from addresses in the reply.
235 .It Fl N
236 Probe node information multicast group address
237 .Pq Li ff02::2:ffxx:xxxx .
238 .Ar host
239 must be string hostname of the target
240 (must not be a numeric IPv6 address).
241 Node information multicast group will be computed based on given
242 .Ar host ,
243 and will be used as the final destination.
244 Since node information multicast group is a link-local multicast group,
245 outgoing interface needs to be specified by
246 .Fl I
247 option.
248 .Pp
249 When specified twice, the address
250 .Pq Li ff02::2:xxxx:xxxx
251 is used instead.
252 The former is in RFC 4620, the latter is in an old Internet Draft
253 draft-ietf-ipngwg-icmp-name-lookup.
254 Note that KAME-derived implementations including
255 .Fx
256 use the latter.
257 .It Fl o
258 Exit successfully after receiving one reply packet.
259 .It Fl p Ar pattern
260 You may specify up to 16
261 .Dq pad
262 bytes to fill out the packet you send.
263 This is useful for diagnosing data-dependent problems in a network.
264 For example,
265 .Dq Li \-p ff
266 will cause the sent packet to be filled with all
267 ones.
268 .\" new ipsec
269 .It Fl P Ar policy
270 .Ar policy
271 specifies IPsec policy to be used for the probe.
272 .It Fl q
273 Quiet output.
274 Nothing is displayed except the summary lines at startup time and
275 when finished.
276 .It Fl a
277 Audible.
278 Include a bell
279 .Tn ( ASCII
280 0x07)
281 character in the output when any packet is received.
282 .It Fl A
283 Audible.
284 Output a bell
285 .Tn ( ASCII
286 0x07)
287 character when no packet is received before the next packet
288 is transmitted.
289 To cater for round-trip times that are longer than the interval
290 between transmissions, further missing packets cause a bell only
291 if the maximum number of unreceived packets has increased.
292 .It Fl S Ar sourceaddr
293 Specifies the source address of request packets.
294 The source address must be one of the unicast addresses of the sending node,
295 and must be numeric.
296 .It Fl s Ar packetsize
297 Specifies the number of data bytes to be sent.
298 The default is 56, which translates into 64
299 .Tn ICMP
300 data bytes when combined
301 with the 8 bytes of
302 .Tn ICMP
303 header data.
304 You may need to specify
305 .Fl b
306 as well to extend socket buffer size.
307 .It Fl O
308 Generate ICMPv6 Node Information supported query types query,
309 rather than echo-request.
310 .Fl s
311 has no effect if
312 .Fl O
313 is specified.
314 .It Fl v
315 Verbose output.
316 .Tn ICMP
317 packets other than
318 .Tn ECHO_RESPONSE
319 that are received are listed.
320 .It Fl y
321 Generate ICMPv6 Node Information DNS Name query, rather than echo-request.
322 .Fl s
323 has no effect if
324 .Fl y
325 is specified.
326 .It Fl Y
327 Same as
328 .Fl y ,
329 but with old packet format based on 03 draft.
330 This option is present for backward compatibility.
331 .Fl s
332 has no effect if
333 .Fl y
334 is specified.
335 .It Fl z Ar tclass
336 Use the specified traffic class when sending.
337 .It Ar hops
338 IPv6 addresses for intermediate nodes,
339 which will be put into type 0 routing header.
340 .It Ar host
341 IPv6 address of the final destination node.
342 .El
343 .Pp
344 When using
345 .Nm
346 for fault isolation, it should first be run on the local host, to verify
347 that the local network interface is up and running.
348 Then, hosts and gateways further and further away should be
349 .Dq pinged .
350 Round-trip times and packet loss statistics are computed.
351 If duplicate packets are received, they are not included in the packet
352 loss calculation, although the round trip time of these packets is used
353 in calculating the round-trip time statistics.
354 When the specified number of packets have been sent
355 (and received)
356 or if the program is terminated with a
357 .Dv SIGINT ,
358 a brief summary is displayed, showing the number of packets sent and
359 received, and the minimum, mean, maximum, and standard deviation of
360 the round-trip times.
361 .Pp
362 If
363 .Nm
364 receives a
365 .Dv SIGINFO
366 (see the
367 .Cm status
368 argument for
369 .Xr stty 1 )
370 signal, the current number of packets sent and received, and the
371 minimum, mean, maximum, and standard deviation of the round-trip times
372 will be written to the standard output in the same format as the
373 standard completion message.
374 .Pp
375 This program is intended for use in network testing, measurement and
376 management.
377 Because of the load it can impose on the network, it is unwise to use
378 .Nm
379 during normal operations or from automated scripts.
380 .\" .Sh ICMP PACKET DETAILS
381 .\" An IP header without options is 20 bytes.
382 .\" An
383 .\" .Tn ICMP
384 .\" .Tn ECHO_REQUEST
385 .\" packet contains an additional 8 bytes worth of
386 .\" .Tn ICMP
387 .\" header followed by an arbitrary amount of data.
388 .\" When a
389 .\" .Ar packetsize
390 .\" is given, this indicated the size of this extra piece of data
391 .\" (the default is 56).
392 .\" Thus the amount of data received inside of an IP packet of type
393 .\" .Tn ICMP
394 .\" .Tn ECHO_REPLY
395 .\" will always be 8 bytes more than the requested data space
396 .\" (the
397 .\" .Tn ICMP
398 .\" header).
399 .\" .Pp
400 .\" If the data space is at least eight bytes large,
401 .\" .Nm
402 .\" uses the first eight bytes of this space to include a timestamp which
403 .\" it uses in the computation of round trip times.
404 .\" If less than eight bytes of pad are specified, no round trip times are
405 .\" given.
406 .Sh DUPLICATE AND DAMAGED PACKETS
407 The
408 .Nm
409 utility will report duplicate and damaged packets.
410 Duplicate packets should never occur when pinging a unicast address,
411 and seem to be caused by
412 inappropriate link-level retransmissions.
413 Duplicates may occur in many situations and are rarely
414 (if ever)
415 a good sign, although the presence of low levels of duplicates may not
416 always be cause for alarm.
417 Duplicates are expected when pinging a broadcast or multicast address,
418 since they are not really duplicates but replies from different hosts
419 to the same request.
420 .Pp
421 Damaged packets are obviously serious cause for alarm and often
422 indicate broken hardware somewhere in the
423 .Nm
424 packet's path
425 (in the network or in the hosts).
426 .Sh TRYING DIFFERENT DATA PATTERNS
427 The
428 (inter)network
429 layer should never treat packets differently depending on the data
430 contained in the data portion.
431 Unfortunately, data-dependent problems have been known to sneak into
432 networks and remain undetected for long periods of time.
433 In many cases the particular pattern that will have problems is something
434 that does not have sufficient
435 .Dq transitions ,
436 such as all ones or all zeros, or a pattern right at the edge, such as
437 almost all zeros.
438 It is not
439 necessarily enough to specify a data pattern of all zeros (for example)
440 on the command line because the pattern that is of interest is
441 at the data link level, and the relationship between what you type and
442 what the controllers transmit can be complicated.
443 .Pp
444 This means that if you have a data-dependent problem you will probably
445 have to do a lot of testing to find it.
446 If you are lucky, you may manage to find a file that either
447 cannot
448 be sent across your network or that takes much longer to transfer than
449 other similar length files.
450 You can then examine this file for repeated patterns that you can test
451 using the
452 .Fl p
453 option of
454 .Nm .
455 .Sh EXIT STATUS
456 The
457 .Nm
458 utility returns 0 on success (the host is alive),
459 2 if the transmission was successful but no responses were received,
460 any other non-zero value if the arguments are incorrect or
461 another error has occurred.
462 .Sh EXAMPLES
463 Normally,
464 .Nm
465 works just like
466 .Xr ping 8
467 would work; the following will send ICMPv6 echo request to
468 .Li dst.foo.com .
469 .Bd -literal -offset indent
470 ping6 -n dst.foo.com
471 .Ed
472 .Pp
473 The following will probe hostnames for all nodes on the network link attached to
474 .Li wi0
475 interface.
476 The address
477 .Li ff02::1
478 is named the link-local all-node multicast address, and the packet would
479 reach every node on the network link.
480 .Bd -literal -offset indent
481 ping6 -y ff02::1%wi0
482 .Ed
483 .Pp
484 The following will probe addresses assigned to the destination node,
485 .Li dst.foo.com .
486 .Bd -literal -offset indent
487 ping6 -k agl dst.foo.com
488 .Ed
489 .Sh SEE ALSO
490 .Xr netstat 1 ,
491 .Xr icmp6 4 ,
492 .Xr inet6 4 ,
493 .Xr ip6 4 ,
494 .Xr ifconfig 8 ,
495 .Xr ping 8 ,
496 .Xr routed 8 ,
497 .Xr traceroute 8 ,
498 .Xr traceroute6 8
499 .Rs
500 .%A A. Conta
501 .%A S. Deering
502 .%T "Internet Control Message Protocol (ICMPv6) for the Internet Protocol Version 6 (IPv6) Specification"
503 .%N RFC2463
504 .%D December 1998
505 .Re
506 .Rs
507 .%A Matt Crawford
508 .%T "IPv6 Node Information Queries"
509 .%N draft-ietf-ipngwg-icmp-name-lookups-09.txt
510 .%D May 2002
511 .%O work in progress material
512 .Re
513 .Sh HISTORY
514 The
515 .Xr ping 8
516 utility appeared in
517 .Bx 4.3 .
518 The
519 .Nm
520 utility with IPv6 support first appeared in the WIDE Hydrangea IPv6
521 protocol stack kit.
522 .Pp
523 IPv6 and IPsec support based on the KAME Project
524 .Pq Pa http://www.kame.net/
525 stack was initially integrated into
526 .Fx 4.0 .
527 .Sh BUGS
528 The
529 .Nm
530 utility
531 is intentionally separate from
532 .Xr ping 8 .
533 .Pp
534 There have been many discussions on why we separate
535 .Nm
536 and
537 .Xr ping 8 .
538 Some people argued that it would be more convenient to uniform the
539 ping command for both IPv4 and IPv6.
540 The followings are an answer to the request.
541 .Pp
542 From a developer's point of view:
543 since the underling raw sockets API is totally different between IPv4
544 and IPv6, we would end up having two types of code base.
545 There would actually be less benefit to uniform the two commands
546 into a single command from the developer's standpoint.
547 .Pp
548 From an operator's point of view: unlike ordinary network applications
549 like remote login tools, we are usually aware of address family when using
550 network management tools.
551 We do not just want to know the reachability to the host, but want to know the
552 reachability to the host via a particular network protocol such as
553 IPv6.
554 Thus, even if we had a unified
555 .Xr ping 8
556 command for both IPv4 and IPv6, we would usually type a
557 .Fl 6
558 or
559 .Fl 4
560 option (or something like those) to specify the particular address family.
561 This essentially means that we have two different commands.