2011-04-15

FreeBSD - How to check what services or port opening in tcp/udp

Platform :
FreeBSD

How to :
List/show what services or port is listening/opening.

Installation :
The command comes with base system.


Command :
sockstat



Example :
To show listening/opening TCP port :
# sockstat -Ptcp
USER     COMMAND    PID   FD PROTO  LOCAL ADDRESS         FOREIGN ADDRESS      
hulahula sshd       54573 3  tcp4   192.168.8.8:22         192.168.8.192:55356
root     sshd       54571 3  tcp4   192.168.8.8:22         192.168.8.192:55356
root     sshd       2943  3  tcp4   192.168.8.8:22         *:*
root     sendmail   2329  3  tcp4   192.168.8.8:25         *:*

Similarly, with UDP port :
# sockstat -Pudp
USER     COMMAND    PID   FD PROTO  LOCAL ADDRESS         FOREIGN ADDRESS      
root     syslogd    697   6  udp6   *:514                 *:*
root     syslogd    697   7  udp4   *:514                 *:*



More precise usage of sockstat, check out :
man sockstat

Nemaste !!!

No comments: