December 21, 2009

Linux port scanning with netcat (nc) command

Q. How do I find out which ports are opened on my own server? How do I run port scanning using nc command?

A. It may be useful to know which ports are open and running services on a target machine. You can use nmap command for port scanning.

If nmap is not installed try nc / netcat command. The -z flag can be used to tell nc to report open ports, rather than initiate a connection.

Run nc command with -z flag. You need to specify host name / ip along with the port range to limit and speedup operation.
$ nc -z vip-1.vsnl.nixcraft.in 1-1023
Output:

Connection to localhost 25 port [tcp/smtp] succeeded!
Connection to vip-1.vsnl.nixcraft.in 25 port [tcp/smtp] succeeded!
Connection to vip-1.vsnl.nixcraft.in 80 port [tcp/http] succeeded!
Connection to vip-1.vsnl.nixcraft.in 143 port [tcp/imap] succeeded!
Connection to vip-1.vsnl.nixcraft.in 199 port [tcp/smux] succeeded!
Connection to vip-1.vsnl.nixcraft.in 783 port [tcp/*] succeeded!
Connection to vip-1.vsnl.nixcraft.in 904 port [tcp/vmware-authd] succeeded!
Connection to vip-1.vsnl.nixcraft.in 993 port [tcp/imaps] succeeded!

No comments:

Post a Comment