SUMMARY: Is it possible to find out who is using a TCP port?

From: Mauricio Fernandez (mauricio@dcfcen.uba.ar)
Date: Fri Feb 17 1995 - 18:00:43 CST


Original posting:
> Hello, I am wondering whether is it possible to find out which
> process is using -accept(ing), connect(ing) or whatever- a TCP port.
> I mean, one can know which ports are in use by means of netstat.
> But what happens if I want to know who's that guy listening at
> port n?
>

Most of the people answered that 'lsof' (list of open files) is the solution.
You have to run it with the -n option in order to list only network
connections.

It is available via FTP in:

ftp.arnes.si:/security/cert/tools/lsof
coast.cs.purdue.edu:/pub/tools/unix/

Thanks to:
Benjamin.Zwittnig@arnes.si
jonathan <jon@eandm.com>
Jon Howell jonh@hitl.washington.edu
Jean-Christophe Touvet <touvet@champagne.inria.fr>
James M. Thompson masato@digex.com
Chris Phillips (chris@cs.yorku.ca)
Michael Sullivan <mike@trdlnk.com>
Matthew Keenan matt@uts.edu.au
Kevin Sheehan <kevin@uniq.com.au>

I also received the following contribution due to Hal Stern
<stern@sunrise.East.Sun.COM>:
>
> from marcus ranum, a long time ago:
>
> You do a netstat -A to get the address of the socket PCB, then
> Use ofiles to map it back. IE:
>
> nsl 7 #netstat -A
> Active Internet connections
> PCB Proto Recv-Q Send-Q Local Address Foreign Address (state)
> c5984400 tcp 0 0 nsl.smtp inet-gw-1.3414 ESTABLISHED
> c5967c00 tcp 0 187 nsl.login hussar.dco.d.1021 ESTABLISHED
> c586a700 tcp 0 0 nsl.3609 gatekeeper.d.6000 ESTABLISHED
>
> nsl 10 #ofiles -n c586a700
> file 8030c320 of socket c597de00 of INPCB c5979a00 of PCB c586a700
> USER PID TYPE FD CMD
> ed 24559 sock 3 xbiff
>
>
>

-- 
+---------------------------------------------------------+
|                          RIU                            |
|              Red de Interconexion Universitaria         |
|_________________________________________________________|
|    Mauricio Fernandez       |e-mail: mauricio@ccc.uba.ar| 
| Universidad de Buenos Aires |                           | 
| Intendente Guiraldes s/n    |   Tel: (541) 787-2674     | 
| C.P 1428, Buenos Aires ARG  |   Fax  (541) 787-2670     |
+---------------------------------------------------------+



This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:10:16 CDT