Ping is one of the most popular commands used in the networking world. Using this command, you can Ping an IP to troubleshoot network issues and check if the internet is working fine.
Moreover, pinging an IP address is very easy on Windows and Linux OS. The command lines used on both are almost similar.
In this article, we will walk you through the process of pinging an IP using the command-line functions on CMD, Powershell, and the Linux Terminal.
How to Ping An IP Address on Windows?
To ping an IP Address on Windows, you must use Command Line Interface(CLI) tools like CMD and PowerShell. The process of pinging IP addresses is relatively easy. It requires you to execute some command lines with the desired IP address. If you are aware of the domain name (For instance, Google.com), you can also use it instead of the IP address.
Using CMD
CMD is the most commonly command-line interface to ping the IP address. Ping command line is used for it. You may use different variations to the ping command in a command prompt. You can see the list of ping options available by entering Ping in CMD.
To ping IP an IP using CMD, follow these steps,
- Press Windows Key + R. Type
CMD
and hit Enter. - Now, execute this command to ping the IP address
Ping 8.8.8.8
ping Google.com
)
Using PowerShell
You can also ping the IP address using Powershell too. Moreover, it can provide you with diverse ping outputs compared to the CMD.
Here’s how to ping an IP using PowerShell,
- Open Run by pressing Windows Key + R. Type
powershell
and hit Enter. - Now, enter
Test-Connection 8.8.8.8
.
This will ping to the IP and give you the desired output. - You can also ping multiple IP addresses using this command;
Test-Connection 8.8.8.8, 1.1.1.1
If you have many IPs to ping, you can do it in seconds using PowerShell. Here is one such quick command line for you that lets you do it and save the output result in a text format as well. Just follow these instructions,
- Save the IP addresses in a notepad and save it (in .txt). In the command, the list is saved under the name List of IPs.txt. Similarly, the output log will be saved under the name pinglog.txt.
- Open Powershell.
- Paste this command. Replace the source (after the Get-consent line) and output file (In the outputfile line) directory in the command line and execute it.
$ServerName = Get-Content "C:\Users\XYZ\OneDrive\Desktop\List of IPs.txt"
$outputfile = "C:\Users\XYZ\OneDrive\Desktop\pinglog.txt"
foreach ($Server in $ServerName)
{
$date = get-date
if (test-Connection -ComputerName $Server -Count 2 -Quiet )
{
"$Server is Pinging | $date" | out-file $outputfile -Append
}
else
{
"$Server NOT pinging | $date" | Out-File $outputfile -Append
}
}
- A ping log will be saved to your device in the specified location. You will see if the IP is getting pinged or not.
How to Ping An IP Address on Linux?
Similar to windows, Linux too has many ping options available for the users. It also requires you to enter the commands into the Linux Terminal. We will suggest you some useful command-line to ping IP addresses on Linux, which would work for all the distros.
Here is how to do it:
- Open the Terminal by pressing Ctrl + Alt + T.
- Type
ping 8.8.8.8
, and hit Enter. This will start the ping process. If you want to stop, it press Ctrl + C. - If you want to change the packet size for the ping, use this command,
ping -s 4 8.8.8.8
This command will only exchange 4 packets with the IP 8.8.8.8 for the process. Change the size in the command as per the requirement. - Similarly, to limit the ping packets to a specified number, use
ping -c 2 8.8.8.8
. This will stop the packet transmission at 2.
There are Some other important ping options you can use.
Ping Options | Use Case |
Ping -i <n> <IP Address> | Wait for ‘n’ seconds to send consecutive packets |
Ping -c <n> -q <Ip Address> | Get ping Summary |
Ping -w <n> <IP Address> | Stop ping after ‘n’ seconds |
Ping -c <m> -w <n> <Ip Address> | Set wait response time to ‘n’ for ‘m’ size of packets |