1ping(1M) System Administration Commands ping(1M)
2
3
4
6 ping - send ICMP (ICMP6) ECHO_REQUEST packets to network hosts
7
9 /usr/sbin/ping host [timeout]
10
11
12 /usr/sbin/ping -s [-l | -U] [-abdlLnrRv] [-A addr_family]
13 [-c traffic_class] [-g gateway [-g gateway...]]
14 [-N next_hop_router] [-F flow_label] [-I interval]
15 [-i interface] [-P tos] [-p port] [-t ttl] host
16 [data_size] [npackets]
17
18
20 The utility ping utilizes the ICMP (ICMP6 in IPv6) protocol's
21 ECHO_REQUEST datagram to elicit an ICMP (ICMP6) ECHO_RESPONSE from the
22 specified host or network gateway. If host responds, ping will print:
23
24 host is alive
25
26
27
28
29 on the standard output and exit. Otherwise, after timeout seconds, it
30 will write:
31
32 no answer from host
33
34
35
36
37 The default value of timeout is 20 seconds.
38
39
40 When you specify the s flag, sends one datagram per second (adjust with
41 -I) and prints one line of output for every ECHO_RESPONSE that it
42 receives. ping produces no output if there is no response. In this sec‐
43 ond form, ping computes round trip times and packet loss statistics; it
44 displays a summary of this information upon termination or timeout. The
45 default data_size is 56 bytes, or you can specify a size with the
46 data_size command-line argument. If you specify the optional npackets,
47 ping sends ping requests until it either sends npackets requests or
48 receives npackets replies.
49
50
51 When using ping for fault isolation, first ping the local host to ver‐
52 ify that the local network interface is running.
53
55 The following options are supported:
56
57 -A addr_family Specify the address family of the target host.
58 addr_family can be either inet or inet6.
59 Address family determines which protocol to
60 use. For an argument of inet, IPv4 is used. For
61 inet6, IPv6 is used.
62
63 By default, if the name of a host is provided,
64 not the literal IP address, and a valid IPv6
65 address exists in the name service database,
66 ping will use this address. Otherwise, if the
67 name service database contains an IPv4 address,
68 it will try the IPv4 address.
69
70 Specify the address family inet or inet6 to
71 override the default behavior. If the argument
72 specified is inet, ping will use the IPv4
73 address associated with the host name. If none
74 exists, ping will state that the host is
75 unknown and exit. It does not try to determine
76 if an IPv6 address exists in the name service
77 database.
78
79 If the specified argument is inet6, ping uses
80 the IPv6 address that is associated with the
81 host name. If none exists, ping states that the
82 host is unknown and exits.
83
84
85 -F flow_label Specify the flow label of probe packets. The
86 value must be an integer in the range from 0 to
87 1048575. This option is valid only on IPv6.
88
89
90 -I interval Turn on the statistics mode and specify the
91 interval between successive transmissions. The
92 default is one second. See the discussion of
93 the -s option.
94
95
96 -L Turn off loopback of multicast packets. Nor‐
97 mally, members are in the host group on the
98 outgoing interface, a copy of the multicast
99 packets will be delivered to the local machine.
100
101
102 -N next_hop_router Specify a next-hop router so that the probe
103 packet goes through the specified router along
104 its path to the target host. This option essen‐
105 tially bypasses the system routing table and
106 leaves the probe packet header unmodified. Only
107 one next-hop router can be specified.
108
109
110 -P tos Set the type of service (tos) in probe packets
111 to the specified value. The default is zero.
112 The value must be an integer in the range from
113 0 to 255. Gateways also in the path can route
114 the probe packet differently, depending upon
115 the value of tos that is set in the probe
116 packet. This option is valid only on IPv4.
117
118
119 -R Record route. Sets the IPv4 record route
120 option, which stores the route of the packet
121 inside the IPv4 header. The contents of the
122 record route are only printed if the -v and -s
123 options are given. They are only set on return
124 packets if the target host preserves the record
125 route option across echos, or the -l option is
126 given. This option is valid only on IPv4.
127
128
129 -U Send UDP packets instead of ICMP (ICMP6) pack‐
130 ets. ping sends UDP packets to consecutive
131 ports expecting to receive back ICMP (ICMP6)
132 PORT_UNREACHABLE from the target host.
133
134
135 -a ping all addresses, both IPv4 and IPv6, of the
136 multihomed destination. The output appears as
137 if ping has been run once for each IP address
138 of the destination. If this option is used
139 together with -A, ping probes only the
140 addresses that are of the specified address
141 family. When used with the -s option and npack‐
142 ets is not specified, ping continuously probes
143 the destination addresses in a round robin
144 fashion. If npackets is specified, ping sends
145 npackets number of probes to each IP address of
146 the destination and then exits.
147
148
149 -b Bypass the global IPsec policy and send and
150 receive packets in the clear for this connec‐
151 tion only. This option can be used to trou‐
152 bleshoot network connectivity independent of
153 IPsec. Because this option bypasses system-wide
154 policy for this connection, it can only be used
155 by superuser or a user granted the sys_net_con‐
156 fig privilege.
157
158
159 -c traffic_class Specify the traffic class of probe packets. The
160 value must be an integer in the range from 0 to
161 255. Gateways along the path can route the
162 probe packet differently, depending upon the
163 value of traffic_class set in the probe packet.
164 This option is valid only on IPv6.
165
166
167 -d Set the SO_DEBUG socket option.
168
169
170 -g gateway Specify a loose source route gateway so that
171 the probe packet goes through the specified
172 host along the path to the target host. The
173 maximum number of gateways is 8 for IPv4 and
174 127 for IPv6. Note that some factors such as
175 the link MTU can further limit the number of
176 gateways for IPv6.
177
178
179 -i interface_address Specify the outgoing interface address to use
180 for multicast packets for IPv4 and both multi‐
181 cast and unicast packets for IPv6. The default
182 interface address for multicast packets is
183 determined from the (unicast) routing tables.
184 interface_address can be a literal IP address,
185 for example, 10.123.100.99, or an interface
186 name, for example, eri0, or an interface index,
187 for example 2.
188
189
190 -l Use to send the probe packet to the given host
191 and back again using loose source routing. Usu‐
192 ally specified with the -R option. If any gate‐
193 ways are specified using -g, they are visited
194 twice, both to and from the destination. This
195 option is ignored if the -U option is used.
196
197
198 -n Show network addresses as numbers. ping nor‐
199 mally does a reverse name lookup on the IP
200 addresses it extracts from the packets
201 received. The -n option blocks the reverse
202 lookup, so ping prints IP addresses instead of
203 host names.
204
205
206 -p port Set the base UDP port number used in probes.
207 This option is used with the -U option. The
208 default base port number is 33434. The ping
209 utility starts setting the destination port
210 number of UDP packets to this base and incre‐
211 ments it by one at each probe.
212
213
214 -r Bypass the normal routing tables and send
215 directly to a host on an attached network. If
216 the host is not on a directly attached network,
217 an error is returned. This option can be used
218 to ping a local host through an interface that
219 has been dropped by the router daemon. See
220 in.routed(1M).
221
222
223 -s Send one datagram per second and collect sta‐
224 tistics.
225
226
227 -t ttl Specify the IPv4 time to live, or IPv6 hop
228 limit, for unicast and multicast packets. The
229 default time to live (hop limit) for unicast
230 packets can be set with the ndd module,
231 /dev/icmp, using the icmp_ipv4_ttl variable for
232 IPv4 and the icmp_ipv6_hoplimit variable for
233 IPv6. The default time to live (hop limit) for
234 multicast is one hop. See EXAMPLES. For further
235 information, seendd(1M).
236
237
238 -v Verbose output. List any ICMP (ICMP6) packets,
239 other than replies from the target host.
240
241
243 host The network host
244
245
247 Example 1 Using ping With IPv6
248
249
250 This example shows ping sending probe packets to all the IPv6 addresses
251 of the host xyz, one at a time. It sends an ICMP6 ECHO_REQUEST every
252 second until the user interrupts it.
253
254
255 istanbul% ping -s -A inet6 -a xyz
256 PING xyz: 56 data bytes
257 64 bytes from xyz (4::114:a00:20ff:ab3d:83ed): icmp_seq=0. time=0.479 ms
258 64 bytes from xyz (fec0::114:a00:20ff:ab3d:83ed): icmp_seq=1. time=0.843 ms
259 64 bytes from xyz (4::114:a00:20ff:ab3d:83ed): icmp_seq=2. time=0.516 ms
260 64 bytes from xyz (fec0::114:a00:20ff:ab3d:83ed): icmp_seq=3. time=4.943 ms
261 64 bytes from xyz (4::114:a00:20ff:ab3d:83ed): icmp_seq=4. time=0.485 ms
262 64 bytes from xyz (fec0::114:a00:20ff:ab3d:83ed): icmp_seq=5. time=2.201 ms
263 ^C
264 ----xyz PING Statistics----
265 6 packets transmitted, 6 packets received, 0% packet loss
266 round-trip (ms) min/avg/stddev = 0.479/1.583/4.943/1.823
267
268
269
270 Example 2 Using ndd to Set the icmp_ipv6_hoplimit
271
272
273 This example shows the ndd module, /dev/icmp, used to set the
274 icmp_ipv6_hoplimit.
275
276
277 # ndd -set /dev/icmp icmp_ipv6_hoplimit 100
278
279
280
282 The following exit values are returned:
283
284 0 Successful operation; the machine is alive.
285
286
287 non-zero An error has occurred. Either a malformed argument has been
288 specified, or the machine was not alive.
289
290
292 See attributes(5) for descriptions of the following attributes:
293
294
295
296
297 ┌─────────────────────────────┬─────────────────────────────┐
298 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
299 ├─────────────────────────────┼─────────────────────────────┤
300 │Availability │SUNWbip │
301 └─────────────────────────────┴─────────────────────────────┘
302
304 ifconfig(1M), in.routed(1M), ndd(1M), netstat(1M), rpcinfo(1M), tracer‐
305 oute(1M), attributes(5), icmp(7P), icmp6(7P)
306
307
308
309SunOS 5.11 7 Sep 2006 ping(1M)