How to Ping Specific TCP Port in Linux & Windows

TCP Port Ping Test using paping

Today we are going to learn, How to ping and test a specific TCP port from windows to Linux system using powershell script.

In this article we will learn network utility tool called paping. Using this we can perform tcp ping test from Windows machine to Target Host

Also i created small small powershell script which will help us to check the multiple host reachability via tcp ports.  

Purpose of this post i created for, if your servers or client hosted in public cloud platform, you might not able to ping the servers using ICMP protocol.  Why because By default ICMP protocol blocked in the cloud NSG firewall perspective due to security reasons.

Also most of the Production On-premises environment ICMP might be blocked from network firewall end. so the normal ping command will not help to test the client or server reachability.

To overcome the normal ICMP ping test, i am going to show you how to ping target host via tcp ports using paping utility

For example

Step 1: Login to your Windows system(Desktop/Laptop)

Step 2: Make sure your windows system have the internet connectivity to download "paping" utility from this URL Download paping

Step 3: After the download extract the downloaded paping zipped package on your desktop.

Step 4: Open PowerShell and switch to your pa ping folder.

Step 5: Now it's time to perform tcp ping test from using paping tool.

> cd C:\Users\Desktop\paping_1.5.5_x86-64_windows

Let's test the tcpping test using paping utility to the Linux Host via SSH port 22.

.\paping.exe 192.168.0.10 -p 22 -c 1

Let's test the tcpping test using paping utility to the windows Host via RDP port 3389.

.\paping.exe 192.168.0.5 -p 3389 -c 1

I prepared a small tcp ping PowerShell script and below this the content of the script for your reference. This script will help us to check the multiple host reachability test via paping utility also  it will store the ping test success and failure result in the output file.

TCP Ping script for Linux Hosts via Port 22 SSH

Clear-HostClear-Content .\success.log -Force -ErrorAction SilentlyContinueClear-Content .\failure.log -Force -ErrorAction SilentlyContinue foreach($line in Get-Content .\ips.txt) {.\paping.exe $line -p 22 -c 1if ( $? -eq $True ){   $currentTime = Get-Date -Format “MM/dd/yyyy HH:mm K”    Write-Host $currentTime Node $line is up    "$(Get-Date -DisplayHint datetime) Node $line is up" | Tee-Object -FilePath "success.log" -Append}else{$currentTime = Get-Date -Format “MM/dd/yyyy HH:mm K” Write-Host $currentTime Node $line is down "$(Get-Date -DisplayHint datetime) Node $line is down" | Tee-Object -FilePath "failure.log" -Append }}

TCP Ping script for Windows Hosts via Port 3389 RDP

Clear-HostClear-Content .\success.log -Force -ErrorAction SilentlyContinueClear-Content .\failure.log -Force -ErrorAction SilentlyContinue foreach($line in Get-Content .\ips.txt) {.\paping.exe $line -p 3389 -c 1if ( $? -eq $True )
{   $currentTime = Get-Date -Format “MM/dd/yyyy HH:mm K”    Write-Host $currentTime Node $line is up        "$(Get-Date -DisplayHint datetime) Node $line is up" | Tee-Object -FilePath "success.log" -Append}else{$currentTime = Get-Date -Format “MM/dd/yyyy HH:mm K” Write-Host $currentTime Node $line is down "$(Get-Date -DisplayHint datetime) Node $line is down" | Tee-Object -FilePath "failure.log" -Append
 }}