PING(8)
๐ ping โ the manual, but make it cute ๐
ok so bestie. this is PING(8) from the iputils gang, and it's literally the most iconic networking tool to ever exist. no cap. let's get into it ๐ซถ
โจ NAME โจ
ping โ send ICMP ECHO_REQUEST to network hosts
like. that's it. that's the whole job. you yell at a host, it yells back. iconic behaviour honestly ๐
โจ SYNOPSIS โจ
ping [-aAbBdCDfhHLnOqrRUvV346] [-c count] [-e identifier] [-F flowlabel]
[-i interval] [-I interface] [-l preload] [-m mark]
[-M pmtudisc_option] [-N nodeinfo_option] [-w deadline]
[-W timeout] [-p pattern] [-Q tos] [-s packetsize] [-S sndbuf]
[-t ttl] [-T timestamp option] [hop...] {destination}
look at all those little flag-letters. it's giving alphabet soup but every single one of them does something. we'll get to them, don't worry ๐
โจ DESCRIPTION โจ
okay so here's the tea ๐
ping uses the ICMP protocol's mandatory ECHO_REQUEST datagram to elicit an ECHO_RESPONSE from a host or gateway. yes mandatory, as in the protocol requires it, as in it's not optional, as in it's the law. the ECHO_REQUEST datagrams โ aka the โpingsโ, the little guys, the whole point โ have an IP and ICMP header, followed by a struct timeval, and then an arbitrary number of โpadโ bytes used to fill out the packet.
so the anatomy is basically:
- IP header
- ICMP header
struct timeval- as many โpadโ bytes as it takes to fill out the packet โจ
ngl the pad bytes are just there to fill space and honestly? relatable. main character energy in an empty room ๐
ping works with both IPv4 and IPv6, bestie. it's bilingual. it contains multitudes ๐ฆ
and if you wanna force it to use only one of them explicitly, you can โ just specify -4 or -6. crisis averted, no ambiguity, pick your lane.
ping can also send IPv6 Node Information Queries (RFC4620). fancy. but heads up: intermediate hops may not be allowed, because IPv6 source routing was deprecated (RFC5095).
๐ฉ deprecated means deprecated, bestie. that's not a vibe check, that's a protocol-level "we don't do that anymore." don't come for me, come for the RFC.
ok that's part one, we're just getting warmed up, there's so much more coming ๐ธ
โจ OPTIONS โจ
okay bestie this is the part where it gets long but it's literally all the good stuff, don't skip any of it, we're going through ALL of them ๐
-3โ RTT precision, meaning it does not round up the result time. no rounding, we're being precise โจ-4โ IPv4 only. periodt.-6โ IPv6 only. also periodt.-aโ Audible ping. it makes noise so you know what's up ๐-Aโ Adaptive ping. the interpacket interval literally adapts to the round-trip time, so that effectively there's not more than one unanswered probe chilling in the network (or more than one, if preload is set ๐). default interval is2 ms, more deets in the-ioption. on networks with low RTT this mode is essentially equivalent to flood mode, no cap.-bโ Allow pinging a broadcast address. let it hit everyone ๐ซถ-Bโ Do not allow ping to change the source address of probes. the address is bound to the one selected when ping starts, so it's locked in, main character energy, no switching up.-c countโ Stop after sendingcountECHO_REQUESTpackets. with the deadline option, ping waits forcountECHO_REPLYpackets, until the timeout expires.-Cโ Callconnect()syscall on socket creation.-dโ Set theSO_DEBUGoption on the socket being used. honestly? this socket option is essentially not used by the Linux kernel. so like, it's giving decorative.-Dโ Print a timestamp (unix time + microseconds, as ingettimeofday) before each line. time-stamped receipts ๐-e identifierโ Set the identification field ofECHO_REQUEST. a value of0implies using a raw socket (not supported on ICMP datagram socket). the value of this field may be printed with the-voption.-fโ Flood ping. for everyECHO_REQUESTsent, a period.is printed, and for everyECHO_REPLYreceived, a backspace is printed. this gives you a rapid display of how many packets are being dropped. if interval is not given, it sets interval to zero and outputs packets as fast as they come back, or one hundred times per second, whichever is more. Only the super-user may use this option with zero interval. ๐ฅ-F flow labelโ IPv6 only. Allocate and set a 20 bit flow label (in hex) on echo request packets. if the value is zero, the kernel allocates a random flow label. cute of it.-hโ Show help.-Hโ Force DNS name resolution for the output. useful for a numeric destination, or for the-foption, which by default do not perform it. it can also help to workaround DNS resolution problems. overrides a previously defined-noption. see also theIPUTILS_PING_PTR_LOOKUPenvironment variable.-i intervalโ Waitintervalseconds between sending each packet. a real number is allowed, with a dot as the decimal separator (regardless of locale setup โ yes, regardless, don't fight it). the default is to wait for one second between each packet normally, or not to wait in flood mode. Only super-user may set interval to values less than2 ms. broadcast and multicast ping have an even higher limitation for a regular user: the minimum is1 sec.-I interfaceโinterfaceis either an address, an interface name or a VRF name. ifinterfaceis an address, it sets the source address to the specified interface address. ifinterfaceis an interface name, it sets the source interface to the specified interface. ifinterfaceis a VRF name, each packet is routed using the corresponding routing table; in this case, the-Ioption can be repeated to specify a source address. NOTE: for IPv6, when pinging a link-local scope address, link specification (by the'%'-notation in destination, or by this option) can be used, but it is no longer required. glow-up ๐-l preloadโ ifpreloadis specified, ping sends that many packets without waiting for a reply. Only the super-user may select apreloadmore than3.-Lโ Suppress loopback of multicast packets. this flag only applies if the ping destination is a multicast address.-m markโ usemarkto tag the packets going out. this is useful for a variety of reasons within the kernel, such as using policy routing to select specific outbound processing.CAP_NET_ADMINorCAP_NET_RAW(since Linux5.17) capability is required, seesocket(7).-M pmtudisc_optโ Select the Path MTU Discovery strategy.pmtudisc_optionmay be eitherdo(set DF flag but subject to PMTU checks by kernel โ packets too large will be rejected),want(do PMTU discovery, fragment locally when packet size is large),probe(set DF flag and bypass PMTU checks, useful for probing), ordont(do not set DF flag).-N nodeinfo_optionโ IPv6 only. Send IPv6 Node Information Queries (RFC4620), instead of Echo Request.CAP_NET_RAWcapability is required.helpโ Show help for NI support.nameโ Queries for Node Names.ipv6โ Queries for IPv6 Addresses. there are several IPv6 specific flags:ipv6-globalโ Request IPv6 global-scope addresses.ipv6-sitelocalโ Request IPv6 site-local addresses.ipv6-linklocalโ Request IPv6 link-local addresses.ipv6-allโ Request IPv6 addresses on other interfaces.
ipv4โ Queries for IPv4 Addresses. there is one IPv4 specific flag:ipv4-allโ Request IPv4 addresses on other interfaces.
subject-ipv6=ipv6addrโ IPv6 subject address.subject-ipv4=ipv4addrโ IPv4 subject address.subject-name=nodenameโ Subject name. if it contains more than one dot, a fully-qualified domain name is assumed.subject-fqdn=nodenameโ Subject name. a fully-qualified domain name is always assumed.
-nโ Numeric output only. no attempt will be made to lookup symbolic names for host addresses (so, no reverse DNS resolution). this is the default for a numeric destination or the-foption. overrides a previously defined-Hoption. see also theIPUTILS_PING_PTR_LOOKUPenvironment variable.-Oโ Report outstanding ICMP ECHO reply before sending the next packet. this is useful together with the timestamp-Dto log output to a diagnostic file and search for missing answers. detective mode ๐ต๏ธ-p patternโ You may specify up to16"pad" bytes to fill out the packet you send. this is useful for diagnosing data-dependent problems in a network. for example,-p ffwill cause the sent packet to be filled with all ones. ff = all the ones, iconic.-qโ Quiet output. nothing is displayed except the summary lines at startup time and when finished. silent but deadly ๐-Q tosโ Set Quality of Service-related bits in ICMP datagrams.toscan be a decimal (ping only) or hex number.
In RFC2474, these fields are interpreted as 8-bit Differentiated Services (DS), consisting of: bits 0-1 (the 2 lowest bits) of separate data, and bits 2-7 (the highest 6 bits) of Differentiated Services Codepoint (DSCP). In RFC2481 and RFC3168, bits 0-1 are used for ECN.
Historically (RFC1349, obsoleted by RFC2474), these were interpreted as: bit 0 (lowest bit) for reserved (currently being redefined as congestion control), 1-4 for Type of Service, and bits 5-7 (highest bits) for Precedence. lore drop ๐
-rโ Bypass the normal routing tables and send directly to a host on an attached interface. if the host is not on a directly-attached network, an error is returned. this option can be used to ping a local host through an interface that has no route through it, provided the option-Iis also used.-Rโ ping only. Record route. includes theRECORD_ROUTEoption in theECHO_REQUESTpacket and displays the route buffer on returned packets. note that the IP header is only large enough forninesuch routes. many hosts ignore or discard this option. rude of them honestly.-s packetsizeโ Specifies the number of data bytes to be sent. the default is56, which translates into64ICMP data bytes when combined with the8bytes of ICMP header data. the maximum allowed value is65507for IPv4 (65467when-Ror-Tor Intermediate hops) or65527for IPv6, but most systems limit this to a smaller, system-dependent number.-S sndbufโ Set socketsndbuf. if not specified, it is selected to buffer not more than one packet.-t ttlโ ping only. Set the IP Time to Live.-T timestamp optionโ Set special IP timestamp options.timestamp optionmay be eithertsonly(only timestamps),tsandaddr(timestamps and addresses) ortsprespec host1 [host2 [host3 [host4]]](timestamp prespecified hops).-Uโ Print full user-to-user latency (the old behaviour). normally ping prints network round trip time, which can be different, f.e. due to DNS failures.-vโ Verbose output. do not suppress DUP replies when pinging a multicast address.-Vโ Show version and exit.-w deadlineโ Specify a timeout, in seconds, before ping exits regardless of how many packets have been sent or received. in this case ping does not stop aftercountpackets are sent, it waits either fordeadlineto expire, or untilcountprobes are answered, or for some error notification from the network.-W timeoutโ Time to wait for a response, in seconds. the option affects only timeout in the absence of any responses, otherwise ping waits for two RTTs. a real number is allowed, with a dot as the decimal separator (regardless of locale setup).0means infinite timeout. ๐ฐ๏ธ
okay so when you're using ping for fault isolation, bestie, you should first run it on the local host, to verify that the local network interface is up and running. then, hosts and gateways further and further away should be "pinged". ๐ฆ
Round-trip times and packet loss statistics are computed. if duplicate packets are received, they are not included in the packet loss calculation, although the round trip time of these packets is used in calculating the minimum/average/maximum/mdev round-trip time numbers.
Population standard deviation (mdev) is essentially an average of how far each ping RTT is from the mean RTT. the higher mdev is, the more variable the RTT is (over time). with a high RTT variability, you will have speed issues with bulk transfers (they will take longer than is strictly speaking necessary, as the variability will eventually cause the sender to wait for ACKs) and you will have middling to poor VoIP quality. so like... jittery network = bad vibes on your calls, fr fr ๐ญ
When the specified number of packets have been sent (and received), or if the program is terminated with a SIGINT, a brief summary is displayed. shorter current statistics can be obtained without terminating the process, with the signal SIGQUIT. ๐
This program is intended for use in network testing, measurement and management. because of the load it can impose on the network, it is unwise to use ping during normal operations or from automated scripts. like please don't, it's not that kind of party.
๐ธ ENVIRONMENT ๐ธ
IPUTILS_PING_PTR_LOOKUPโ environment variable set to0disables reverse DNS resolution (PTR lookup) by default. it will be overrided by the-Hor-noption.
๐ EXIT STATUS ๐
ok so here's the tea on how ping says goodbye ๐ โ the exit code is literally a vibe check on whether your host is alive or not, no cap.
- If
pingdoes not receive any reply packets at all, it exits with code1. - If a packet count and a deadline are both specified, and fewer than count packets are received by the time the deadline has arrived, it also exits with code
1. - On any other error, it exits with code
2. - Otherwise, it exits with code
0. โจ
This makes it possible to use the exit code to see if a host is alive or not. fr fr, scriptable queen behavior ๐
๐ฆ IPV6 LINK-LOCAL DESTINATIONS ๐ฆ
For IPv6, when the destination address has link-local scope and ping is using ICMP datagram sockets, the output interface must be specified. ๐ค
When ping is using raw sockets, it is not strictly necessary to specify the output interface โ but it should be done to avoid ambiguity when there are multiple possible output interfaces. iykyk.
There are two ways to specify the output interface:
- using the
%notation โ the destination address is postfixed with%and the output interface name or ifindex, for example:
ping fe80::5054:ff:fe70:67bc%eth0
ping fe80::5054:ff:fe70:67bc%2
- using the
-Ioption โ when using ICMP datagram sockets, this method is supported since the following kernel versions:5.17,5.15.19,5.10.96,5.4.176,4.19.228,4.14.265. Also it is not supported on musl libc. ๐
๐ธ ICMP PACKET DETAILS ๐ธ
An IP header without options is 20 bytes. An ICMP ECHO_REQUEST packet contains an additional 8 bytes worth of ICMP header followed by an arbitrary amount of data. ๐
When a packetsize is given, this indicates the size of this extra piece of data โ and the default is 56. Thus the amount of data received inside of an IP packet of type ICMP ECHO_REPLY will always be 8 bytes more than the requested data space (the ICMP header). math is mathing ๐
If the data space is at least of size of struct timeval, ping uses the beginning bytes of this space to include a timestamp which it uses in the computation of round trip times. If the data space is shorter, no round trip times are given. ๐ญ
๐ DUPLICATE AND DAMAGED PACKETS ๐
ping will report duplicate and damaged packets.
Duplicate packets should never occur, and seem to be caused by inappropriate link-level retransmissions. Duplicates may occur in many situations and are rarely (if ever) a good sign โ although the presence of low levels of duplicates may not always be cause for alarm. like, it's giving concerning but maybe chill ๐ซ
Damaged packets are obviously serious cause for alarm and often indicate broken hardware somewhere in the ping packet's path โ in the network or in the hosts. ๐จ
๐ ID COLLISIONS ๐
Unlike TCP and UDP, which use port to uniquely identify the recipient to deliver data, ICMP uses the identifier field (ID) for identification. So if, on the same machine, at the same time, two ping processes use the same ID, the echo reply can be delivered to a wrong recipient. ๐
This is a known problem due to the limited size of the 16-bit ID field. That is a historical limitation of the protocol that cannot be fixed at the moment unless we encode an ID into the ping packet payload. ping prints DIFFERENT ADDRESS error and packet loss is negative. not the negative packet loss ๐ญ
ping uses PID to get a unique number. The default value of /proc/sys/kernel/pid_max is 32768. On the systems that use ping heavily and with pid_max greater than 65535, collisions are bound to happen.
๐ง TRYING DIFFERENT DATA PATTERNS ๐ง
The (inter)network layer should never treat packets differently depending on the data contained in the data portion. Unfortunately, data-dependent problems have been known to sneak into networks and remain undetected for long periods of time. ๐
In many cases the particular pattern that will have problems is something that doesn't have sufficient "transitions" โ such as all ones or all zeros, or a pattern right at the edge, such as almost all zeros. It isn't necessarily enough to specify a data pattern of all zeros (for example) on the command line because the pattern that is of interest is at the data link level, and the relationship between what you type and what the controllers transmit can be complicated. it's giving layers upon layers ๐ง
This means that if you have a data-dependent problem you will probably have to do a lot of testing to find it. If you are lucky ๐, you may manage to find a file that either can't be sent across your network or that takes much longer to transfer than other similar length files. You can then examine this file for repeated patterns that you can test using the -p option of ping. slay, detective era ๐
โญ TTL DETAILS โญ
The TTL value of an IP packet represents the maximum number of IP routers that the packet can go through before being thrown away. In current practice you can expect each router in the Internet to decrement the TTL field by exactly one.
The TTL field for TCP packets may take various values. The maximum possible value of this field is 255, and a recommended initial value is 64. For more information, see the TCP/Lower-Level Interface section of RFC9293. ๐
In normal operation ping prints the TTL value from the packet it receives. When a remote system receives a ping packet, it can do one of three things with the TTL field in its response:
- Not change it โ this is what Berkeley Unix systems did before the
4.3BSD Tahoerelease. In this case the TTL value in the received packet will be255minus the number of routers in the round-trip path. - Set it to
255โ this is what current Berkeley Unix systems do. In this case the TTL value in the received packet will be255minus the number of routers in the path from the remote system to the pinging host. - Set it to some other value โ some machines use the same value for ICMP packets that they use for TCP packets, for example either
30or60. Others may use completely wild values. ๐คช main character energy, honestly
๐ญ BUGS ๐ญ
- Many Hosts and Gateways ignore the
RECORD_ROUTEoption. - The maximum IP header length is too small for options like
RECORD_ROUTEto be completely useful. There's not much that can be done about this, however. ๐ฅฒ - Flood pinging is not recommended in general, and flood pinging the broadcast address should only be done under very controlled conditions.
bestie, pls do not flood ping the broadcast address on a whim. that's not a cute look, that's a whole incident. ๐ซ
๐ SEE ALSO ๐
๐ HISTORY ๐
The ping command appeared in 4.3BSD. ๐ฐ๏ธ
The version described here is its descendant specific to Linux. ๐ง
As of version s20150815, the ping6 binary doesn't exist anymore. It has been merged into ping. Creating a symlink named ping6 pointing to ping will result in the same functionality as before. the way they just merged them, iconic ๐
๐ฅ SECURITY ๐ฅ
ping requires CAP_NET_RAW capability to be executed:
- if the program is used for non-echo queries (see
-Noption) or when the identification field set to0forECHO_REQUEST(see-e), or - if kernel does not support ICMP datagram sockets, or
- if the user is not allowed to create an ICMP echo socket.
The program may be used as set-uid root. โ ๏ธ
๐ AVAILABILITY ๐
ping is part of the iputils package.
and that's the whole page, bestie!! ๐ you just read the iputils 20250605 version of PING(8) โ yes that's the source and version, and yes she's serving section-8 realness. go ping something and be free ๐ฆโจ
๐ฆ where this page comes from
- fedora 43: iputils 20250605-1.fc43 ยท BSD-4-Clause-UC AND GPL-2.0-or-later
- fedora 44: iputils 20250605-2.fc44 ยท BSD-4-Clause-UC AND GPL-2.0-or-later
- ubuntu resolute: iputils-ping 3:20250605-1ubuntu1 ยท BSD-3-Clause
- ubuntu stonking: iputils-ping 3:20250605-1ubuntu1 ยท BSD-3-Clause
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms