| 1 | <refentry xmlns="http://docbook.org/ns/docbook" version="5.0" |
| 2 | xml:id="man.ping"> |
| 3 | |
| 4 | <refentryinfo> |
| 5 | <title>ping</title> |
| 6 | <productname>iputils</productname> |
| 7 | </refentryinfo> |
| 8 | |
| 9 | <refmeta> |
| 10 | <refentrytitle> |
| 11 | <application>ping</application> |
| 12 | </refentrytitle> |
| 13 | <manvolnum>8</manvolnum> |
| 14 | <refmiscinfo class='manual'>iputils</refmiscinfo> |
| 15 | </refmeta> |
| 16 | |
| 17 | <refnamediv> |
| 18 | <refname>ping</refname> |
| 19 | <refpurpose>send ICMP ECHO_REQUEST to network |
| 20 | hosts</refpurpose> |
| 21 | </refnamediv> |
| 22 | |
| 23 | <refsynopsisdiv> |
| 24 | <cmdsynopsis sepchar=" "> |
| 25 | <command>ping</command> |
| 26 | <arg choice="opt" rep="norepeat"> |
| 27 | <option>-aAbBdCDfhHLnOqrRUvV346</option> |
| 28 | </arg> |
| 29 | <arg choice="opt" rep="norepeat"> |
| 30 | <option>-c |
| 31 | <replaceable>count</replaceable></option> |
| 32 | </arg> |
| 33 | <arg choice="opt" rep="norepeat"> |
| 34 | <option>-e |
| 35 | <replaceable>identifier</replaceable></option> |
| 36 | </arg> |
| 37 | <arg choice="opt" rep="norepeat"> |
| 38 | <option>-F |
| 39 | <replaceable>flowlabel</replaceable></option> |
| 40 | </arg> |
| 41 | <arg choice="opt" rep="norepeat"> |
| 42 | <option>-i |
| 43 | <replaceable>interval</replaceable></option> |
| 44 | </arg> |
| 45 | <arg choice="opt" rep="norepeat"> |
| 46 | <option>-I |
| 47 | <replaceable>interface</replaceable></option> |
| 48 | </arg> |
| 49 | <arg choice="opt" rep="norepeat"> |
| 50 | <option>-l |
| 51 | <replaceable>preload</replaceable></option> |
| 52 | </arg> |
| 53 | <arg choice="opt" rep="norepeat"> |
| 54 | <option>-m |
| 55 | <replaceable>mark</replaceable></option> |
| 56 | </arg> |
| 57 | <arg choice="opt" rep="norepeat"> |
| 58 | <option>-M |
| 59 | <replaceable>pmtudisc_option</replaceable></option> |
| 60 | </arg> |
| 61 | <arg choice="opt" rep="norepeat"> |
| 62 | <option>-N |
| 63 | <replaceable>nodeinfo_option</replaceable></option> |
| 64 | </arg> |
| 65 | <arg choice="opt" rep="norepeat"> |
| 66 | <option>-w |
| 67 | <replaceable>deadline</replaceable></option> |
| 68 | </arg> |
| 69 | <arg choice="opt" rep="norepeat"> |
| 70 | <option>-W |
| 71 | <replaceable>timeout</replaceable></option> |
| 72 | </arg> |
| 73 | <arg choice="opt" rep="norepeat"> |
| 74 | <option>-p |
| 75 | <replaceable>pattern</replaceable></option> |
| 76 | </arg> |
| 77 | <arg choice="opt" rep="norepeat"> |
| 78 | <option>-Q |
| 79 | <replaceable>tos</replaceable></option> |
| 80 | </arg> |
| 81 | <arg choice="opt" rep="norepeat"> |
| 82 | <option>-s |
| 83 | <replaceable>packetsize</replaceable></option> |
| 84 | </arg> |
| 85 | <arg choice="opt" rep="norepeat"> |
| 86 | <option>-S |
| 87 | <replaceable>sndbuf</replaceable></option> |
| 88 | </arg> |
| 89 | <arg choice="opt" rep="norepeat"> |
| 90 | <option>-t |
| 91 | <replaceable>ttl</replaceable></option> |
| 92 | </arg> |
| 93 | <arg choice="opt" rep="norepeat"> |
| 94 | <option>-T |
| 95 | <replaceable>timestamp option</replaceable></option> |
| 96 | </arg> |
| 97 | <arg choice="opt" rep="norepeat">hop...</arg> |
| 98 | <arg choice="req" rep="norepeat">destination</arg> |
| 99 | </cmdsynopsis> |
| 100 | </refsynopsisdiv> |
| 101 | |
| 102 | <refsection xml:id="description"> |
| 103 | <info> |
| 104 | <title>DESCRIPTION</title> |
| 105 | </info> |
| 106 | <para> |
| 107 | <command>ping</command> uses the ICMP protocol's mandatory |
| 108 | ECHO_REQUEST datagram to elicit an ICMP ECHO_RESPONSE from a |
| 109 | host or gateway. ECHO_REQUEST datagrams (“pings”) have an IP |
| 110 | and ICMP header, followed by a struct timeval and then an |
| 111 | arbitrary number of “pad” bytes used to fill out the |
| 112 | packet.</para> |
| 113 | <para> |
| 114 | <command>ping</command> works with both IPv4 and IPv6. Using |
| 115 | only one of them explicitly can be enforced by specifying |
| 116 | <option>-4</option> or |
| 117 | <option>-6</option>.</para> |
| 118 | <para> |
| 119 | <command>ping</command> can also send IPv6 Node Information |
| 120 | Queries (RFC4620). Intermediate |
| 121 | <emphasis remap="I">hop</emphasis>s may not be allowed, because |
| 122 | IPv6 source routing was deprecated (RFC5095).</para> |
| 123 | </refsection> |
| 124 | |
| 125 | <refsection xml:id="options"> |
| 126 | <info> |
| 127 | <title>OPTIONS</title> |
| 128 | </info> |
| 129 | <variablelist remap="TP"> |
| 130 | <varlistentry> |
| 131 | <term> |
| 132 | <option>-3</option> |
| 133 | </term> |
| 134 | <listitem> |
| 135 | <para>RTT precision (do not round up the result time).</para> |
| 136 | </listitem> |
| 137 | </varlistentry> |
| 138 | <varlistentry> |
| 139 | <term> |
| 140 | <option>-4</option> |
| 141 | </term> |
| 142 | <listitem> |
| 143 | <para>Use IPv4 only.</para> |
| 144 | </listitem> |
| 145 | </varlistentry> |
| 146 | <varlistentry> |
| 147 | <term> |
| 148 | <option>-6</option> |
| 149 | </term> |
| 150 | <listitem> |
| 151 | <para>Use IPv6 only.</para> |
| 152 | </listitem> |
| 153 | </varlistentry> |
| 154 | <varlistentry> |
| 155 | <term> |
| 156 | <option>-a</option> |
| 157 | </term> |
| 158 | <listitem> |
| 159 | <para>Audible ping.</para> |
| 160 | </listitem> |
| 161 | </varlistentry> |
| 162 | <varlistentry> |
| 163 | <term> |
| 164 | <option>-A</option> |
| 165 | </term> |
| 166 | <listitem> |
| 167 | <para>Adaptive ping. Interpacket interval adapts to |
| 168 | round-trip time, so that effectively not more than one |
| 169 | (or more, if preload is set) unanswered probe is present |
| 170 | in the network. The default interval is 2 ms, |
| 171 | for more info see option <option>-i</option>. |
| 172 | On networks with low RTT this mode is |
| 173 | essentially equivalent to flood mode.</para> |
| 174 | </listitem> |
| 175 | </varlistentry> |
| 176 | <varlistentry> |
| 177 | <term> |
| 178 | <option>-b</option> |
| 179 | </term> |
| 180 | <listitem> |
| 181 | <para>Allow pinging a broadcast address.</para> |
| 182 | </listitem> |
| 183 | </varlistentry> |
| 184 | <varlistentry> |
| 185 | <term> |
| 186 | <option>-B</option> |
| 187 | </term> |
| 188 | <listitem> |
| 189 | <para>Do not allow |
| 190 | <command>ping</command> to change source address of |
| 191 | probes. The address is bound to one selected when |
| 192 | <command>ping</command> starts.</para> |
| 193 | </listitem> |
| 194 | </varlistentry> |
| 195 | <varlistentry> |
| 196 | <term> |
| 197 | <option>-c</option> |
| 198 | <emphasis remap="I">count</emphasis> |
| 199 | </term> |
| 200 | <listitem> |
| 201 | <para>Stop after sending |
| 202 | <emphasis remap="I">count</emphasis> ECHO_REQUEST packets. |
| 203 | With |
| 204 | <emphasis remap="I">deadline</emphasis> option, |
| 205 | <command>ping</command> waits for |
| 206 | <emphasis remap="I">count</emphasis> ECHO_REPLY packets, |
| 207 | until the timeout expires.</para> |
| 208 | </listitem> |
| 209 | </varlistentry> |
| 210 | <varlistentry> |
| 211 | <term> |
| 212 | <option>-C</option> |
| 213 | </term> |
| 214 | <listitem> |
| 215 | <para>Call connect() syscall on socket creation.</para> |
| 216 | </listitem> |
| 217 | </varlistentry> |
| 218 | <varlistentry> |
| 219 | <term> |
| 220 | <option>-d</option> |
| 221 | </term> |
| 222 | <listitem> |
| 223 | <para>Set the SO_DEBUG option on the socket being used. |
| 224 | Essentially, this socket option is not used by Linux |
| 225 | kernel.</para> |
| 226 | </listitem> |
| 227 | </varlistentry> |
| 228 | <varlistentry> |
| 229 | <term> |
| 230 | <option>-D</option> |
| 231 | </term> |
| 232 | <listitem> |
| 233 | <para>Print timestamp (unix time + microseconds as in |
| 234 | gettimeofday) before each line.</para> |
| 235 | </listitem> |
| 236 | </varlistentry> |
| 237 | <varlistentry> |
| 238 | <term> |
| 239 | <option>-e</option> |
| 240 | <emphasis remap="I">identifier</emphasis> |
| 241 | </term> |
| 242 | <listitem> |
| 243 | <para>Set the identification field of ECHO_REQUEST. |
| 244 | Value 0 implies using <emphasis remap="I">raw socket</emphasis> |
| 245 | (not supported on <emphasis remap="I">ICMP datagram socket</emphasis>). |
| 246 | The value of the field may be printed with <option>-v</option> option. |
| 247 | </para> |
| 248 | </listitem> |
| 249 | </varlistentry> |
| 250 | <varlistentry> |
| 251 | <term> |
| 252 | <option>-f</option> |
| 253 | </term> |
| 254 | <listitem> |
| 255 | <para>Flood ping. For every ECHO_REQUEST sent a period |
| 256 | “.” is printed, while for every ECHO_REPLY received a |
| 257 | backspace is printed. This provides a rapid display of |
| 258 | how many packets are being dropped. If interval is not |
| 259 | given, it sets interval to zero and outputs packets as |
| 260 | fast as they come back or one hundred times per second, |
| 261 | whichever is more. Only the super-user may use this |
| 262 | option with zero interval.</para> |
| 263 | </listitem> |
| 264 | </varlistentry> |
| 265 | <varlistentry> |
| 266 | <term> |
| 267 | <option>-F</option> |
| 268 | <emphasis remap="I">flow label</emphasis> |
| 269 | </term> |
| 270 | <listitem> |
| 271 | <para>IPv6 only. Allocate and set 20 bit flow label (in |
| 272 | hex) on echo request packets. If value is zero, kernel |
| 273 | allocates random flow label.</para> |
| 274 | </listitem> |
| 275 | </varlistentry> |
| 276 | <varlistentry> |
| 277 | <term> |
| 278 | <option>-h</option> |
| 279 | </term> |
| 280 | <listitem> |
| 281 | <para>Show help.</para> |
| 282 | </listitem> |
| 283 | </varlistentry> |
| 284 | <varlistentry> |
| 285 | <term> |
| 286 | <option>-H</option> |
| 287 | </term> |
| 288 | <listitem> |
| 289 | <para>Force DNS name resolution for the output. Useful for numeric |
| 290 | destination, or <option>-f</option> option, which by default do not |
| 291 | perform it. It can also help to workaround DNS resolution problems. |
| 292 | Override previously defined <option>-n</option> option. |
| 293 | See also <emphasis remap="I">IPUTILS_PING_PTR_LOOKUP</emphasis> |
| 294 | environment variable. |
| 295 | </para> |
| 296 | </listitem> |
| 297 | </varlistentry> |
| 298 | <varlistentry> |
| 299 | <term> |
| 300 | <option>-i</option> |
| 301 | <emphasis remap="I">interval</emphasis> |
| 302 | </term> |
| 303 | <listitem> |
| 304 | <para>Wait |
| 305 | <emphasis remap="I">interval</emphasis> seconds between |
| 306 | sending each packet. Real number allowed with dot as |
| 307 | a decimal separator (regardless locale setup). |
| 308 | The default is to wait for one second between each packet |
| 309 | normally, or not to wait in flood mode. |
| 310 | Only super-user may set interval to values |
| 311 | less than 2 ms. Broadcast and multicast ping have even |
| 312 | higher limitation for regular user: minimum is 1 sec.</para> |
| 313 | </listitem> |
| 314 | </varlistentry> |
| 315 | <varlistentry> |
| 316 | <term> |
| 317 | <option>-I</option> |
| 318 | <emphasis remap="I">interface</emphasis> |
| 319 | </term> |
| 320 | <listitem> |
| 321 | <para> |
| 322 | <emphasis remap="I">interface</emphasis> is either an |
| 323 | address, an interface name or a VRF name. If |
| 324 | <emphasis remap="I">interface</emphasis> is an address, it |
| 325 | sets source address to specified interface address. If |
| 326 | <emphasis remap="I">interface</emphasis> is an interface |
| 327 | name, it sets source interface to specified interface. |
| 328 | If <emphasis remap="I">interface</emphasis> is a VRF |
| 329 | name, each packet is routed using the corresponding |
| 330 | routing table; in this case, the <option>-I</option> option |
| 331 | can be repeated to specify a source address. |
| 332 | NOTE: For IPv6, when doing ping to a link-local scope |
| 333 | address, link specification (by the '%'-notation in |
| 334 | <emphasis remap="I">destination</emphasis>, or by this |
| 335 | option) can be used but it is no longer required.</para> |
| 336 | </listitem> |
| 337 | </varlistentry> |
| 338 | <varlistentry> |
| 339 | <term> |
| 340 | <option>-l</option> |
| 341 | <emphasis remap="I">preload</emphasis> |
| 342 | </term> |
| 343 | <listitem> |
| 344 | <para>If |
| 345 | <emphasis remap="I">preload</emphasis> is specified, |
| 346 | <command>ping</command> sends that many packets not |
| 347 | waiting for reply. Only the super-user may select preload |
| 348 | more than 3.</para> |
| 349 | </listitem> |
| 350 | </varlistentry> |
| 351 | <varlistentry> |
| 352 | <term> |
| 353 | <option>-L</option> |
| 354 | </term> |
| 355 | <listitem> |
| 356 | <para>Suppress loopback of multicast packets. This flag |
| 357 | only applies if the ping destination is a multicast |
| 358 | address.</para> |
| 359 | </listitem> |
| 360 | </varlistentry> |
| 361 | <varlistentry> |
| 362 | <term> |
| 363 | <option>-m</option> |
| 364 | <emphasis remap="I">mark</emphasis> |
| 365 | </term> |
| 366 | <listitem> |
| 367 | <para>use |
| 368 | <emphasis remap="I">mark</emphasis> to tag the packets |
| 369 | going out. This is useful for variety of reasons within |
| 370 | the kernel such as using policy routing to select |
| 371 | specific outbound processing. CAP_NET_ADMIN or CAP_NET_RAW |
| 372 | (since Linux 5.17) capability is required, see |
| 373 | <citerefentry> |
| 374 | <refentrytitle>socket</refentrytitle> |
| 375 | <manvolnum>7</manvolnum> |
| 376 | </citerefentry>.</para> |
| 377 | </listitem> |
| 378 | </varlistentry> |
| 379 | <varlistentry> |
| 380 | <term> |
| 381 | <option>-M</option> |
| 382 | <emphasis remap="I">pmtudisc_opt</emphasis> |
| 383 | </term> |
| 384 | <listitem> |
| 385 | <para>Select Path MTU Discovery strategy. |
| 386 | <emphasis remap="I">pmtudisc_option</emphasis> may be |
| 387 | either |
| 388 | <emphasis remap="I">do</emphasis> (set DF flag but |
| 389 | subject to PMTU checks by kernel, packets too large will |
| 390 | be rejected), |
| 391 | <emphasis remap="I">want</emphasis> (do PMTU discovery, |
| 392 | fragment locally when packet size is large), |
| 393 | <emphasis remap="I">probe</emphasis> (set DF flag and |
| 394 | bypass PMTU checks, useful for probing), or |
| 395 | <emphasis remap="I">dont</emphasis> (do not set DF |
| 396 | flag).</para> |
| 397 | </listitem> |
| 398 | </varlistentry> |
| 399 | <varlistentry> |
| 400 | <term> |
| 401 | <option>-N</option> |
| 402 | <emphasis remap="I">nodeinfo_option</emphasis> |
| 403 | </term> |
| 404 | <listitem> |
| 405 | <para>IPv6 only. Send IPv6 Node Information Queries |
| 406 | (RFC4620), instead of Echo Request. CAP_NET_RAW |
| 407 | capability is required.</para> |
| 408 | <variablelist remap="TP"> |
| 409 | <varlistentry> |
| 410 | <term> |
| 411 | <emphasis remap="B">help</emphasis> |
| 412 | </term> |
| 413 | <listitem> |
| 414 | <para>Show help for NI support.</para> |
| 415 | </listitem> |
| 416 | </varlistentry> |
| 417 | </variablelist> |
| 418 | <variablelist remap="TP"> |
| 419 | <varlistentry> |
| 420 | <term> |
| 421 | <emphasis remap="B">name</emphasis> |
| 422 | </term> |
| 423 | <listitem> |
| 424 | <para>Queries for Node Names.</para> |
| 425 | </listitem> |
| 426 | </varlistentry> |
| 427 | </variablelist> |
| 428 | <variablelist remap="TP"> |
| 429 | <varlistentry> |
| 430 | <term> |
| 431 | <emphasis remap="B">ipv6</emphasis> |
| 432 | </term> |
| 433 | <listitem> |
| 434 | <para>Queries for IPv6 Addresses. There are several |
| 435 | IPv6 specific flags.</para> |
| 436 | <variablelist remap="TP"> |
| 437 | <varlistentry> |
| 438 | <term> |
| 439 | <emphasis remap="B">ipv6-global</emphasis> |
| 440 | </term> |
| 441 | <listitem> |
| 442 | <para>Request IPv6 global-scope |
| 443 | addresses.</para> |
| 444 | </listitem> |
| 445 | </varlistentry> |
| 446 | </variablelist> |
| 447 | <variablelist remap="TP"> |
| 448 | <varlistentry> |
| 449 | <term> |
| 450 | <emphasis remap="B">ipv6-sitelocal</emphasis> |
| 451 | </term> |
| 452 | <listitem> |
| 453 | <para>Request IPv6 site-local |
| 454 | addresses.</para> |
| 455 | </listitem> |
| 456 | </varlistentry> |
| 457 | </variablelist> |
| 458 | <variablelist remap="TP"> |
| 459 | <varlistentry> |
| 460 | <term> |
| 461 | <emphasis remap="B">ipv6-linklocal</emphasis> |
| 462 | </term> |
| 463 | <listitem> |
| 464 | <para>Request IPv6 link-local |
| 465 | addresses.</para> |
| 466 | </listitem> |
| 467 | </varlistentry> |
| 468 | </variablelist> |
| 469 | <variablelist remap="TP"> |
| 470 | <varlistentry> |
| 471 | <term> |
| 472 | <emphasis remap="B">ipv6-all</emphasis> |
| 473 | </term> |
| 474 | <listitem> |
| 475 | <para>Request IPv6 addresses on other |
| 476 | interfaces.</para> |
| 477 | </listitem> |
| 478 | </varlistentry> |
| 479 | </variablelist> |
| 480 | </listitem> |
| 481 | </varlistentry> |
| 482 | </variablelist> |
| 483 | <variablelist remap="TP"> |
| 484 | <varlistentry> |
| 485 | <term> |
| 486 | <emphasis remap="B">ipv4</emphasis> |
| 487 | </term> |
| 488 | <listitem> |
| 489 | <para>Queries for IPv4 Addresses. There is one IPv4 |
| 490 | specific flag.</para> |
| 491 | <variablelist remap="TP"> |
| 492 | <varlistentry> |
| 493 | <term> |
| 494 | <emphasis remap="B">ipv4-all</emphasis> |
| 495 | </term> |
| 496 | <listitem> |
| 497 | <para>Request IPv4 addresses on other |
| 498 | interfaces.</para> |
| 499 | </listitem> |
| 500 | </varlistentry> |
| 501 | </variablelist> |
| 502 | </listitem> |
| 503 | </varlistentry> |
| 504 | </variablelist> |
| 505 | <variablelist remap="TP"> |
| 506 | <varlistentry> |
| 507 | <term> |
| 508 | <emphasis remap="B">subject-ipv6=</emphasis><emphasis remap="I">ipv6addr</emphasis> |
| 509 | </term> |
| 510 | <listitem> |
| 511 | <para>IPv6 subject address.</para> |
| 512 | </listitem> |
| 513 | </varlistentry> |
| 514 | </variablelist> |
| 515 | <variablelist remap="TP"> |
| 516 | <varlistentry> |
| 517 | <term> |
| 518 | <emphasis remap="B">subject-ipv4=</emphasis><emphasis remap="I">ipv4addr</emphasis> |
| 519 | </term> |
| 520 | <listitem> |
| 521 | <para>IPv4 subject address.</para> |
| 522 | </listitem> |
| 523 | </varlistentry> |
| 524 | </variablelist> |
| 525 | <variablelist remap="TP"> |
| 526 | <varlistentry> |
| 527 | <term> |
| 528 | <emphasis remap="B">subject-name=</emphasis><emphasis remap="I">nodename</emphasis> |
| 529 | </term> |
| 530 | <listitem> |
| 531 | <para>Subject name. If it contains more than one |
| 532 | dot, fully-qualified domain name is assumed.</para> |
| 533 | </listitem> |
| 534 | </varlistentry> |
| 535 | </variablelist> |
| 536 | <variablelist remap="TP"> |
| 537 | <varlistentry> |
| 538 | <term> |
| 539 | <emphasis remap="B">subject-fqdn=</emphasis><emphasis remap="I">nodename</emphasis> |
| 540 | </term> |
| 541 | <listitem> |
| 542 | <para>Subject name. Fully-qualified domain name is |
| 543 | always assumed.</para> |
| 544 | </listitem> |
| 545 | </varlistentry> |
| 546 | </variablelist> |
| 547 | </listitem> |
| 548 | </varlistentry> |
| 549 | <varlistentry> |
| 550 | <term> |
| 551 | <option>-n</option> |
| 552 | </term> |
| 553 | <listitem> |
| 554 | <para>Numeric output only. No attempt will be made to lookup |
| 555 | symbolic names for host addresses (no reverse DNS resolution). |
| 556 | This is the default for numeric destination or <option>-f</option> |
| 557 | option. Override previously defined <option>-H</option> option. |
| 558 | See also <emphasis remap="I">IPUTILS_PING_PTR_LOOKUP</emphasis> |
| 559 | environment variable. |
| 560 | </para> |
| 561 | </listitem> |
| 562 | </varlistentry> |
| 563 | <varlistentry> |
| 564 | <term> |
| 565 | <option>-O</option> |
| 566 | </term> |
| 567 | <listitem> |
| 568 | <para>Report outstanding ICMP ECHO reply before sending |
| 569 | next packet. This is useful together with the timestamp |
| 570 | <option>-D</option> to log output to a diagnostic file and |
| 571 | search for missing answers.</para> |
| 572 | </listitem> |
| 573 | </varlistentry> |
| 574 | <varlistentry> |
| 575 | <term> |
| 576 | <option>-p</option> |
| 577 | <emphasis remap="I">pattern</emphasis> |
| 578 | </term> |
| 579 | <listitem> |
| 580 | <para>You may specify up to 16 “pad” bytes to fill out |
| 581 | the packet you send. This is useful for diagnosing |
| 582 | data-dependent problems in a network. For example, |
| 583 | <option>-p ff</option> will cause the sent packet to be |
| 584 | filled with all ones.</para> |
| 585 | </listitem> |
| 586 | </varlistentry> |
| 587 | <varlistentry> |
| 588 | <term> |
| 589 | <option>-q</option> |
| 590 | </term> |
| 591 | <listitem> |
| 592 | <para>Quiet output. Nothing is displayed except the |
| 593 | summary lines at startup time and when finished.</para> |
| 594 | </listitem> |
| 595 | </varlistentry> |
| 596 | <varlistentry> |
| 597 | <term> |
| 598 | <option>-Q</option> |
| 599 | <emphasis remap="I">tos</emphasis> |
| 600 | </term> |
| 601 | <listitem> |
| 602 | <para>Set Quality of Service -related bits in ICMP |
| 603 | datagrams. |
| 604 | <emphasis remap="I">tos</emphasis> can be decimal |
| 605 | (<command>ping</command> only) or hex number.</para> |
| 606 | <para>In RFC2474, these fields are interpreted as 8-bit |
| 607 | Differentiated Services (DS), consisting of: bits 0-1 (2 |
| 608 | lowest bits) of separate data, and bits 2-7 (highest 6 |
| 609 | bits) of Differentiated Services Codepoint (DSCP). In |
| 610 | RFC2481 and RFC3168, bits 0-1 are used for ECN.</para> |
| 611 | <para>Historically (RFC1349, obsoleted by RFC2474), these |
| 612 | were interpreted as: bit 0 (lowest bit) for reserved |
| 613 | (currently being redefined as congestion control), 1-4 |
| 614 | for Type of Service and bits 5-7 (highest bits) for |
| 615 | Precedence.</para> |
| 616 | </listitem> |
| 617 | </varlistentry> |
| 618 | <varlistentry> |
| 619 | <term> |
| 620 | <option>-r</option> |
| 621 | </term> |
| 622 | <listitem> |
| 623 | <para>Bypass the normal routing tables and send directly |
| 624 | to a host on an attached interface. If the host is not on |
| 625 | a directly-attached network, an error is returned. This |
| 626 | option can be used to ping a local host through an |
| 627 | interface that has no route through it provided the |
| 628 | option |
| 629 | <option>-I</option> is also used.</para> |
| 630 | </listitem> |
| 631 | </varlistentry> |
| 632 | <varlistentry> |
| 633 | <term> |
| 634 | <option>-R</option> |
| 635 | </term> |
| 636 | <listitem> |
| 637 | <para> |
| 638 | <command>ping</command> only. Record route. Includes the |
| 639 | RECORD_ROUTE option in the ECHO_REQUEST packet and |
| 640 | displays the route buffer on returned packets. Note that |
| 641 | the IP header is only large enough for nine such routes. |
| 642 | Many hosts ignore or discard this option.</para> |
| 643 | </listitem> |
| 644 | </varlistentry> |
| 645 | <varlistentry> |
| 646 | <term> |
| 647 | <option>-s</option> |
| 648 | <emphasis remap="I">packetsize</emphasis> |
| 649 | </term> |
| 650 | <listitem> |
| 651 | <para>Specifies the number of data bytes to be sent. The |
| 652 | default is 56, which translates into 64 ICMP data bytes |
| 653 | when combined with the 8 bytes of ICMP header data. |
| 654 | The maximum allowed value is 65507 for IPv4 |
| 655 | (65467 when <option>-R</option> or <option>-T</option> |
| 656 | or Intermediate <emphasis remap="I">hop</emphasis>s) |
| 657 | or 65527 for IPv6, but most systems |
| 658 | limit this to a smaller, system-dependent number.</para> |
| 659 | </listitem> |
| 660 | </varlistentry> |
| 661 | <varlistentry> |
| 662 | <term> |
| 663 | <option>-S</option> |
| 664 | <emphasis remap="I">sndbuf</emphasis> |
| 665 | </term> |
| 666 | <listitem> |
| 667 | <para>Set socket sndbuf. If not specified, it is selected |
| 668 | to buffer not more than one packet.</para> |
| 669 | </listitem> |
| 670 | </varlistentry> |
| 671 | <varlistentry> |
| 672 | <term> |
| 673 | <option>-t</option> |
| 674 | <emphasis remap="I">ttl</emphasis> |
| 675 | </term> |
| 676 | <listitem> |
| 677 | <para> |
| 678 | <command>ping</command> only. Set the IP Time to |
| 679 | Live.</para> |
| 680 | </listitem> |
| 681 | </varlistentry> |
| 682 | <varlistentry> |
| 683 | <term> |
| 684 | <option>-T</option> |
| 685 | <emphasis remap="I">timestamp option</emphasis> |
| 686 | </term> |
| 687 | <listitem> |
| 688 | <para>Set special IP timestamp options. |
| 689 | <emphasis remap="I">timestamp option</emphasis> may be |
| 690 | either |
| 691 | <emphasis remap="I">tsonly</emphasis> (only timestamps), |
| 692 | <emphasis remap="I">tsandaddr</emphasis> (timestamps and |
| 693 | addresses) or |
| 694 | <emphasis remap="I">tsprespec host1 [host2 [host3 |
| 695 | [host4]]]</emphasis> (timestamp prespecified hops).</para> |
| 696 | </listitem> |
| 697 | </varlistentry> |
| 698 | <varlistentry> |
| 699 | <term> |
| 700 | <option>-U</option> |
| 701 | </term> |
| 702 | <listitem> |
| 703 | <para>Print full user-to-user latency (the old |
| 704 | behaviour). Normally |
| 705 | <command>ping</command> prints network round trip time, |
| 706 | which can be different f.e. due to DNS failures.</para> |
| 707 | </listitem> |
| 708 | </varlistentry> |
| 709 | <varlistentry> |
| 710 | <term> |
| 711 | <option>-v</option> |
| 712 | </term> |
| 713 | <listitem> |
| 714 | <para>Verbose output. Do not suppress DUP replies when pinging |
| 715 | multicast address.</para> |
| 716 | </listitem> |
| 717 | </varlistentry> |
| 718 | <varlistentry> |
| 719 | <term> |
| 720 | <option>-V</option> |
| 721 | </term> |
| 722 | <listitem> |
| 723 | <para>Show version and exit.</para> |
| 724 | </listitem> |
| 725 | </varlistentry> |
| 726 | <varlistentry> |
| 727 | <term> |
| 728 | <option>-w</option> |
| 729 | <emphasis remap="I">deadline</emphasis> |
| 730 | </term> |
| 731 | <listitem> |
| 732 | <para>Specify a timeout, in seconds, before |
| 733 | <command>ping</command> exits regardless of how many |
| 734 | packets have been sent or received. In this case |
| 735 | <command>ping</command> does not stop after |
| 736 | <emphasis remap="I">count</emphasis> packet are sent, it |
| 737 | waits either for |
| 738 | <emphasis remap="I">deadline</emphasis> expire or until |
| 739 | <emphasis remap="I">count</emphasis> probes are answered |
| 740 | or for some error notification from network.</para> |
| 741 | </listitem> |
| 742 | </varlistentry> |
| 743 | <varlistentry> |
| 744 | <term> |
| 745 | <option>-W</option> |
| 746 | <emphasis remap="I">timeout</emphasis> |
| 747 | </term> |
| 748 | <listitem> |
| 749 | <para>Time to wait for a response, in seconds. The option |
| 750 | affects only timeout in absence of any responses, |
| 751 | otherwise |
| 752 | <command>ping</command> waits for two RTTs. |
| 753 | Real number allowed with dot as a decimal separator |
| 754 | (regardless locale setup). |
| 755 | 0 means infinite timeout.</para> |
| 756 | </listitem> |
| 757 | </varlistentry> |
| 758 | </variablelist> |
| 759 | <para>When using |
| 760 | <command>ping</command> for fault isolation, it should first be |
| 761 | run on the local host, to verify that the local network |
| 762 | interface is up and running. Then, hosts and gateways further |
| 763 | and further away should be “pinged”. Round-trip times and |
| 764 | packet loss statistics are computed. If duplicate packets are |
| 765 | received, they are not included in the packet loss calculation, |
| 766 | although the round trip time of these packets is used in |
| 767 | calculating the minimum/average/maximum/mdev round-trip time |
| 768 | numbers.</para> |
| 769 | <para>Population standard deviation (mdev), essentially an |
| 770 | average of how far each ping RTT is from the mean RTT. The |
| 771 | higher mdev is, the more variable the RTT is (over time). |
| 772 | With a high RTT |
| 773 | variability, you will have speed issues with bulk transfers |
| 774 | (they will take longer than is strictly speaking necessary, as |
| 775 | the variability will eventually cause the sender to wait for |
| 776 | ACKs) and you will have middling to poor VoIP quality.</para> |
| 777 | <para>When the specified number of packets have been sent (and |
| 778 | received) or if the program is terminated with a SIGINT, a |
| 779 | brief summary is displayed. Shorter current statistics can be |
| 780 | obtained without termination of process with signal |
| 781 | SIGQUIT.</para> |
| 782 | <para>This program is intended for use in network testing, |
| 783 | measurement and management. Because of the load it can impose |
| 784 | on the network, it is unwise to use |
| 785 | <command>ping</command> during normal operations or from |
| 786 | automated scripts.</para> |
| 787 | </refsection> |
| 788 | |
| 789 | <refsection xml:id="environment"> |
| 790 | <info> |
| 791 | <title>ENVIRONMENT</title> |
| 792 | </info> |
| 793 | <para><emphasis remap="I">IPUTILS_PING_PTR_LOOKUP</emphasis> environment |
| 794 | variable set to 0 disable reverse DNS resolution (PTR lookup) by default. |
| 795 | It will be overrided by <option>-H</option> or <option>-n</option> option.</para> |
| 796 | </refsection> |
| 797 | |
| 798 | <refsection xml:id="exit_status"> |
| 799 | <info> |
| 800 | <title>EXIT STATUS</title> |
| 801 | </info> |
| 802 | <para>If |
| 803 | <command>ping</command> does not receive any reply packets at |
| 804 | all it will exit with code 1. If a packet |
| 805 | <emphasis remap="I">count</emphasis> and |
| 806 | <emphasis remap="I">deadline</emphasis> are both specified, and |
| 807 | fewer than |
| 808 | <emphasis remap="I">count</emphasis> packets are received by the |
| 809 | time the |
| 810 | <emphasis remap="I">deadline</emphasis> has arrived, it will |
| 811 | also exit with code 1. On other error it exits with code 2. |
| 812 | Otherwise it exits with code 0. This makes it possible to use |
| 813 | the exit code to see if a host is alive or not.</para> |
| 814 | </refsection> |
| 815 | |
| 816 | <refsection xml:id="ipv6_link_local_destinations"> |
| 817 | <info> |
| 818 | <title>IPV6 LINK-LOCAL DESTINATIONS</title> |
| 819 | </info> |
| 820 | <para>For IPv6, when the destination address has link-local scope and |
| 821 | <command>ping</command> is using <emphasis remap="I">ICMP datagram sockets</emphasis>, |
| 822 | the output interface must be specified. |
| 823 | When <command>ping</command> is using <emphasis remap="I">raw sockets</emphasis>, |
| 824 | it is not strictly necessary to specify the output interface but it should be done |
| 825 | to avoid ambiguity when there are multiple possible output interfaces.</para> |
| 826 | <para>There are two ways to specify the output interface:</para> |
| 827 | <variablelist remap="TP"> |
| 828 | <varlistentry> |
| 829 | <term> |
| 830 | • using the |
| 831 | <emphasis remap="I">% notation</emphasis> |
| 832 | </term> |
| 833 | <listitem> |
| 834 | <para>The destination address is postfixed with |
| 835 | <emphasis remap="I">%</emphasis> |
| 836 | and the output interface name or ifindex, for example:</para> |
| 837 | <para><command>ping fe80::5054:ff:fe70:67bc%eth0</command></para> |
| 838 | <para><command>ping fe80::5054:ff:fe70:67bc%2</command></para> |
| 839 | </listitem> |
| 840 | </varlistentry> |
| 841 | <varlistentry> |
| 842 | <term> |
| 843 | • using the |
| 844 | <emphasis remap="I">-I option</emphasis> |
| 845 | </term> |
| 846 | <listitem> |
| 847 | <para>When using <emphasis remap="I">ICMP datagram sockets</emphasis>, |
| 848 | this method is supported since the following kernel versions: 5.17, |
| 849 | 5.15.19, 5.10.96, 5.4.176, 4.19.228, 4.14.265. |
| 850 | Also it is not supported on musl libc.</para> |
| 851 | </listitem> |
| 852 | </varlistentry> |
| 853 | </variablelist> |
| 854 | </refsection> |
| 855 | |
| 856 | <refsection xml:id="icmp_packet_details"> |
| 857 | <info> |
| 858 | <title>ICMP PACKET DETAILS</title> |
| 859 | </info> |
| 860 | <para>An IP header without options is 20 bytes. An ICMP |
| 861 | ECHO_REQUEST packet contains an additional 8 bytes worth of |
| 862 | ICMP header followed by an arbitrary amount of data. When a |
| 863 | <emphasis remap="I">packetsize</emphasis> is given, this |
| 864 | indicates the size of this extra piece of data (the default is |
| 865 | 56). Thus the amount of data received inside of an IP packet of |
| 866 | type ICMP ECHO_REPLY will always be 8 bytes more than the |
| 867 | requested data space (the ICMP header).</para> |
| 868 | <para>If the data space is at least of size of struct timeval |
| 869 | <command>ping</command> uses the beginning bytes of this space |
| 870 | to include a timestamp which it uses in the computation of |
| 871 | round trip times. If the data space is shorter, no round trip |
| 872 | times are given.</para> |
| 873 | </refsection> |
| 874 | |
| 875 | <refsection xml:id="duplicate_and_damaged_packets"> |
| 876 | <info> |
| 877 | <title>DUPLICATE AND DAMAGED PACKETS</title> |
| 878 | </info> |
| 879 | <para> |
| 880 | <command>ping</command> will report duplicate and damaged |
| 881 | packets. Duplicate packets should never occur, and seem to be |
| 882 | caused by inappropriate link-level retransmissions. Duplicates |
| 883 | may occur in many situations and are rarely (if ever) a good |
| 884 | sign, although the presence of low levels of duplicates may not |
| 885 | always be cause for alarm.</para> |
| 886 | <para>Damaged packets are obviously serious cause for alarm and |
| 887 | often indicate broken hardware somewhere in the |
| 888 | <command>ping</command> packet's path (in the network or in the |
| 889 | hosts).</para> |
| 890 | </refsection> |
| 891 | |
| 892 | <refsection xml:id="id_collisions"> |
| 893 | <info> |
| 894 | <title>ID COLLISIONS</title> |
| 895 | </info> |
| 896 | <para> |
| 897 | Unlike TCP and UDP, which use port to uniquely identify the recipient to |
| 898 | deliver data, ICMP uses identifier field (ID) for identification. |
| 899 | Therefore, if on the same machine, at the same time, two ping processes |
| 900 | use the same ID, echo reply can be delivered to a wrong recipient. |
| 901 | This is a known problem due to the limited size of the 16-bit ID field. |
| 902 | That is a historical limitation of the protocol that cannot be fixed |
| 903 | at the moment unless we encode an ID into the ping packet payload. |
| 904 | <command>ping</command> prints <emphasis remap="I">DIFFERENT ADDRESS</emphasis> |
| 905 | error and packet loss is negative. |
| 906 | </para> |
| 907 | <para> |
| 908 | <command>ping</command> uses PID to get unique number. The default value of |
| 909 | <emphasis remap="I">/proc/sys/kernel/pid_max</emphasis> is 32768. |
| 910 | On the systems that use ping heavily and with <emphasis remap="I">pid_max</emphasis> |
| 911 | greater than 65535 collisions are bound to happen. |
| 912 | </para> |
| 913 | </refsection> |
| 914 | |
| 915 | <refsection xml:id="trying_different_data_patterns"> |
| 916 | <info> |
| 917 | <title>TRYING DIFFERENT DATA PATTERNS</title> |
| 918 | </info> |
| 919 | <para>The (inter)network layer should never treat packets |
| 920 | differently depending on the data contained in the data |
| 921 | portion. Unfortunately, data-dependent problems have been known |
| 922 | to sneak into networks and remain undetected for long periods |
| 923 | of time. In many cases the particular pattern that will have |
| 924 | problems is something that doesn't have sufficient |
| 925 | “transitions”, such as all ones or all zeros, or a pattern |
| 926 | right at the edge, such as almost all zeros. It isn't |
| 927 | necessarily enough to specify a data pattern of all zeros (for |
| 928 | example) on the command line because the pattern that is of |
| 929 | interest is at the data link level, and the relationship |
| 930 | between what you type and what the controllers transmit can be |
| 931 | complicated.</para> |
| 932 | <para>This means that if you have a data-dependent problem you |
| 933 | will probably have to do a lot of testing to find it. If you |
| 934 | are lucky, you may manage to find a file that either can't be |
| 935 | sent across your network or that takes much longer to transfer |
| 936 | than other similar length files. You can then examine this file |
| 937 | for repeated patterns that you can test using the |
| 938 | <option>-p</option> option of |
| 939 | <command>ping</command>.</para> |
| 940 | </refsection> |
| 941 | |
| 942 | <refsection xml:id="ttl_details"> |
| 943 | <info> |
| 944 | <title>TTL DETAILS</title> |
| 945 | </info> |
| 946 | <para>The TTL value of an IP packet represents the maximum |
| 947 | number of IP routers that the packet can go through before |
| 948 | being thrown away. In current practice you can expect each |
| 949 | router in the Internet to decrement the TTL field by exactly |
| 950 | one.</para> |
| 951 | <para>The TTL field for TCP packets may take various values. |
| 952 | The maximum possible value of this field is 255, a recommended |
| 953 | initial value is 64. For more information, see the TCP/Lower-Level |
| 954 | Interface section of RFC9293.</para> |
| 955 | <para>In normal operation <command>ping</command> prints the TTL |
| 956 | value from the packet it receives. When a remote system receives |
| 957 | a ping packet, it can do one of three things with the TTL field in |
| 958 | its response:</para> |
| 959 | <variablelist remap="TP"> |
| 960 | <varlistentry> |
| 961 | <listitem> |
| 962 | <para>• Not change it; this is what Berkeley Unix systems |
| 963 | did before the 4.3BSD Tahoe release. In this case the TTL |
| 964 | value in the received packet will be 255 minus the number |
| 965 | of routers in the round-trip path.</para> |
| 966 | </listitem> |
| 967 | </varlistentry> |
| 968 | <varlistentry> |
| 969 | <listitem> |
| 970 | <para>• Set it to 255; this is what current Berkeley Unix |
| 971 | systems do. In this case the TTL value in the received |
| 972 | packet will be 255 minus the number of routers in the |
| 973 | path |
| 974 | <emphasis remap="B">from</emphasis> the remote system |
| 975 | <emphasis remap="B">to</emphasis> the |
| 976 | <command>ping</command>ing host.</para> |
| 977 | </listitem> |
| 978 | </varlistentry> |
| 979 | <varlistentry> |
| 980 | <listitem> |
| 981 | <para>• Set it to some other value. Some machines use the |
| 982 | same value for ICMP packets that they use for TCP |
| 983 | packets, for example either 30 or 60. Others may use |
| 984 | completely wild values.</para> |
| 985 | </listitem> |
| 986 | </varlistentry> |
| 987 | </variablelist> |
| 988 | </refsection> |
| 989 | |
| 990 | <refsection xml:id="bugs"> |
| 991 | <info> |
| 992 | <title>BUGS</title> |
| 993 | </info> |
| 994 | <variablelist remap="TP"> |
| 995 | <varlistentry> |
| 996 | <listitem> |
| 997 | <para>• Many Hosts and Gateways ignore the RECORD_ROUTE |
| 998 | option.</para> |
| 999 | </listitem> |
| 1000 | </varlistentry> |
| 1001 | <varlistentry> |
| 1002 | <listitem> |
| 1003 | <para>• The maximum IP header length is too small for |
| 1004 | options like RECORD_ROUTE to be completely useful. |
| 1005 | There's not much that can be done about this, |
| 1006 | however.</para> |
| 1007 | </listitem> |
| 1008 | </varlistentry> |
| 1009 | <varlistentry> |
| 1010 | <listitem> |
| 1011 | <para>• Flood pinging is not recommended in general, and |
| 1012 | flood pinging the broadcast address should only be done |
| 1013 | under very controlled conditions.</para> |
| 1014 | </listitem> |
| 1015 | </varlistentry> |
| 1016 | </variablelist> |
| 1017 | </refsection> |
| 1018 | |
| 1019 | <refsection xml:id="see_also"> |
| 1020 | <info> |
| 1021 | <title>SEE ALSO</title> |
| 1022 | </info> |
| 1023 | <para> |
| 1024 | <citerefentry> |
| 1025 | <refentrytitle>ip</refentrytitle> |
| 1026 | <manvolnum>8</manvolnum> |
| 1027 | </citerefentry>, |
| 1028 | <citerefentry> |
| 1029 | <refentrytitle>ss</refentrytitle> |
| 1030 | <manvolnum>8</manvolnum> |
| 1031 | </citerefentry>.</para> |
| 1032 | </refsection> |
| 1033 | |
| 1034 | <refsection xml:id="history"> |
| 1035 | <info> |
| 1036 | <title>HISTORY</title> |
| 1037 | </info> |
| 1038 | <para>The |
| 1039 | <command>ping</command> command appeared in 4.3BSD.</para> |
| 1040 | <para>The version described here is its descendant specific to |
| 1041 | Linux.</para> |
| 1042 | <para>As of version s20150815, the |
| 1043 | <emphasis remap="B">ping6</emphasis> binary doesn't exist |
| 1044 | anymore. It has been merged into |
| 1045 | <command>ping</command>. Creating a symlink named |
| 1046 | <emphasis remap="B">ping6</emphasis> pointing to |
| 1047 | <command>ping</command> will result in the same functionality as |
| 1048 | before.</para> |
| 1049 | </refsection> |
| 1050 | |
| 1051 | <refsection xml:id="security"> |
| 1052 | <info> |
| 1053 | <title>SECURITY</title> |
| 1054 | </info> |
| 1055 | <para> |
| 1056 | <command>ping</command> requires CAP_NET_RAW capability to be |
| 1057 | executed 1) if the program is used for non-echo queries (see |
| 1058 | <option>-N</option> option) or when the identification field set to 0 |
| 1059 | for ECHO_REQUEST (see <option>-e</option>), or |
| 1060 | 2) if kernel does not support ICMP datagram sockets, or |
| 1061 | 3) if the user is not allowed to create an ICMP echo socket. |
| 1062 | The program may be used as set-uid root. |
| 1063 | </para> |
| 1064 | </refsection> |
| 1065 | |
| 1066 | <refsection xml:id="availability"> |
| 1067 | <info> |
| 1068 | <title>AVAILABILITY</title> |
| 1069 | </info> |
| 1070 | <para> |
| 1071 | <command>ping</command> is part of |
| 1072 | <emphasis remap="I">iputils</emphasis> package.</para> |
| 1073 | </refsection> |
| 1074 | </refentry> |