xref: /netbsd-src/sbin/ping6/ping6.8 (revision fcb4d9ad2eae4303fac77030400fd64a19b2281c)
1.\"	$NetBSD: ping6.8,v 1.34 2021/06/07 22:13:34 dholland Exp $
2.\"	$KAME: ping6.8,v 1.57 2002/05/26 13:18:25 itojun Exp $
3.\"
4.\" Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
5.\" All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\" 1. Redistributions of source code must retain the above copyright
11.\"    notice, this list of conditions and the following disclaimer.
12.\" 2. Redistributions in binary form must reproduce the above copyright
13.\"    notice, this list of conditions and the following disclaimer in the
14.\"    documentation and/or other materials provided with the distribution.
15.\" 3. Neither the name of the project nor the names of its contributors
16.\"    may be used to endorse or promote products derived from this software
17.\"    without specific prior written permission.
18.\"
19.\" THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
20.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
23.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29.\" SUCH DAMAGE.
30.\"
31.Dd June 7, 2021
32.Dt PING6 8
33.Os
34.Sh NAME
35.Nm ping6
36.Nd send ICMPv6 ECHO_REQUEST packets to network hosts
37.Sh SYNOPSIS
38.Nm ping6
39.\" without IPsec, or new IPsec
40.Op Fl dfHmnNoqtvwW
41.\" old IPsec
42.\" .Op Fl AdEfnNqRtvwW
43.Op Fl a Ar addrtype
44.Op Fl b Ar bufsiz
45.Op Fl c Ar count
46.Op Fl g Ar gateway
47.Op Fl h Ar hoplimit
48.Op Fl I Ar interface
49.Op Fl i Ar wait
50.Op Fl l Ar preload
51.\" new IPsec
52.Op Fl P Ar policy
53.Op Fl p Ar pattern
54.Op Fl S Ar sourceaddr
55.Op Fl s Ar packetsize
56.Op Fl X Ar deadline
57.Op Fl x Ar maxwait
58.Ar host
59.Sh DESCRIPTION
60.Nm
61uses the ICMPv6 protocol's mandatory
62.Dv ICMP6_ECHO_REQUEST
63datagram to elicit an
64.Dv ICMP6_ECHO_REPLY
65from a host or gateway.
66.Dv ICMP6_ECHO_REQUEST
67datagrams (``pings'') have an IPv6 header,
68and ICMPv6 header formatted as documented in RFC 2463.
69The options are as follows:
70.Bl -tag -width Ds
71.\" old IPsec
72.\" .It Fl A
73.\" Enables transport-mode IPsec authentication header
74.\" .Pq experimental .
75.It Fl a Ar addrtype
76Generate ICMPv6 Node Information Node Addresses query, rather than echo-request.
77.Ar addrtype
78must be a string constructed of the following characters.
79.Bl -tag -width Ds -compact
80.It Ic a
81requests unicast addresses from all of the responder's interfaces.
82If the character is omitted,
83only those addresses which belong to the interface which has the
84responder's address are requests.
85.It Ic c
86requests responder's IPv4-compatible and IPv4-mapped addresses.
87.It Ic g
88requests responder's global-scope addresses.
89.It Ic s
90requests responder's site-local addresses.
91.It Ic l
92requests responder's link-local addresses.
93.It Ic A
94requests responder's anycast addresses.
95Without this character, the responder will return unicast addresses only.
96With this character, the responder will return anycast addresses only.
97Note that the specification does not specify how to get responder's
98anycast addresses.
99This is an experimental option.
100.El
101.It Fl b Ar bufsiz
102Set socket buffer size.
103.It Fl c Ar count
104Stop after sending
105.Pq and receiving
106.Ar count
107.Dv ECHO_RESPONSE
108packets.
109.It Fl d
110Set the
111.Dv SO_DEBUG
112option on the socket being used.
113.\" .It Fl E
114.\" Enables transport-mode IPsec encapsulated security payload
115.\" .Pq experimental .
116.It Fl f
117Flood ping.
118Outputs packets as fast as they come back or one hundred times per second,
119whichever is more.
120For every
121.Dv ECHO_REQUEST
122sent a period
123.Dq \&.
124is printed, while for every
125.Dv ECHO_REPLY
126received a backspace is printed.
127This provides a rapid display of how many packets are being dropped.
128Only the super-user may use this option.
129.Bf -emphasis
130This can be very hard on a network and should be used with caution.
131.Ef
132.It Fl g Ar gateway
133Specifies to use
134.Ar gateway
135as the next hop to the destination.
136The gateway must be a neighbor of the sending node.
137.It Fl H
138Specifies to try reverse-lookup of IPv6 addresses.
139The
140.Nm
141command does not try reverse-lookup unless the option is specified.
142.It Fl h Ar hoplimit
143Set the IPv6 hoplimit.
144.It Fl I Ar interface
145Source packets with the given interface address.
146This flag applies if the ping destination is a multicast address,
147or link-local/site-local unicast address.
148.It Fl i Ar wait
149Wait
150.Ar wait
151seconds
152.Em between sending each packet .
153The default is to wait for one second between each packet.
154This option is incompatible with the
155.Fl f
156option.
157.It Fl l Ar preload
158If
159.Ar preload
160is specified,
161.Nm
162sends that many packets as fast as possible before falling into its normal
163mode of behavior.
164Only the super-user may use this option.
165.It Fl m
166By default,
167.Nm
168asks the kernel to fragment packets to fit into the minimum IPv6 MTU.
169.Fl m
170will suppress the behavior in the following two levels:
171when the option is specified once, the behavior will be disabled for
172unicast packets.
173When the option is specified more than once, it will be disabled for both
174unicast and multicast packets.
175.It Fl N
176Probe node information multicast group
177.Pq Li ff02::2:xxxx:xxxx .
178.Ar host
179must be string hostname of the target
180.Pq must not be a numeric IPv6 address .
181Node information multicast group will be computed based on given
182.Ar host ,
183and will be used as the final destination.
184Since node information multicast group is a link-local multicast group,
185outgoing interface needs to be specified by
186.Fl I
187option.
188.It Fl n
189Numeric output only.
190No attempt will be made to lookup symbolic names from addresses in the reply.
191.It Fl o
192Exit successfully after receiving one reply packet.
193.It Fl P Ar policy
194.Ar policy
195specifies IPsec policy to be used for the probe.
196.It Fl p Ar pattern
197You may specify up to 16
198.Dq pad
199bytes to fill out the packet you send.
200This is useful for diagnosing data-dependent problems in a network.
201For example,
202.Dq Li \-p ff
203will cause the sent packet to be filled with all
204ones.
205Note that for IPv6 there is no fill space by default so it is
206necessary to also use the
207.Fl s
208option to expand the packet.
209.\" new IPsec
210.It Fl q
211Quiet output.
212Nothing is displayed except the summary lines at startup time and
213when finished.
214.It Fl S Ar sourceaddr
215Specifies the source address of request packets.
216The source address must be one of the unicast addresses of the sending node,
217and must be numeric.
218.It Fl s Ar packetsize
219Specifies the number of data bytes to be sent.
220The default is 56, which translates into 64 ICMP data bytes when combined
221with the 8 bytes of ICMP header data.
222You may need to specify
223.Fl b
224as well to extend socket buffer size.
225.It Fl t
226Generate ICMPv6 Node Information supported query types query,
227rather than echo-request.
228.Fl s
229has no effect if
230.Fl t
231is specified.
232.It Fl v
233Verbose output.
234ICMP packets other than
235.Dv ECHO_RESPONSE
236that are received are listed.
237.It Fl W
238Same as
239.Fl w ,
240but with old packet format based on 03 draft.
241This option is present for backward compatibility.
242.Fl s
243has no effect if
244.Fl w
245is specified.
246.It Fl w
247Generate ICMPv6 Node Information DNS Name query, rather than echo-request.
248.Fl s
249has no effect if
250.Fl w
251is specified.
252.It Fl X Ar deadline
253Specify a timeout, in seconds, before ping exits regardless of
254how many packets have been received.
255.It Ar host
256IPv6 address of the final destination node.
257.It Fl x Ar maxwait
258Time in milliseconds to wait for a reply for each packet sent.
259.El
260.Pp
261When using
262.Nm
263for fault isolation, it should first be run on the local host, to verify
264that the local network interface is up and running.
265Then, hosts and gateways further and further away should be
266.Dq pinged .
267Round-trip times and packet loss statistics are computed.
268If duplicate packets are received, they are not included in the packet
269loss calculation, although the round trip time of these packets is used
270in calculating the round-trip time statistics.
271When the specified number of packets have been sent
272.Pq and received
273or if the program is terminated with a
274.Dv SIGINT ,
275a brief summary is displayed, showing the number of packets sent and
276received, and the minimum, maximum, mean, and standard deviation of
277the round-trip times.
278.Pp
279This program is intended for use in network testing, measurement and
280management.
281Because of the load it can impose on the network, it is unwise to use
282.Nm
283during normal operations or from automated scripts.
284.\" .Sh ICMP PACKET DETAILS
285.\" An IP header without options is 20 bytes.
286.\" An
287.\" ICMP
288.\" .Dv ECHO_REQUEST
289.\" packet contains an additional 8 bytes worth of
290.\" ICMP
291.\" header followed by an arbitrary amount of data.
292.\" When a
293.\" .Ar packetsize
294.\" is given, this indicated the size of this extra piece of data
295.\" .Pq the default is 56 .
296.\" Thus the amount of data received inside of an IP packet of type
297.\" ICMP
298.\" .Dv ECHO_REPLY
299.\" will always be 8 bytes more than the requested data space
300.\" .Pq the ICMP header .
301.\" .Pp
302.\" If the data space is at least eight bytes large,
303.\" .Nm
304.\" uses the first eight bytes of this space to include a timestamp which
305.\" it uses in the computation of round trip times.
306.\" If less than eight bytes of pad are specified, no round trip times are
307.\" given.
308.Sh DUPLICATE AND DAMAGED PACKETS
309.Nm
310will report duplicate and damaged packets.
311Duplicate packets should never occur when pinging a unicast address,
312and seem to be caused by
313inappropriate link-level retransmissions.
314Duplicates may occur in many situations and are rarely
315.Pq if ever
316a good sign, although the presence of low levels of duplicates may not
317always be cause for alarm.
318Duplicates are expected when pinging a multicast address,
319since they are not really duplicates but replies from different hosts
320to the same request.
321.Pp
322Damaged packets are obviously serious cause for alarm and often
323indicate broken hardware somewhere in the
324.Nm
325packet's path
326.Pq in the network or in the hosts .
327.Sh TRYING DIFFERENT DATA PATTERNS
328The
329(inter)network
330layer should never treat packets differently depending on the data
331contained in the data portion.
332Unfortunately, data-dependent problems have been known to sneak into
333networks and remain undetected for long periods of time.
334In many cases the particular pattern that will have problems is something
335that does not have sufficient
336.Dq transitions ,
337such as all ones or all zeros, or a pattern right at the edge, such as
338almost all zeros.
339It is not
340necessarily enough to specify a data pattern of all zeros (for example)
341on the command line because the pattern that is of interest is
342at the data link level, and the relationship between what you type and
343what the controllers transmit can be complicated.
344.Pp
345This means that if you have a data-dependent problem you will probably
346have to do a lot of testing to find it.
347If you are lucky, you may manage to find a file that either
348cannot
349be sent across your network or that takes much longer to transfer than
350other similar length files.
351You can then examine this file for repeated patterns that you can test
352using the
353.Fl p
354option of
355.Nm .
356.Sh EXIT STATUS
357.Nm
358exits with 0 on success (the host is alive),
359and non-zero if the arguments are incorrect or the host is not responding.
360.Sh EXAMPLES
361Normally,
362.Nm
363works just like
364.Xr ping 8
365would work; the following will send ICMPv6 echo request to
366.Li dst.foo.com .
367.Bd -literal -offset indent
368ping6 -n dst.foo.com
369.Ed
370.Pp
371The following will probe hostnames for all nodes on the network link attached to
372.Li wi0
373interface.
374The address
375.Li ff02::1
376is named the link-local all-node multicast address, and the packet would
377reach every node on the network link.
378.Bd -literal -offset indent
379ping6 -w ff02::1%wi0
380.Ed
381.Pp
382The following will probe addresses assigned to the destination node,
383.Li dst.foo.com .
384.Bd -literal -offset indent
385ping6 -a agl dst.foo.com
386.Ed
387.Sh SEE ALSO
388.Xr netstat 1 ,
389.Xr icmp6 4 ,
390.Xr inet6 4 ,
391.Xr ip6 4 ,
392.Xr ifconfig 8 ,
393.Xr ping 8 ,
394.Xr routed 8 ,
395.Xr traceroute 8 ,
396.Xr traceroute6 8
397.Rs
398.%A A. Conta
399.%A S. Deering
400.%T "Internet Control Message Protocol (ICMPv6) for the Internet Protocol Version 6 (IPv6) Specification"
401.%N RFC 2463
402.%D December 1998
403.Re
404.Rs
405.%A Matt Crawford
406.%T "IPv6 Node Information Queries"
407.%N draft-ietf-ipngwg-icmp-name-lookups-09.txt
408.%D May 2002
409.%O work in progress material
410.Re
411.Sh HISTORY
412The
413.Xr ping 8
414command appeared in
415.Bx 4.3 .
416The
417.Nm
418command with IPv6 support first appeared in the WIDE Hydrangea IPv6
419protocol stack kit.
420.Sh BUGS
421.\" except for bsdi
422.Nm
423is intentionally separate from
424.Xr ping 8 .
425