Monday, May 10, 2010

CentOS: find out what network ports are in use

To get a quick idea of what ports you have open on your local box, you can use nmap.

[root@api1dev /usr/local/bin]nmap localhost
Starting Nmap 5.00 ( http://nmap.org ) at 2010-05-10 03:02 EDT
Interesting ports on vmlinux-testing1 (127.0.0.1):
Not shown: 991 closed ports
PORT     STATE SERVICE
21/tcp   open  ftp
22/tcp   open  ssh
80/tcp   open  http
111/tcp  open  rpcbind
389/tcp  open  ldap
631/tcp  open  ipp
726/tcp  open  unknown
8009/tcp open  ajp13
8080/tcp open  http-proxy


For more detailed information, try netstat:

netstat -an

You’ll get a breakdown of every socket open on your machine – useful for figuring out who’s connected and from where.