November 2024
M T W T F S S
 123
45678910
11121314151617
18192021222324
252627282930  

Categories

November 2024
M T W T F S S
 123
45678910
11121314151617
18192021222324
252627282930  

Port scanning with netcat (nc) command

Port scanning with netcat (nc) command

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 test.rmohan.com 1-1023
Output:

Connection to localhost 25 port [tcp/smtp] succeeded!
Connection to test.rmohan.com 25 port [tcp/smtp] succeeded!
Connection to test.rmohan.com 80 port [tcp/http] succeeded!
Connection to test.rmohan.com 143 port [tcp/imap] succeeded!
Connection to test.rmohan.com 199 port [tcp/smux] succeeded!
Connection to test.rmohan.com 783 port [tcp/*] succeeded!
Connection to test.rmohan.com 904 port [tcp/vmware-authd] succeeded!
Connection to test.rmohan.com993 port [tcp/imaps] succeeded!

[root@localhost thermal_zone]# nc -z localhost 1-1023
Connection to localhost 22 port [tcp/ssh] succeeded!
Connection to localhost 111 port [tcp/sunrpc] succeeded!

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>