*BSD News Article 75028


Return to BSD News archive

Path: euryale.cc.adfa.oz.au!newshost.anu.edu.au!harbinger.cc.monash.edu.au!munnari.OZ.AU!spool.mu.edu!howland.reston.ans.net!EU.net!sun4nl!surfnet.nl!tuegate.tue.nl!news.win.tue.nl!il.ft.hse.nl!not-for-mail
From: robert@il.ft.hse.nl (robert)
Newsgroups: comp.security.unix,comp.unix.admin,comp.unix.bsd.freebsd.misc
Subject: Re: How to associate a socket w/ PID? (BSD solution)
Date: 30 Jul 1996 11:09:26 +0200
Organization: LSD...melts in your mind, not in your hand
Lines: 20
Message-ID: <4tkjg6$st@charm.il.ft.hse.nl>
References: <4tk4mh$qpl@hermes.jersey.net>
NNTP-Posting-Host: charm.il.ft.hse.nl
Xref: euryale.cc.adfa.oz.au comp.security.unix:26615 comp.unix.admin:45476 comp.unix.bsd.freebsd.misc:24656

bherd@zeus.jersey.net (Bil Herd):
 >How do you find out which process is associated with a network 
 >connection other than recognizing the port?  

charm.il.ft.hse.nl:/pub/perl/nstat.pl
It's a perl-program I wrote a while back for my FreeBSD machine, but I
just checked and it also seems to work on BSDI.

It combines the outputs of fstat(8) and netstat(8), and produces something
like this:
--
PID   User     Command    Pro Local Address      Foreign Address    State
29545 nobody   httpd      tcp 145.85.127.2.80    194.90.103.192.144 ESTABLISHED 
...
--

It has some commandline-options which are useful, 'nstat.pl -?' shows
them.

                                                                robert