IT Basics: The Ping Utility Explained
A ping, according to the dictionary, is a sharp, high-pitched, and somewhat musical tone. You might associate it with the sound you hear when you tap a spoon against a crystal glass. In the IT world, it has a very different meaning.
In this article, we will explain the basic concept of Ping, how the Ping utility works, and how it is utilized in the context of networking and network monitoring.
What Is a Ping?
A ping is a Command Prompt command that can be used to test a connection between one computer and another. Think of it in terms of sonar on a submarine. You’ve probably seen in the movies when the “ping” in the background as an audible signal is sent out to check a sub’s surroundings. When the ping strikes a nearby object, it will echo back. Operators can determine an object’s distance by the length of time it takes to return the echo.
How Does a Ping Work?
A ping is used to verify connectivity at an IP-level to a second TCP/IP device. It does this by transmitting Internet Control Message Protocol (ICMP) Echo Request messages and waits for a return message. Unless modified, the ping command will send 4 requests by default in Windows. How many responses get returned and how long it takes for the round-trip provide important information, such as:
- Bytes sent and received
- Packets sent, received, and lost
- Approximate round-trip time (in milliseconds)
The ping is initiated several times to test consistency in the connection. Here's what a successful ping request would return when connecting to a router.
Why Would I Use Ping?
If you’re ever run a speed test on your computer or network, you’ve used the ping command whether you knew it or not. You’re bouncing a message off a remote server and testing the amount of time it takes to return.
Pings are useful for a variety of reasons, including troubleshooting connectivity, devices, and networks.
Ping is used to troubleshoot connectivity. Most commonly, it’s used to verify the connection between two machines. You might use ping to test a network printer or copier connection to determine whether a device is offline or to verify you can connect to a router. If you’re having trouble with an application hosted over a network on a server, one of the first things you want to do is check the connection using a series of ping commands to help you narrow down the problem. If a ping comes back with fast response times, your connection is good so the problem likely lies with the server or application.
You can also ping websites to see if they are operating and whether there’s a problem with the connection.
Troubleshooting Networking Issues
Almost any network-connected device will respond to a ping which makes it incredibly valuable to check networking connections. Ping can be used to test routers or servers for throughput and speed. You can also ping across a range of addresses to find each attached device in a particular range. You can test computer names and addresses of computers. When you can ping an IP address, but not a computer name, there’s likely a name resolution issue.
If a ping comes back showing a successful connection but has long response times, you’re likely facing a routing, congestion, or networking issue.
A ping command can be run manually or automated as a scheduled task for monitor network reliability. When a ping fails, there’s a problem.
Ping Error Messages
If the ping command does not get a response from the host, you will see either nothing returned or get a timeout notification. Since it's sending 4 requests, you'll likely see four time out notices.
Ping Command Switches and Modifiers
The Ping command allows you to add modifiers or parameters (also called switches) to customize the command for troubleshooting. Here is a list of the commands and the proper syntax in which to use them for Windows, although you will find slight variations for Unix.
- /t - ping continues sending Echo request messages to the destination until interrupted manually. To interrupt and display statistics, press CTRL + Break. To interrupt and quit the ping, press CTRL + C.
- /a - the ping tries to resolve and show the hostname of an IP address that is entered as the target.
- /n count - use this change the number of Echo request messages from 4 (the default) to something else. You can use any number from 1 to 4294967295.
- /l size - sets the size (in bytes) of the Echo request message that is sent to the target, from 32 (the default) to something else. You can use any number from 1 to 65527.
- /f - use this to send Echo request messages with a "Do Not Fragment" flag turned on so that the request is not fragmented by routers, on the way to the destination. This option works for IPv4 addresses only, and it is useful for troubleshooting path Maximum Transmission Unit (PMTU) problems.
- /i TTL - sets the Time to Live (TTL) value for the Echo request, the maximum of which is 255. TTL limits the lifetime of the data being sent by the ping command. If the TTL value has elapsed and no reply was received, the data is discarded.
- /v TOS - sets the Type of Service (TOS) used for the Echo request. The default value is 0, and the maximum is 255. This option works only for IPv4 addresses.
- /r count - sets the number of hops between your PC and the target that you want be recorded and displayed by the ping command. The maximum value for the count is 9. It works only with IPv4 addresses.
- /s count - reports the time (in Internet Timestamp format) when each Echo request is received and each reply is sent. The maximum value for the count is 4, meaning that only the first four hops can be time stamped. This option works just with IPv4 addresses.
- /j host-list - uses the Loose Source Route specified in the host list. With this type of routing, successive intermediate destinations can be separated by one or multiple routers. The maximum number of addresses or names in the host list is 9. The host list is a series of IP addresses separated by spaces, and they have to be IPv4 addresses.
- /k host-list - uses the Strict Source Route specified in the host list. With strict routing, the next intermediate destination must be reachable directly (and not separated by a router). The maximum number of addresses or names in the host list is 9. The host list is a series of IPv4 addresses separated by spaces.
- /w timeout - the timeout value adjusts the amount of time, in milliseconds, that the ping waits for each reply. The default timeout value is 4000 or 4 seconds.
- /r range - tells the ping command to trace the round-trip path, for a number of hops. It works only with IPv6 addresses. The range must be a number between 1 and 9.
- /s srcaddr - specifies the source address to use when working with IPv6 addresses. The address must be entered after srcaddr.
- /c compartments - specifies the routing compartment identifier.
- /p - pings a Hyper-V Network Virtualization provider address.
- /4 - forces the use of the IPv4 address and it is used in conjunction with hostnames, not IP addresses. For example, write "ping /4 www.WEBSITENAME.com" (without the quotation marks), and it returns the IPv4 address of the hostname.
- /6 - forces the use of the IPv6 address and it is used in conjunction with hostnames, not IP addresses. For example, write "ping /6 www.WESBITENAME.com" and you see the IPv6 address of the hostname.
Proper Ping Syntax
The order in which you use these switches is important. Here’s is the proper syntax to use:
ping [-t] [-a] [-n count] [-l size] [-f] [-i TTL] [-v TOS] [-r count] [-s count] [-w timeout] [-R] [-S srcaddr] [-p] [-4] [-6] target [/?]
Network MonitoringSours: https://www.whatsupgold.com/blog/it-basics-the-ping-utility-explained
Applies to: Windows Server 2022, Windows Server 2019, Windows Server 2016, Windows Server 2012 R2, Windows Server 2012
Verifies IP-level connectivity to another TCP/IP computer by sending Internet Control Message Protocol (ICMP) echo Request messages. The receipt of corresponding echo Reply messages are displayed, along with round-trip times. ping is the primary TCP/IP command used to troubleshoot connectivity, reachability, and name resolution. Used without parameters, this command displays Help content.
You can also use this command to test both the computer name and the IP address of the computer. If pinging the IP address is successful, but pinging the computer name isn't, you might have a name resolution problem. In this case, make sure the computer name you are specifying can be resolved through the local Hosts file, by using Domain Name System (DNS) queries, or through NetBIOS name resolution techniques.
This command is available only if the Internet Protocol (TCP/IP) is installed as a component in the properties of a network adapter in Network Connections.
|/t||Specifies ping continue sending echo Request messages to the destination until interrupted. To interrupt and display statistics, press CTRL+ENTER. To interrupt and quit this command, press CTRL+C.|
|/a||Specifies reverse name resolution be performed on the destination IP address. If this is successful, ping displays the corresponding host name.|
|/n||Specifies the number of echo Request messages be sent. The default is 4.|
|/l||Specifies the length, in bytes, of the Data field in the echo Request messages. The default is 32. The maximum size is 65,527.|
|/f||Specifies that echo Request messages are sent with the Do not Fragment flag in the IP header set to 1 (available on IPv4 only). The echo Request message can't be fragmented by routers in the path to the destination. This parameter is useful for troubleshooting path Maximum Transmission Unit (PMTU) problems.|
|/I||Specifies the value of the Time To Live (TTL) field in the IP header for echo Request messages sent. The default is the default TTL value for the host. The maximum TTL is 255.|
|/v||Specifies the value of the Type Of Service (TOS) field in the IP header for echo Request messages sent (available on IPv4 only). The default is 0. TOS is specified as a decimal value from 0 through 255.|
|/r||Specifies the Record Route option in the IP header is used to record the path taken by the echo Request message and corresponding echo Reply message (available on IPv4 only). Each hop in the path uses an entry in the Record Route option. If possible, specify a count equal to or greater than the number of hops between the source and destination. The count must be a minimum of 1 and a maximum of 9.|
|/s||Specifies that the Internet timestamp option in the IP header is used to record the time of arrival for the echo Request message and corresponding echo Reply message for each hop. The count must be a minimum of 1 and a maximum of 4. This is required for link-local destination addresses.|
|/j||Specifies the echo Request messages use the Loose Source Route option in the IP header with the set of intermediate destinations specified in hostlist (available on IPv4 only). With loose source routing, successive intermediate destinations can be separated by one or multiple routers. The maximum number of addresses or names in the host list is 9. The host list is a series of IP addresses (in dotted decimal notation) separated by spaces.|
|/k||Specifies the echo Request messages use the Strict Source Route option in the IP header with the set of intermediate destinations specified in hostlist (available on IPv4 only). With strict source routing, the next intermediate destination must be directly reachable (it must be a neighbor on an interface of the router). The maximum number of addresses or names in the host list is 9. The host list is a series of IP addresses (in dotted decimal notation) separated by spaces.|
|/w||Specifies the amount of time, in milliseconds, to wait for the echo Reply message corresponding to a given echo Request message. If the echo Reply message is not received within the time-out, the "Request timed out" error message is displayed. The default time-out is 4000 (4 seconds).|
|/R||Specifies the round-trip path is traced (available on IPv6 only).|
|/S||Specifies the source address to use (available on IPv6 only).|
|/4||Specifies IPv4 used to ping. This parameter is not required to identify the target host with an IPv4 address. It is only required to identify the target host by name.|
|/6||Specifies IPv6 used to ping. This parameter is not required to identify the target host with an IPv6 address. It is only required to identify the target host by name.|
|Specifies the host name or IP address of the destination.|
|/?||Displays help at the command prompt.|
Example of the ping command output
To ping the destination 10.0.99.221 and resolve 10.0.99.221 to its host name, type:
To ping the destination 10.0.99.221 with 10 echo Request messages, each of which has a Data field of 1000 bytes, type:
To ping the destination 10.0.99.221 and record the route for 4 hops, type:
To ping the destination 10.0.99.221 and specify the loose source route of 10.12.0.1-10.29.3.1-10.1.44.1, type:
ping(8) - Linux man page
Nameping, ping6 - send ICMP ECHO_REQUEST to network hosts
ping [ -LRUbdfnqrvVaAB] [ -c count] [ -i interval] [ -l preload] [ -p pattern] [ -s packetsize] [ -t ttl] [ -w deadline] [ -F flowlabel] [ -I interface] [ -M hint] [ -Q tos] [ -S sndbuf] [ -T timestamp option] [ -W timeout] [ hop...] destination
ping uses the ICMP protocol's mandatory ECHO_REQUEST datagram to elicit an ICMP ECHO_RESPONSE from a host or gateway. ECHO_REQUEST datagrams (''pings'') 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.
- Audible ping.
- Adaptive ping. Interpacket interval adapts to round-trip time, so that effectively not more than one (or more, if preload is set) unanswered probes present in the network. Minimal interval is 200msec for not super-user. On networks with low rtt this mode is essentially equivalent to flood mode.
- Allow pinging a broadcast address.
- Do not allow ping to change source address of probes. The address is bound to one selected when ping starts.
- -c count
- Stop after sending count ECHO_REQUEST packets. With deadline option, ping waits for count ECHO_REPLY packets, until the timeout expires.
- Set the SO_DEBUG option on the socket being used. Essentially, this socket option is not used by Linux kernel.
- -F flow label
- Allocate and set 20 bit flow label on echo request packets. (Only ping6). If value is zero, kernel allocates random flow label.
- Flood ping. For every ECHO_REQUEST sent a period ''.'' is printed, while for ever ECHO_REPLY received a backspace is printed. This provides 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.
- -i interval
- Wait interval seconds between sending each packet. 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 0.2 seconds.
- -I interface address
- Set source address to specified interface address. Argument may be numeric IP address or name of device. When pinging IPv6 link-local address this option is required.
- -l preload
- If preload is specified, ping sends that many packets not waiting for reply. Only the super-user may select preload more than 3.
- Suppress loopback of multicast packets. This flag only applies if the ping destination is a multicast address.
- Numeric output only. No attempt will be made to lookup symbolic names for host addresses.
- -p pattern
- You may specify up to 16 ''pad'' bytes to fill out the packet you send. This is useful for diagnosing data-dependent problems in a network. For example, -p ff will cause the sent packet to be filled with all ones.
- -Q tos
- Set Quality of Service -related bits in ICMP datagrams. tos can be either decimal or hex number. Traditionally (RFC1349), these have been interpreted as: 0 for reserved (currently being redefined as congestion control), 1-4 for Type of Service and 5-7 for Precedence. Possible settings for Type of Service are: minimal cost: 0x02, reliability: 0x04, throughput: 0x08, low delay: 0x10. Multiple TOS bits should not be set simultaneously. Possible settings for special Precedence range from priority (0x20) to net control (0xe0). You must be root (CAP_NET_ADMIN capability) to use Critical or higher precedence value. You cannot set bit 0x01 (reserved) unless ECN has been enabled in the kernel. In RFC2474, these fields has been redefined as 8-bit Differentiated Services (DS), consisting of: bits 0-1 of separate data (ECN will be used, here), and bits 2-7 of Differentiated Services Codepoint (DSCP).
- Quiet output. Nothing is displayed except the summary lines at startup time and when finished.
- Record route. Includes the RECORD_ROUTE option in the ECHO_REQUEST packet and displays the route buffer on returned packets. Note that the IP header is only large enough for nine such routes. Many hosts ignore or discard this option.
- 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 -I is also used.
- -s packetsize
- Specifies the number of data bytes to be sent. The default is 56, which translates into 64 ICMP data bytes when combined with the 8 bytes of ICMP header data.
- -S sndbuf
- Set socket sndbuf. If not specified, it is selected to buffer not more than one packet.
- -t ttl
- Set the IP Time to Live.
- -T timestamp option
- Set special IP timestamp options. timestamp option may be either tsonly (only timestamps), tsandaddr (timestamps and addresses) or tsprespec host1 [host2 [host3 [host4]]] (timestamp prespecified hops).
- -M hint
- Select Path MTU Discovery strategy. hint may be either do (prohibit fragmentation, even local one), want (do PMTU discovery, fragment locally when packet size is large), or dont (do not set DF flag).
- 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.
- Verbose output.
- 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 after count packet are sent, it waits either for deadline expire or until count probes are answered or for some error notification from network.
- -W timeout
- Time to wait for a response, in seconds. The option affects only timeout in absense of any responses, otherwise ping waits for two RTTs.
When using ping for fault isolation, it should first be run 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 round-trip time numbers. 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 termination of process with signal SIGQUIT.
If ping does not receive any reply packets at all it will exit with code 1. If a packet count and deadline are both specified, and fewer than count packets are received by the time the deadline has arrived, it will also exit with code 1. On 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.
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.
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 indicated the size of this extra piece of data (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).
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.
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).
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.
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.
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 TCP/IP specification states that the TTL field for TCP packets should be set to 60, but many systems use smaller values (4.3 BSD uses 30, 4.2 used 15).
The maximum possible value of this field is 255, and most Unix systems set the TTL field of ICMP ECHO_REQUEST packets to 255. This is why you will find you can ''ping'' some hosts, but not reach them with telnet(1) or ftp(1).
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 Tahoe release. In this case the TTL value in the received packet will be 255 minus 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 be 255 minus 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 30 or 60. Others may use completely wild values.
- Many Hosts and Gateways ignore the RECORD_ROUTE option.
- The maximum IP header length is too small for options like RECORD_ROUTE to be completely useful. There's not much that 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.
The ping command appeared in 4.3BSD.
The version described here is its descendant specific to Linux.
ping requires CAP_NET_RAWIO capability to be executed. It may be used as set-uid root.
ping is part of iputils package and the latest versions are available in source form at http://www.skbuff.net/iputils/iputils-current.tar.bz2.
Referenced Byarping(8), bing(8), clockdiff(8), cytune(8), fping(8), hping2(8), hping3(8), ipmiping(8), ipsec_ikeping(8), irdaping(8), iwspy(8), libval_shim(3), mtr(8), omping(8), oping(8), ping_selinux(8), rdisc(8), rds-ping(1), rmcpping(8), sonar(1), sonar(6), tcptraceroute(1), tping(1), tracepath(8), traceroute(8), virt-rescue(1)
Each PC and corresponding VLAN interface must be in the same subnet. The PC will also need to have a default gateway set to point to the IP address of the switch.
You need to think about this from the perspective of routing tables. Nodes consult their routing table to figure out where to transmit data. Here's an example using /24 masks since you didn't specify the subnet masks above.
PC A: 100.100.100.3/24 (/24 means 255.255.255.0) without a default gateway set will have only a few entries in it's routing table. The first will be 100.100.100.3/32 since its on the machine itself, the other will 100.100.100.0/24. The PC interprets this to mean it doesn't have to go anywhere else to reach 100.100.100.1-254 it can reach those addresses on the interface you set the IP on. Now... once you add a default gateway (which must be on a network you are CONNECTED to), then you'll have an entry for 0.0.0.0 to 100.100.100.5.
To make your entire network function, this is how you'd do it:
The switch should not need a default gateway or any other routes set. If it's a Cisco switch, do not forget the command "ip routing" or the switch will not perform inter-vlan routing.
EDIT: Also, if it helps you comprehend a little better, someone once summed this up in a way that made everything click for me when I kept asking "why do we we need subnets". His simple answer was "So the damn routers know what to do!"
As a homework assignment, you should read and digest this information: How does IPv4 Subnetting Work?
The ping command is a Command Prompt command used to test the ability of the source computer to reach a specified destination computer. It's usually used as a simple way to verify that a computer can communicate over the network with another computer or network device.
The ping command operates by sending Internet Control Message Protocol (ICMP) Echo Request messages to the destination computer and waiting for a response. How many of those responses are returned, and how long it takes for them to return, are the two major pieces of information that the ping command provides.
For example, you might find that there are no responses when pinging a network printer, only to find out that the printer is offline and its cable needs replaced. Or maybe you need to ping a router to verify that your computer can connect to it, to eliminate it as a possible cause for a networking issue.
The word "ping" is also used online to refer to a brief message, usually over text message or email. For example, you can "ping your boss," or send her a message, when you're done with a specific project, but it has nothing to do with the ping command.
Ping Command Availability
The ping command is available from within the Command Prompt in Windows 10, Windows 8, Windows 7, Windows Vista, and Windows XP operating systems. It's also available in older versions of Windows like Windows 98 and 95.
This command can also be found in Command Prompt in the Advanced Startup Options and System Recovery Options repair/recovery menus.
Ping Command Syntax
ping [-t] [-a] [-ncount] [-lsize] [-f] [-iTTL] [-vTOS] [-rcount] [-scount] [-wtimeout] [-R] [-Ssrcaddr] [-p] [-4] [-6] target [/?]
The availability of certain ping command switches and other ping command syntax might differ from operating system to operating system. See How to Read Command Syntax if you're not sure how to interpret the ping command syntax as it's described above or in the table below.
|Ping Command Options|
|-t||Using this option will ping the target until you force it to stop by using Ctrl+C.|
|-a||This ping command option will resolve, if possible, the hostname of an IP addresstarget.|
|-ncount||This option sets the number of ICMP Echo Requests to send, from 1 to 4294967295. The ping command will send 4 by default if -n isn't used.|
|-lsize||Use this option to set the size, in bytes, of the echo request packet from 32 to 65,527. The ping command will send a 32-byte echo request if you don't use the -l option.|
|-f||Use this ping command option to prevent ICMP Echo Requests from being fragmented by routers between you and the target. The -f option is most often used to troubleshoot Path Maximum Transmission Unit (PMTU) issues.|
|-iTTL||This option sets the Time to Live (TTL) value, the maximum of which is 255.|
|-vTOS||This option allows you to set a Type of Service (TOS) value. Beginning in Windows 7, this option no longer functions but still exists for compatibility reasons.|
|-rcount||Use this ping command option to specify the number of hops between your computer and the target computer or device that you'd like to be recorded and displayed. The maximum value for count is 9, so use the tracert command instead if you're interested in viewing all the hops between two devices.|
|-scount||Use this option to report the time, in Internet Timestamp format, that each echo request is received and echo reply is sent. The maximum value for count is 4, meaning that only the first four hops can be time stamped.|
|-wtimeout||Specifying a timeout value when executing the ping command adjusts the amount of time, in milliseconds, that ping waits for each reply. If you don't use the -w option, the default timeout value of 4000 is used, which is 4 seconds.|
|-R||This option tells the ping command to trace the round trip path.|
|-Ssrcaddr||Use this option to specify the source address.|
|-p||Use this switch to ping a Hyper-V Network Virtualization provider address.|
|-4||This forces the ping command to use IPv4 only but is only necessary if target is a hostname and not an IP address.|
|-6||This forces the ping command to use IPv6 only but as with the -4 option, is only necessary when pinging a hostname.|
|target||This is the destination you wish to ping, either an IP address or a hostname.|
|/?||Use the help switch with the ping command to show detailed help about the command's several options.|
The -f, -v, -r, -s, -j, and -k options work when pinging IPv4 addresses only. The -R and -S options only work with IPv6.
Other less commonly used switches for the ping command exist including [-jhost-list], [-khost-list], and [-ccompartment]. Execute ping /? from the Command Prompt for more information on these options.
Ping Command Examples
Below are several examples of commands that use ping.
In this example, the ping command is used to ping the hostnamewww.google.com. The -n option tells the ping command to send 5 ICMP Echo Requests instead of the default of 4, and the -l option sets the packet size for each request to 1500 bytes instead of the default of 32 bytes.
The result displayed in the Command Prompt window will look something like this:
The 0% loss reported under Ping statistics for 126.96.36.199 explains that each ICMP Echo Request message sent to www.google.com was returned. This means that, as far as this network connection goes, it can communicate with Google's website just fine.
In the above example, we're pinging 127.0.0.1, also called the IPv4 localhost IP address or IPv4 loopback IP address, without options.
Using the ping command with this address is an excellent way to test that Windows' network features are working properly but it says nothing about your own network hardware or your connection to any other computer or device. The IPv6 version of this test would be ping ::1.
Find Hostname With Ping
In this example, we're asking the ping command to find the hostname assigned to the 192.168.1.22 IP address, but to otherwise ping it as normal.
The command might resolve the IP address, 192.168.1.22, as the hostname J3RTY22, for example, and then execute the remainder of the ping with default settings.
Ping Router Command
Similar to the ping command examples above, this one is used to see if your computer can reach your router. The only difference here is that instead of using a ping command switch or pinging the localhost, we're checking the connection between the computer and the router (192.168.2.1 in this case).
If you're having trouble logging in to your router or accessing the internet at all, see if your router is accessible with this ping command, of course, replacing 192.168.2.1 with your router's IP address.
Ping With IPv6
In this example, we force the ping command to use IPv6 with the -6 option and continue to ping SERVER indefinitely with the -t option. You can interrupt the ping manually with Ctrl+C.
The number after the % in the replies generated in this ping command example is the IPv6 Zone ID, which most often indicates the network interface used. You can generate a table of Zone IDs matched with your network interface names by executing netsh interface ipv6 show interface. The IPv6 Zone ID is the number in the Idx column.
Ping Related Commands
The ping command is often used with other networking related Command Prompt commands like tracert, ipconfig, netstat, and nslookup.
Other Ping Uses
Given the results you see above, it's clear that you can also use the ping command to find a website's IP address. Follow that link to learn more about how to do that.
You can also use ping on a Linux computer, and third-party ping tools exist as well which offer more features than the basic ping command.
Thanks for letting us know!
What is Ping?
Ping is a command-line utility, available on virtually any operating system with network connectivity, that acts as a test to see if a networked device is reachable.
The ping command sends a request over the network to a specific device. A successful ping results in a response from the computer that was pinged back to the originating computer.
What does Ping stand for?
According to the author, the name Ping comes from sonar terminology. In sonar, a ping is an audible sound wave sent out to find an object. If the sound hits the object, the sound waves will reflect, or echo, back to the source. The distance and location of the object can be determined by measuring the time and direction of the returning sound wave.
Similarly, the ping command sends out an echo request. If it finds the target system, the remote host sends back an echo reply. The distance (number of hops) to the remote system can be determined from the reply, as well as the conditions in-between (packet loss and time to respond). While the author of the ping utility said the name of the program was simply based on the sound of sonar, others sometimes say that Ping is an acronym for Packet InterNet Groper.
The Ping utility uses the echo request, and echo reply messages within the Internet Control Message Protocol (ICMP), an integral part of any IP network. When a ping command is issued, an echo request packet is sent to the address specified. When the remote host receives the echo request, it responds with an echo reply packet.
By default, the ping command sends several echo requests, typically four or five. The result of each echo request is displayed, showing whether the request received a successful response, how many bytes were received in response, the Time to Live (TTL), and how long the response took to receive, along with statistics about packet loss and round trip times.
The echo request ("ping") is structured as follows:
|Byte 0||Byte 1||Byte 2||Byte 3|
|Type (8 = IPv4, ICMP; 128 = IPv6, ICMP6)||Code||Header Checksum|
The echo reply must include the exact payload received in the request:
|Byte 0||Byte 1||Byte 2||Byte 3|
|Type (0 = IPv4, ICMP; 129 = IPv6, ICMP6)||Code||Header Checksum|
The ping utility has been incorporated into virtually every operating system with network support. While echo request and echo reply are ICMP messages, the exact implementation of the Ping utility varies slightly among manufacturers.
In its simplest form, the ping utility can be run with nothing more than the ping command and a destination. The remote host can be specified either by name or address.
The following is the output of a simple ping to the target host paessler.com:
Pinging paessler.com [188.8.131.52] with 32 bytes of data:
Reply from 184.108.40.206: bytes=32 time=4ms TTL=57
Reply from 220.127.116.11: bytes=32 time=4ms TTL=57
Reply from 18.104.22.168: bytes=32 time=4ms TTL=57
Reply from 22.214.171.124: bytes=32 time=4ms TTL=57
Ping statistics for 126.96.36.199:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 4ms, Maximum = 4ms, Average = 4ms
However, the ping utility also provides several customizable options.
Ping switches and variables
There are numerous switches available for the ping command that allow the default settings to be customized for more specific purposes. Unfortunately, there is no consistency across platforms for the different switches. For example, Windows uses a -n (number) to set how many pings to send, while most Unix systems use a -c (count).
Here are some examples of ping command switches. Generally, using ping -? will result in a list of switches along with the corresponding letter to use the switch on the operating system.
Number (or count) – sets the number of echo requests, or pings, to be sent. By default, this number is four on most Windows systems, and five on most Unix systems. Setting a higher number allows the ping to continue to run either as a way of gathering more data, for example, to see if the reply time varies, or as a way of ensuring that a system continues to be responsive.
Timeout– changes the timeout before the utility waits for a reply from the destination. On Windows systems, the default value is 4,000 milliseconds, or 4 seconds.
Size– changes the size of the ping packet. The default value on Windows is 32 bytes, many Unix/Linux systems default to 64 bytes.
TTL – sets a different TTL.
IP4 or IP6– responds with IPv4 or IPv6 addresses. (ping -4/ping -6 in Windows, ping or ping6 in Linux)
Until stopped – keeps running the ping until stopped by the user (-t in Windows)
Ping command syntax for Windows
|-t||Pings the specified host until stopped. To stop - type Control-C|
|-a||Resolve adresses to hostnames|
|Number of echo requests to send|
|-l||Send buffer size|
|-f||Set Don't Fragmet flag in packet (IPv4-only)|
|-i||Set Time To Live|
|-v||Set Type of Service (Setting has been deprecated)|
|-r||Record route for count hops (IPv4-only)|
|-s||Timestamp for count hops (IPv4-only)|
|-j||Loose source route along host-list (IPv4-only)|
|-k||Strict source route along host-list (IPv4-only)|
|-w||Timeout in milliseconds to wait for each reply|
|-R||Use routing header to test reverse route also (IPv6-only, deprecated per RFC 5095)|
|-S||Source address to use|
|-c||Routing compartment identifier|
|-p||Ping a Hyper-V Network Virtualization provider address|
|-4||Force using IPv4|
|-6||Force using Ipv6|
For such a small, basic utility, the ping command can be a valuable tool in numerous situations. As a command-line based utility, ping lends itself to easy use in various scripts, allowing for numerous pings to run and be recorded for all manner of usage. For example, the output of the ping command can easily be piped to a text file for later review.
Troubleshooting with Ping
Perhaps the most common use of the ping utility is in troubleshooting. When trying to use applications or systems over a network, the most important thing to know is if there is actually a working connection. A series of ping commands can help determine what the problem is.
A quick ping by IP address will confirm that the system is on, that there is a connection, and that the two machines can talk to each other.
If the ping is successful by name and IP address, but the response times are long, there may be a routing, network speed, or congestion issue. Even unsuccessful pings can provide valuable troubleshooting information.
If a ping by IP address is successful, but a ping by name fails, then there is a name resolution issue. If the ping fails altogether, you can try to ping other parts of the network to isolate the issue. A successful ping of the default gateway confirms that the network connection is functioning, but that something is interfering with a connection to the remote system.
If you can ping successfully with the same subnet of the remote system, but not the target system itself, then the network connectivity of the remote host is in doubt. If the default gateway cannot be pinged, but the loopback address (127.0.0.1) results in a successful ping, then you would know that the network interface is functioning, but there is no connection to the network.
If ping gets no response from the target host, most implementations of ping display nothing or a timeout notification. The result may look like this, for example:
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Ping can be used as a quick and dirty discovery tool. Since virtually any network connected device will respond to a ping, pinging a range of addresses, for example, would allow an administrator to find all the attached devices in that range, regardless of type of device or operating system.
Ping can be used to monitor the network availability of devices. A ping command running as a scheduled task can offer rudimentary polling of any networked computer or device without the need to install any additional software agents, and without the need to open additional ports. The most basic of any up/down monitor could be accomplished by running a ping with the ‘run until stopped’ option. When the pings start failing, there is an issue reaching the system.
Obviously, these solutions are greatly improved upon by the addition of a monitoring tool like PRTG, which, while using underlying ping commands, does not rely on someone watching the output, or piping the output to some sort of record.
The standard Ping Sensor runs ping commands in the background. These can be configured to run at specific intervals, or in response to another event. For example, if a sensor reports a connection failure, a ping can determine if there is still a network connection. Or, monitors can be configured to alert an administrator if ping times get too long, or if there is too much packet loss.
Another interesting ping-based sensor is the Cloud Ping Sensor, which pings monitored systems from a remote cloud of distributed systems. This provides the all-important, but difficult to detect, alert when everything is running just fine on your end, but for whatever reason, your systems are unreachable from the outside by remote users or clients.
Simply knowing a system exists and is connected to the network may be enough information for an attacker to begin. Careful analysis of ping replies may yield additional information such as which operating system the target is running, where the machine is located, and so on.
Many hacking tools take advantage of “walking the range”, by pinging every IP address on a targeted network to get a list of what systems are reachable and will respond. As a result, many firewalls are configured to block ping requests from untrusted networks.
You will also like:
- Msi rx 480 gaming x
- Honda civic transmission flush?
- Harmonica licks
- Blue corvette
- How to register canon printer
- Gun polishing service near me
- Infected eczema pictures
- Thunderbolt connection
i tried to browse all available answers on this subject, but it's still not clear to me what a switch can or can't do.
I understand that when a host sends out a ping command, for instance ping 192.168.1.5, the switch will only look at the frames, since it is a very simple version of a switch that doesn't operate in layer 3. But in my case, when using this ping command i do get a response from another host, so it seems that the switch did some routing?
Also, when a host is sending a packet to another host on the same switch network, before the ARP process, how does the sending host know the recipient's MAC address in the first place, if they didn't communicate before?
Thanks for the answers!
asked Jun 16 '18 at 8:00