Thursday 1 November 2012

Free ports in Linux

Problem: Want to find free ports in Linux. 
Solution:  You can use  nc (or netcat) utility to do port scanning and find out free ports in the system.
Example:
Below command list ports that are binded from 1-10000

 
[root@dragon ~]# nc -z localhost 1-10000
Connection to localhost 22 port [tcp/ssh] succeeded!
Connection to localhost 25 port [tcp/smtp] succeeded!
Connection to localhost 111 port [tcp/sunrpc] succeeded!
Connection to localhost 631 port [tcp/ipp] succeeded!
Connection to localhost 925 port [tcp/*] succeeded!
Connection to localhost 2207 port [tcp/*] succeeded!
Connection to localhost 2208 port [tcp/*] succeeded!
Connection to localhost 4105 port [tcp/*] succeeded!
Connection to localhost 4728 port [tcp/*] succeeded!
Connection to localhost 5222 port [tcp/xmpp-client] succeeded!
Connection to localhost 5229 port [tcp/*] succeeded!
Connection to localhost 5269 port [tcp/xmpp-server] succeeded!
Connection to localhost 7005 port [tcp/afs3-volser] succeeded!
Connection to localhost 7070 port [tcp/arcp] succeeded!
Connection to localhost 7080 port [tcp/*] succeeded!
Connection to localhost 7777 port [tcp/cbt] succeeded!
Connection to localhost 8005 port [tcp/*] succeeded!
Connection to localhost 8009 port [tcp/*] succeeded!
Connection to localhost 8010 port [tcp/*] succeeded!
Connection to localhost 8080 port [tcp/webcache] succeeded!
Connection to localhost 8222 port [tcp/*] succeeded!
Connection to localhost 8223 port [tcp/*] succeeded!
Connection to localhost 8224 port [tcp/*] succeeded!
Connection to localhost 8225 port [tcp/*] succeeded!
Connection to localhost 9005 port [tcp/*] succeeded!
Connection to localhost 9009 port [tcp/pichat] succeeded!
Connection to localhost 9080 port [tcp/glrpc] succeeded!
Connection to localhost 9090 port [tcp/websm] succeeded!

No comments:

Post a Comment