Wednesday 15 February 2012

Command to check the opened/closed ports in a server

You can check with the following command to see the opened/closed ports of a server:

======
# nmap -P0 -T4 -sV -p-
Server_IP_Address

Starting Nmap 5.00 ( http://nmap.org ) at 2012-02-16 06:28 IST
Connect Scan Timing: About 90.53% done; ETC: 06:47 (0:01:47 remaining)
Interesting ports on xxx.xxxx.xx (Server_IP_Address):

Not shown: 65480 filtered ports, 41 closed ports
PORT STATE SERVICE VERSION
53/tcp open domain
110/tcp open pop3 Dovecot pop3d
143/tcp open imap Dovecot imapd
993/tcp open ssl/imap Dovecot imapd
995/tcp open ssl/pop3 Dovecot pop3d
2077/tcp open unknown
2078/tcp open ssl/unknown
2082/tcp open unknown
2083/tcp open ssl/unknown
2086/tcp open unknown
2087/tcp open ssl/unknown
2095/tcp open unknown
2096/tcp open ssl/unknown
8080/tcp open http Apache Tomcat/Coyote JSP engine 1.1
8 services unrecognized despite returning data.
======


2 comments:

Anonymous said...

instead of nmap use command

netstat -pant | grep :80*

This shows the status of the port

Hemanth said...

Yes, you can use "netstat". However, netstat has to be used to find individual port.

eg:-
netstat -plan |grep :80 - For apache
netstat -plan |grep :25 - SMTP

This will show you the individual port access enabled and listening to a particular process.


Its better to use, nmap to see the whole list of ports and the current status.