Check what ports are open

To see what ports are open in your Linux box, you can use nmap port scanner or you can use netstat.

nmap can be used with following command:

# nmap -sS -O 127.0.0.1

The answer will be something like:

Starting Nmap 4.11 ( http://www.insecure.org/nmap/ ) at 2010-07-08 11:31 CEST
Interesting ports on localhost.localdomain (127.0.0.1):
Not shown: 1663 closed ports
PORT     STATE SERVICE
22/tcp   open  ssh
25/tcp   open  smtp
80/tcp   open  http
110/tcp  open  pop3
111/tcp  open  rpcbind
143/tcp  open  imap
993/tcp  open  imaps
995/tcp  open  pop3s
3306/tcp open  mysql
8009/tcp open  ajp13
8080/tcp open  http-proxy
8443/tcp open  https-alt
No exact OS matches for host (If you know what OS is running on it, see http://www.insecure.org/cgi-bin/nmap-submit.cgi).
......
 
Uptime 15.472 days (since Wed Jun 23 00:12:46 2010)
 
Nmap finished: 1 IP address (1 host up) scanned in 9.558 seconds

and nmap can be used to scan remote hosts (keep in mind that many admins will notice this as hack attempt). Simple replace 127.0.0.1 with host IP address.

Another way to check open ports is via netstat. Netstat can show hidden ports and programs associated with ports. Simple execute next command as root:

# netstat -nap

The output list can be very long (depending from your network activity).

Note: Use this tips carefully. I’m not responsible for any potential damage…

Leave a Reply

Your email address will not be published. Required fields are marked *