ping.8 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409
  1. .\" This manpage has been automatically generated by docbook2man
  2. .\" from a DocBook document. This tool can be found at:
  3. .\" <http://shell.ipoline.com/~elmert/comp/docbook2X/>
  4. .\" Please send any bug reports, improvements, comments, patches,
  5. .\" etc. to Steve Cheng <steve@ggi-project.org>.
  6. .TH "PING" "8" "24 Mayıs 2011" "iputils-101006" "System Manager's Manual: iputils"
  7. .SH NAME
  8. ping, ping6 \- send ICMP ECHO_REQUEST to network hosts
  9. .SH SYNOPSIS
  10. \fBping\fR [ \fB-LRUbdfnqrvVaAB\fR] [ \fB-c \fIcount\fB\fR] [ \fB-m \fImark\fB\fR] [ \fB-i \fIinterval\fB\fR] [ \fB-l \fIpreload\fB\fR] [ \fB-p \fIpattern\fB\fR] [ \fB-s \fIpacketsize\fB\fR] [ \fB-t \fIttl\fB\fR] [ \fB-w \fIdeadline\fB\fR] [ \fB-F \fIflowlabel\fB\fR] [ \fB-I \fIinterface\fB\fR] [ \fB-M \fIhint\fB\fR] [ \fB-N \fInioption\fB\fR] [ \fB-Q \fItos\fB\fR] [ \fB-S \fIsndbuf\fB\fR] [ \fB-T \fItimestamp option\fB\fR] [ \fB-W \fItimeout\fB\fR] [ \fB\fIhop\fB\fR\fI ...\fR] \fB\fIdestination\fB\fR
  11. .SH "DESCRIPTION"
  12. .PP
  13. \fBping\fR uses the ICMP protocol's mandatory ECHO_REQUEST
  14. datagram to elicit an ICMP ECHO_RESPONSE from a host or gateway.
  15. ECHO_REQUEST datagrams (``pings'') have an IP and ICMP
  16. header, followed by a struct timeval and then an arbitrary
  17. number of ``pad'' bytes used to fill out the packet.
  18. .PP
  19. \fBping6\fR can also send Node Information Queries (RFC4620).
  20. .SH "OPTIONS"
  21. .TP
  22. \fB-a\fR
  23. Audible ping.
  24. .TP
  25. \fB-A\fR
  26. Adaptive ping. Interpacket interval adapts to round-trip time, so that
  27. effectively not more than one (or more, if preload is set) unanswered probe
  28. is present in the network. Minimal interval is 200msec for not super-user.
  29. On networks with low rtt this mode is essentially equivalent to flood mode.
  30. .TP
  31. \fB-b\fR
  32. Allow pinging a broadcast address.
  33. .TP
  34. \fB-B\fR
  35. Do not allow \fBping\fR to change source address of probes.
  36. The address is bound to one selected when \fBping\fR starts.
  37. .TP
  38. \fB-m \fImark\fB\fR
  39. use \fImark\fR to tag the packets going out. This is useful
  40. for variety of reasons within the kernel such as using policy
  41. routing to select specific outbound processing.
  42. .TP
  43. \fB-c \fIcount\fB\fR
  44. Stop after sending \fIcount\fR ECHO_REQUEST
  45. packets. With
  46. \fIdeadline\fR
  47. option, \fBping\fR waits for
  48. \fIcount\fR ECHO_REPLY packets, until the timeout expires.
  49. .TP
  50. \fB-d\fR
  51. Set the SO_DEBUG option on the socket being used.
  52. Essentially, this socket option is not used by Linux kernel.
  53. .TP
  54. \fB-F \fIflow label\fB\fR
  55. Allocate and set 20 bit flow label on echo request packets.
  56. (Only \fBping6\fR). If value is zero, kernel allocates random flow label.
  57. .TP
  58. \fB-f\fR
  59. Flood ping. For every ECHO_REQUEST sent a period ``.'' is printed,
  60. while for ever ECHO_REPLY received a backspace is printed.
  61. This provides a rapid display of how many packets are being dropped.
  62. If interval is not given, it sets interval to zero and
  63. outputs packets as fast as they come back or one hundred times per second,
  64. whichever is more.
  65. Only the super-user may use this option with zero interval.
  66. .TP
  67. \fB-i \fIinterval\fB\fR
  68. Wait \fIinterval\fR seconds between sending each packet.
  69. The default is to wait for one second between each packet normally,
  70. or not to wait in flood mode. Only super-user may set interval
  71. to values less 0.2 seconds.
  72. .TP
  73. \fB-I \fIinterface address\fB\fR
  74. Set source address to specified interface address. Argument
  75. may be numeric IP address or name of device. When pinging IPv6
  76. link-local address this option is required.
  77. .TP
  78. \fB-l \fIpreload\fB\fR
  79. If \fIpreload\fR is specified,
  80. \fBping\fR sends that many packets not waiting for reply.
  81. Only the super-user may select preload more than 3.
  82. .TP
  83. \fB-L\fR
  84. Suppress loopback of multicast packets. This flag only applies if the ping
  85. destination is a multicast address.
  86. .TP
  87. \fB-N \fInioption\fB\fR
  88. Send ICMPv6 Node Information Queries (RFC4620), instead of Echo Request.
  89. .RS
  90. .TP
  91. \fBname\fR
  92. Queries for Node Names.
  93. .RE
  94. .RS
  95. .TP
  96. \fBipv6\fR
  97. Queries for IPv6 Addresses. There are several IPv6 specific flags.
  98. .RS
  99. .TP
  100. \fBipv6-global\fR
  101. Request IPv6 global-scope addresses.
  102. .RE
  103. .RS
  104. .TP
  105. \fBipv6-sitelocal\fR
  106. Request IPv6 site-local addresses.
  107. .RE
  108. .RS
  109. .TP
  110. \fBipv6-linklocal\fR
  111. Request IPv6 link-local addresses.
  112. .RE
  113. .RS
  114. .TP
  115. \fBipv6-all\fR
  116. Request IPv6 addresses on other interfaces.
  117. .RE
  118. .RE
  119. .RS
  120. .TP
  121. \fBipv4\fR
  122. Queries for IPv4 Addresses. There is one IPv4 specific flag.
  123. .RS
  124. .TP
  125. \fBipv4-all\fR
  126. Request IPv4 addresses on other interfaces.
  127. .RE
  128. .RE
  129. .RS
  130. .TP
  131. \fBsubject-ipv6=\fIipv6addr\fB\fR
  132. IPv6 subject address.
  133. .RE
  134. .RS
  135. .TP
  136. \fBsubject-ipv4=\fIipv4addr\fB\fR
  137. IPv4 subject address.
  138. .RE
  139. .RS
  140. .TP
  141. \fBsubject-name=\fInodename\fB\fR
  142. Subject name. If it contains more than one dot,
  143. fully-qualified domain name is assumed.
  144. .RE
  145. .RS
  146. .TP
  147. \fBsubject-fqdn=\fInodename\fB\fR
  148. Subject name. Fully-qualified domain name is
  149. always assumed.
  150. .RE
  151. .TP
  152. \fB-n\fR
  153. Numeric output only.
  154. No attempt will be made to lookup symbolic names for host addresses.
  155. .TP
  156. \fB-p \fIpattern\fB\fR
  157. You may specify up to 16 ``pad'' bytes to fill out the packet you send.
  158. This is useful for diagnosing data-dependent problems in a network.
  159. For example, \fB-p ff\fR will cause the sent packet
  160. to be filled with all ones.
  161. .TP
  162. \fB-D\fR
  163. Print timestamp (unix time + microseconds as in gettimeofday) before
  164. each line.
  165. .TP
  166. \fB-Q \fItos\fB\fR
  167. Set Quality of Service -related bits in ICMP datagrams.
  168. \fItos\fR can be either decimal or hex number.
  169. Traditionally (RFC1349), these have been interpreted as: 0 for reserved
  170. (currently being redefined as congestion control), 1-4 for Type of Service
  171. and 5-7 for Precedence.
  172. Possible settings for Type of Service are: minimal cost: 0x02,
  173. reliability: 0x04, throughput: 0x08, low delay: 0x10. Multiple TOS bits
  174. should not be set simultaneously. Possible settings for
  175. special Precedence range from priority (0x20) to net control (0xe0). You
  176. must be root (CAP_NET_ADMIN capability) to use Critical or
  177. higher precedence value. You cannot set
  178. bit 0x01 (reserved) unless ECN has been enabled in the kernel.
  179. In RFC2474, these fields has been redefined as 8-bit Differentiated
  180. Services (DS), consisting of: bits 0-1 of separate data (ECN will be used,
  181. here), and bits 2-7 of Differentiated Services Codepoint (DSCP).
  182. .TP
  183. \fB-q\fR
  184. Quiet output.
  185. Nothing is displayed except the summary lines at startup time and
  186. when finished.
  187. .TP
  188. \fB-R\fR
  189. Record route.
  190. Includes the RECORD_ROUTE option in the ECHO_REQUEST
  191. packet and displays the route buffer on returned packets.
  192. Note that the IP header is only large enough for nine such routes.
  193. Many hosts ignore or discard this option.
  194. .TP
  195. \fB-r\fR
  196. Bypass the normal routing tables and send directly to a host on an attached
  197. interface.
  198. If the host is not on a directly-attached network, an error is returned.
  199. This option can be used to ping a local host through an interface
  200. that has no route through it provided the option \fB-I\fR is also
  201. used.
  202. .TP
  203. \fB-s \fIpacketsize\fB\fR
  204. Specifies the number of data bytes to be sent.
  205. The default is 56, which translates into 64 ICMP
  206. data bytes when combined with the 8 bytes of ICMP header data.
  207. .TP
  208. \fB-S \fIsndbuf\fB\fR
  209. Set socket sndbuf. If not specified, it is selected to buffer
  210. not more than one packet.
  211. .TP
  212. \fB-t \fIttl\fB\fR
  213. Set the IP Time to Live.
  214. .TP
  215. \fB-T \fItimestamp option\fB\fR
  216. Set special IP timestamp options.
  217. \fItimestamp option\fR may be either
  218. \fItsonly\fR (only timestamps),
  219. \fItsandaddr\fR (timestamps and addresses) or
  220. \fItsprespec host1 [host2 [host3 [host4]]]\fR
  221. (timestamp prespecified hops).
  222. .TP
  223. \fB-M \fIhint\fB\fR
  224. Select Path MTU Discovery strategy.
  225. \fIhint\fR may be either \fIdo\fR
  226. (prohibit fragmentation, even local one),
  227. \fIwant\fR (do PMTU discovery, fragment locally when packet size
  228. is large), or \fIdont\fR (do not set DF flag).
  229. .TP
  230. \fB-U\fR
  231. Print full user-to-user latency (the old behaviour). Normally
  232. \fBping\fR
  233. prints network round trip time, which can be different
  234. f.e. due to DNS failures.
  235. .TP
  236. \fB-v\fR
  237. Verbose output.
  238. .TP
  239. \fB-V\fR
  240. Show version and exit.
  241. .TP
  242. \fB-w \fIdeadline\fB\fR
  243. Specify a timeout, in seconds, before
  244. \fBping\fR
  245. exits regardless of how many
  246. packets have been sent or received. In this case
  247. \fBping\fR
  248. does not stop after
  249. \fIcount\fR
  250. packet are sent, it waits either for
  251. \fIdeadline\fR
  252. expire or until
  253. \fIcount\fR
  254. probes are answered or for some error notification from network.
  255. .TP
  256. \fB-W \fItimeout\fB\fR
  257. Time to wait for a response, in seconds. The option affects only timeout
  258. in absence of any responses, otherwise \fBping\fR waits for two RTTs.
  259. .PP
  260. When using \fBping\fR for fault isolation, it should first be run
  261. on the local host, to verify that the local network interface is up
  262. and running. Then, hosts and gateways further and further away should be
  263. ``pinged''. Round-trip times and packet loss statistics are computed.
  264. If duplicate packets are received, they are not included in the packet
  265. loss calculation, although the round trip time of these packets is used
  266. in calculating the minimum/average/maximum round-trip time numbers.
  267. When the specified number of packets have been sent (and received) or
  268. if the program is terminated with a
  269. SIGINT, a brief summary is displayed. Shorter current statistics
  270. can be obtained without termination of process with signal
  271. SIGQUIT.
  272. .PP
  273. If \fBping\fR does not receive any reply packets at all it will
  274. exit with code 1. If a packet
  275. \fIcount\fR
  276. and
  277. \fIdeadline\fR
  278. are both specified, and fewer than
  279. \fIcount\fR
  280. packets are received by the time the
  281. \fIdeadline\fR
  282. has arrived, it will also exit with code 1.
  283. On other error it exits with code 2. Otherwise it exits with code 0. This
  284. makes it possible to use the exit code to see if a host is alive or
  285. not.
  286. .PP
  287. This program is intended for use in network testing, measurement and
  288. management.
  289. Because of the load it can impose on the network, it is unwise to use
  290. \fBping\fR during normal operations or from automated scripts.
  291. .SH "ICMP PACKET DETAILS"
  292. .PP
  293. An IP header without options is 20 bytes.
  294. An ICMP ECHO_REQUEST packet contains an additional 8 bytes worth
  295. of ICMP header followed by an arbitrary amount of data.
  296. When a \fIpacketsize\fR is given, this indicated the size of this
  297. extra piece of data (the default is 56). Thus the amount of data received
  298. inside of an IP packet of type ICMP ECHO_REPLY will always be 8 bytes
  299. more than the requested data space (the ICMP header).
  300. .PP
  301. If the data space is at least of size of struct timeval
  302. \fBping\fR uses the beginning bytes of this space to include
  303. a timestamp which it uses in the computation of round trip times.
  304. If the data space is shorter, no round trip times are given.
  305. .SH "DUPLICATE AND DAMAGED PACKETS"
  306. .PP
  307. \fBping\fR will report duplicate and damaged packets.
  308. Duplicate packets should never occur, and seem to be caused by
  309. inappropriate link-level retransmissions.
  310. Duplicates may occur in many situations and are rarely (if ever) a
  311. good sign, although the presence of low levels of duplicates may not
  312. always be cause for alarm.
  313. .PP
  314. Damaged packets are obviously serious cause for alarm and often
  315. indicate broken hardware somewhere in the
  316. \fBping\fR packet's path (in the network or in the hosts).
  317. .SH "TRYING DIFFERENT DATA PATTERNS"
  318. .PP
  319. The (inter)network layer should never treat packets differently depending
  320. on the data contained in the data portion.
  321. Unfortunately, data-dependent problems have been known to sneak into
  322. networks and remain undetected for long periods of time.
  323. In many cases the particular pattern that will have problems is something
  324. that doesn't have sufficient ``transitions'', such as all ones or all
  325. zeros, or a pattern right at the edge, such as almost all zeros.
  326. It isn't necessarily enough to specify a data pattern of all zeros (for
  327. example) on the command line because the pattern that is of interest is
  328. at the data link level, and the relationship between what you type and
  329. what the controllers transmit can be complicated.
  330. .PP
  331. This means that if you have a data-dependent problem you will probably
  332. have to do a lot of testing to find it.
  333. If you are lucky, you may manage to find a file that either can't be sent
  334. across your network or that takes much longer to transfer than other
  335. similar length files.
  336. You can then examine this file for repeated patterns that you can test
  337. using the \fB-p\fR option of \fBping\fR.
  338. .SH "TTL DETAILS"
  339. .PP
  340. The TTL value of an IP packet represents the maximum number of IP routers
  341. that the packet can go through before being thrown away.
  342. In current practice you can expect each router in the Internet to decrement
  343. the TTL field by exactly one.
  344. .PP
  345. The TCP/IP specification states that the TTL field for TCP
  346. packets should be set to 60, but many systems use smaller values
  347. (4.3 BSD uses 30, 4.2 used 15).
  348. .PP
  349. The maximum possible value of this field is 255, and most Unix systems set
  350. the TTL field of ICMP ECHO_REQUEST packets to 255.
  351. This is why you will find you can ``ping'' some hosts, but not reach them
  352. with
  353. \fBtelnet\fR(1)
  354. or
  355. \fBftp\fR(1).
  356. .PP
  357. In normal operation ping prints the TTL value from the packet it receives.
  358. When a remote system receives a ping packet, it can do one of three things
  359. with the TTL field in its response:
  360. .TP 0.2i
  361. \(bu
  362. Not change it; this is what Berkeley Unix systems did before the
  363. 4.3BSD Tahoe release. In this case the TTL value in the received packet
  364. will be 255 minus the number of routers in the round-trip path.
  365. .TP 0.2i
  366. \(bu
  367. Set it to 255; this is what current Berkeley Unix systems do.
  368. In this case the TTL value in the received packet will be 255 minus the
  369. number of routers in the path \fBfrom\fR
  370. the remote system \fBto\fR the \fBping\fRing host.
  371. .TP 0.2i
  372. \(bu
  373. Set it to some other value. Some machines use the same value for
  374. ICMP packets that they use for TCP packets, for example either 30 or 60.
  375. Others may use completely wild values.
  376. .SH "BUGS"
  377. .TP 0.2i
  378. \(bu
  379. Many Hosts and Gateways ignore the RECORD_ROUTE option.
  380. .TP 0.2i
  381. \(bu
  382. The maximum IP header length is too small for options like
  383. RECORD_ROUTE to be completely useful.
  384. There's not much that that can be done about this, however.
  385. .TP 0.2i
  386. \(bu
  387. Flood pinging is not recommended in general, and flood pinging the
  388. broadcast address should only be done under very controlled conditions.
  389. .SH "SEE ALSO"
  390. .PP
  391. \fBnetstat\fR(1),
  392. \fBifconfig\fR(8).
  393. .SH "HISTORY"
  394. .PP
  395. The \fBping\fR command appeared in 4.3BSD.
  396. .PP
  397. The version described here is its descendant specific to Linux.
  398. .SH "SECURITY"
  399. .PP
  400. \fBping\fR requires CAP_NET_RAWIO capability
  401. to be executed. It may be used as set-uid root.
  402. .SH "AVAILABILITY"
  403. .PP
  404. \fBping\fR is part of \fIiputils\fR package
  405. and the latest versions are available in source form at
  406. http://www.skbuff.net/iputils/iputils-current.tar.bz2.