views:

2157

answers:

4

I need a command line that can check the port status on a remote host. I tried ping xxx.xxx.xxx.xxx:161 but it doesn't recognize the "host". I thought it was a "good" answer until I did the same command against a host I know has that port open. This is for a batch file on Windows that will check the status of the remote port then run a command that uses that remote port for information, then the remote port check command again, then the command that uses that port on the next server for information, and so on. I've looked everywhere and thought the ping might do it, but there must be various versions of ping, I suppose as the server I am doing this on does not show that option.

Just for chuckles, I tried a web-based remote port checker from a website - and the results were correct for both the "problem" server and the correct server. However, I can't use that in a batch run with 500+ server IPs in it.

Is there something I can do that is simple? My perl skills are extremely rusty (use it or lose it), don't know any other windows based langs except DOS. Unix is my skill, but this must be executed from win2003.

+1  A: 

I think you're looking for Hping (http://www.hping.org/), which has a Windows version.

"The interface is inspired to the ping(8) unix command, but hping isn't only able to send ICMP echo requests. It supports TCP, UDP, ICMP..."

It's also very useful if you want to see where along a route that a TCP port is being blocked (like by a firewall), where ICMP might not be.

Trueblood
+2  A: 

You seem to be looking for a port scanner such as nmap or netcat, both of which are available for Windows, Linux, and Mac OS X.

For example, check for telnet on a known ip:

nmap -A 192.168.0.5/32 -p 23

For example, look for open ports from 20 to 30 on host.example.com:

nc -z host.example.com 20-30
Glenn
It has port to Windows too
dimba
Both of these are available for Windows.
Glenn
A: 

nc or 'netcat' also has a scan mode which may be of use.

caskey
A: 

hehe, nmap rise all bells on your corporate firewall :) I used simple tool for that http://porttest.blogspot.com/2010/10/here-is-how-application-is-looks-like.html

akeru