tags:

views:

5225

answers:

9

Hi,

Just a quick sanity check here.

Can you ping a specific port of a machine and if so in the answer can you provide an example?

Im a looking for something likeping ip address portNum

Thanks!

+11  A: 

You can't ping ports, as Ping is using ICMP which doesn't have the concept of ports itself. Ports belong to the IP family of protocols (with TCP and UDP beeing its famous transport layer protocols). However, you could use nmap to see whether ports are open or not

nmap -p 80 example.com

Edit: As flokra mentioned, nmap is more than just a ping-for-ports-thingy. It's the security auditers and hackers best friend and comes with tons of cool options. Check the doc for all possible flags.

sfussenegger
You might want to add `-PN` to skip the host discovery nmap usually does before testing the given port.
flokra
+4  A: 

No.

There's no guarantee that the service running on the port understands ping. It also opens up the question of what "flavor" of port you want to ping, TCP or UDP? Since the ping "protocol" uses neither (ping is implemented using ICMP), it doesn't make a lot of sense.

unwind
+1  A: 

No, you can't, because ping uses the ICMP protocol, which doesn't even have a conecpt of ports.

Martin B
+1  A: 

i'm feeling lucky on google for “ping a specific port”: http://philwilks.blogspot.com/2008/01/ping-specific-port.html, so NO, you cannot ping a specific port

you can use nmap though: nmap -p <port> <host>

knittl
+4  A: 

Open a telnet session to the specific port .

telnet ip address portNum

Pipo
+1  A: 

Ping is very specific but if you want to check whether a port is open or not, and are running a Windows box then PortQry is your friend.

I've only used it for testing Domain Controllers for connectivity issues, but it worked a treat for that, so should work for you.

Rob
PortQry works great and its only 140kb. Thanks!
Dawkins
+1  A: 

I'm quite sure that Nagios check_tcp probe does what you want. They can be found here and although designed to be used in a Nagios context, they're all standalone programs.

$ ./check_tcp -H host -p 22
TCP OK - 0.010 second response time on port 22|time=0.009946s;0.000000;0.000000;0.000000;10.000000
fvu
A: 

You can use PaPing:

http://code.google.com/p/paping

C:\>paping.exe www.google.com -p 80 -c 4
paping v1.5.1 - Copyright (c) 2010 Mike Lovell

Connecting to www.l.google.com [209.85.225.147] on TCP 80:

Connected to 209.85.225.147: time=24.00ms protocol=TCP port=80
Connected to 209.85.225.147: time=25.00ms protocol=TCP port=80
Connected to 209.85.225.147: time=24.00ms protocol=TCP port=80
Connected to 209.85.225.147: time=24.00ms protocol=TCP port=80

Connection statistics:
        Attempted = 4, Connected = 4, Failed = 0 (0.00%)
Approximate connection times:
        Minimum = 24.00ms, Maximum = 25.00ms, Average = 24.25ms
CodhubIV
A: 

Or instead of paping you could use cryping which has been around much longer and supports pinging of some services as well as ports.

Brian Cryer