Introduction
I don’t remember exactly when the idea of a simple solution to checking opened ports on machines came into my mind. All I know is that this task was unnecessary painful to me. So I thought about what would be the ideal solution. I came up with the idea that I want the exact same behavior ping gives me on the console and I wished I just could add a port number to it and it will work.
This is exactly the core functionallity behind pping (and thus the name!).
Installation
The easiest way to obtain and manage pping on your machine is to use chocolatey:
choco install pping
If you don’t want to pre-install choco on your box you could download the latest version via
- Windows x64: Latest version (SHA256: 6F98462191A770DF0592EE8FE91A2C4F4834092402BA8B673C1C2430EA2E45FB)
- Linux x64: Latest version (SHA256: C1962DB9679A0E8E7BEE7E86A7DC7B7A1AA637FDB4B4D9D365623EBB024FCC72)
and extract the contents of this 7zip into any folder. Then set add the directory you choosen to your PATH and use the tool.
Basic usage
The simplest possible call would be to check a single port on a DNS address or IP address. The following snippets checks, if port 80
is open on the address google.com
:
pping google.com 80
The result will be something like this:
> pping google.com 80
Starting pinging host google.com on TCP port(s) 80 4 times:
# 1 -> Pinging host google.com (IP:-) on TCP port 80 with timeout 1: OPEN
# 2 -> Pinging host google.com (IP:-) on TCP port 80 with timeout 1: OPEN
# 3 -> Pinging host google.com (IP:-) on TCP port 80 with timeout 1: OPEN
# 4 -> Pinging host google.com (IP:-) on TCP port 80 with timeout 1: OPEN
Finished pinging host google.com (IP:-). 4 pings sent (4 OPEN, 0 CLOSED)
By default pping will try to reach a port 4 times.If you want pping to resolve the IP address behind a DNS entry just add the -res
parameter:
pping google.com 80 -res
Starting pinging host google.com on TCP port(s) 80 4 times:
# 1 -> Pinging host google.com (IP:2a00:1450:4005:808::200e) on TCP port 80 with timeout 1: OPEN
# 2 -> Pinging host google.com (IP:2a00:1450:4005:808::200e) on TCP port 80 with timeout 1: OPEN
# 3 -> Pinging host google.com (IP:2a00:1450:4005:808::200e) on TCP port 80 with timeout 1: OPEN
# 4 -> Pinging host google.com (IP:2a00:1450:4005:808::200e) on TCP port 80 with timeout 1: OPEN
Finished pinging host google.com (IP:2a00:1450:4005:808::200e). 4 pings sent (4 OPEN, 0 CLOSED)
You can perform constant pings too:
pping google.com 80 -t
This will perform and “endless” ping to the address.
Special usage
Waiting for a port to open
On of the common scenarios to use ping is to determine, if a certain service is already up. Consider a situation where you restart a server and want to know, when RDP connections are possible. A simple ping would’nt help you here because even if the machine is up, the RDP port (3389) might no be reachable yet.
pping can help you in this situation:
pping myserver.local 3389 -t -as
You perform a permanent pping (-t
) but you tell pping to stop pinging when the port is reachable the first time (-as
). “as” is the abbreviation for “autostop”.
Multiple ports
If you want to check lets say 2 ports (http and https) on a certain address. Just delimit the ports by ,
:
pping google.com 80,443 -d
Starting pinging host google.com on TCP port(s) 80,443 4 times:
# 1 -> Pinging host google.com (IP:-) on TCP port 80 with timeout 1: CLOSED (TimedOut)
# 2 -> Pinging host google.com (IP:-) on TCP port 443 with timeout 1: CLOSED (TimedOut)
# 3 -> Pinging host google.com (IP:-) on TCP port 80 with timeout 1: OPEN
# 4 -> Pinging host google.com (IP:-) on TCP port 443 with timeout 1: OPEN
# 5 -> Pinging host google.com (IP:-) on TCP port 80 with timeout 1: OPEN
# 6 -> Pinging host google.com (IP:-) on TCP port 443 with timeout 1: OPEN
# 7 -> Pinging host google.com (IP:-) on TCP port 80 with timeout 1: OPEN
# 8 -> Pinging host google.com (IP:-) on TCP port 443 with timeout 1: OPEN
Finished pinging host google.com (IP:-). 8 pings sent (6 OPEN, 2 CLOSED)
It is also possible to define a range of ports by delimiting them with ’-‘:
pping google.com 80-82 -d
Starting pinging host google.com on TCP port(s) 80-82 4 times:
# 1 -> Pinging host google.com (IP:-) on TCP port 80 with timeout 1: OPEN
# 2 -> Pinging host google.com (IP:-) on TCP port 81 with timeout 1: CLOSED (TimedOut)
# 3 -> Pinging host google.com (IP:-) on TCP port 82 with timeout 1: CLOSED (TimedOut)
# 4 -> Pinging host google.com (IP:-) on TCP port 80 with timeout 1: OPEN
# 5 -> Pinging host google.com (IP:-) on TCP port 81 with timeout 1: CLOSED (TimedOut)
# 6 -> Pinging host google.com (IP:-) on TCP port 82 with timeout 1: CLOSED (TimedOut)
# 7 -> Pinging host google.com (IP:-) on TCP port 80 with timeout 1: OPEN
# 8 -> Pinging host google.com (IP:-) on TCP port 81 with timeout 1: CLOSED (TimedOut)
# 9 -> Pinging host google.com (IP:-) on TCP port 82 with timeout 1: CLOSED (TimedOut)
# 10 -> Pinging host google.com (IP:-) on TCP port 80 with timeout 1: OPEN
# 11 -> Pinging host google.com (IP:-) on TCP port 81 with timeout 1: CLOSED (TimedOut)
# 12 -> Pinging host google.com (IP:-) on TCP port 82 with timeout 1: CLOSED (TimedOut)
Finished pinging host google.com (IP:-). 12 pings sent (4 OPEN, 8 CLOSED)
Option table
The following table lists all available options:
Abbreviation | Full name | Sample | Purpose |
---|---|---|---|
t | endless | -t | Perform a constant pping. |
r | repeats | -r 10 | Number of repeats in a non-endless pping (defaults to 4) |
tim | timeout | -tim 2 | Timeout in seconds (defaults to 1) |
l | logo | -logo | If provided, pping will print detailed header informations. |
res | resolve | -res | If provided, pping will resolve the IP address for each pping. |
a | autostop | -a | If provided, pping will stop operation on the first opened port. |
els | elsucc | -els | If provided, the process will retrieve the amount of opened ports as the process-result to DOS. |
elf | elfail | -elf | If provided, the process will return 0 if there was at least one open port, otherwise it returns 1. |
w | waittime | -w 2000 | The amount of milliseconds to wait between 2 ppings. |
d | detailed | -d | If provided, pping will try to write reason details at closed ports to te console. |
4 | ipv4 | -4 | If provided, pping will use IPv4 for resolutions. |
6 | ipv6 | -6 | If provided, pping will use IPv6 for resolutions. |