How To Use ping In Windows MS-DOS (cmd.exe)?

Windows provides the ping command in order to check remote system network connectivity. The ping name comes from the “Packet Internet Groper”. The ping command is provided by Windows operating systems by default. Ping command can send ICMP packets to the specified targets where the targets can be specified as IP address or hostname.

Open MS-DOS (cmd.exe)

The MS-DOS is the command-line interface of the Windows operating systems. It is also called cmd.exe. Because after providing the Windows operating systems with a desktop ad GUI the MS-DOS operating system is provided as an executable called cmd.exe and all MS-DOS commands can be executed via this command-line interface.

MS-DOS or cmd.exe can be opened in different ways. We can open the cmd.exe from the Start menu by typing the cmd or msdos or command prompt which will list the Command Prompt. The Command Prompt is another name of the cmd.exe.

Open cmd.exe From Start Menu

Alternatively, the command line interface can be also opened from the Run where just type the cmd.exe and press the OK button or Enter key.

Open Command Line From Run

For more information about opening the command line interface or cmd please take a look at the following tutorial.

Display ping Command Help Information

Even the job of the ping tool is very simple it provides different parameters and options to configure the ping action. All of these features can be listed and displayed with the /? option like below. This will list options, parameters, and their meanings line by line.

> ping /?

The output will be like below where the syntax of the ping command is also provided.

Usage: ping [-t] [-a] [-n count] [-l size] [-f] [-i TTL] [-v TOS]
[-r count] [-s count] [[-j host-list] | [-k host-list]]
[-w timeout] [-R] [-S srcaddr] [-c compartment] [-p]
[-4] [-6] target_name
Options:
-t Ping the specified host until stopped.
To see statistics and continue - type Control-Break;
To stop - type Control-C.
-a Resolve addresses to hostnames.
-n count Number of echo requests to send.
-l size Send buffer size.
-f Set Don't Fragment flag in packet (IPv4-only).
-i TTL Time To Live.
-v TOS Type Of Service (IPv4-only. This setting has been deprecated
and has no effect on the type of service field in the IP
Header).
-r count Record route for count hops (IPv4-only).
-s count Timestamp for count hops (IPv4-only).
-j host-list Loose source route along host-list (IPv4-only).
-k host-list Strict source route along host-list (IPv4-only).
-w timeout Timeout in milliseconds to wait for each reply.
-R Use routing header to test reverse route also (IPv6-only).
Per RFC 5095 the use of this routing header has been
deprecated. Some systems may drop echo requests if
this header is used.
-S srcaddr Source address to use.
-c compartment Routing compartment identifier.
-p Ping a Hyper-V Network Virtualization provider address.
-4 Force using IPv4.
-6 Force using IPv6.

Ping IP Address

The ping command is generally used to check given remote IP address network connectivity. The IP address can be IPv4 or IPv6. In the following example, we will ping the popular DNS service IP address which is 8.8.8.8.

> ping 8.8.8.8

By default, the Windows ping commands send 4 ICMP packets which can be also called 4 ping packets to the target system. After 4 packets the ping command stops and provides information about the status of the packet, accessibility to the target system, etc. During the ping, every sent packet information is also printed on the screen with some basic information.

We can see that there are 4 lines below.

Reply from 8.8.8.8: bytes=32 time=38ms TTL=128
  • Reply from 8.8.8.8 specifies the replying target system which returns ICMP responses.
  • bytes=32 is the size of the ICMP packet
  • time=38ms is the RTT or round trip time.
  • TTL=128 is the TTL value for the ICMP packet.

The last lines provide general statistics about the ping.

Ping Hostname

The ping command can be also used to ping a hostname or domain name. But the DNS should be working properly and resolve the given domain name or hostname into an IP address. In the following example, we will ping the hostname windowstect.com.

> ping windowstect.com

The output will be like below where the hostname windowstect.com will be resolved into IP address 104.26.4.78 .

Set Packet Count

By default, the Windows ping command sends 4 ping packets or ICMP packets to the specified target. But in some cases, this may not enough and we may need to change the packet count for a longer test. We can specify the packet count with the -n option by providing the count we want. In the following example, we will send 10 ping or ICMP packets to the target. The -n is the short form of the number.

> ping -n 10 windowstect.com

Ping Continuously

By default, the Windows ping command only sends 4 ping or ICMP packets and then stops. But for the longer test, we may require to send a lot of packets which will be sent forever or unless we stop it. The continuous ping option can be used to ping packets repetitively forever. The continuous ping option is -t and there is no need to specify the packet count.

> ping -t windowstect.com

2 thoughts on “How To Use ping In Windows MS-DOS (cmd.exe)?”

Leave a Comment