Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 10 Nov 1998 21:51:48 -0600
From:      Jahanur R Subedar <jahanur@jjsoft.com>
To:        Greg Lehey <grog@lemis.com>
Cc:        Joe Gleason <clash@tasam.com>, freebsd-questions@FreeBSD.ORG
Subject:   Re: Finding the pid of a tcp connection
Message-ID:  <364909D4.1203EA83@jjsoft.com>
References:  <00aa01be0d1c$3d9d0aa0$fe90e8c6@bug.tasam.com> <19981111135424.E20374@freebie.lemis.com>

next in thread | previous in thread | raw e-mail | index | archive | help
I am just curious.
1) Is this known as list server?
2) Is port collection lsof same as the Purdue Version.  and can Purdue version be trusted
to install.

Thanks.
Jahanur


Greg Lehey wrote:

> On Tuesday, 10 November 1998 at 21:37:31 -0500, Joe Gleason wrote:
> > How do I find the process that is doing a connection that is
> > listed in netstat?
> > Idealy, I would like to write a little shell script that will
> > give me the pid if I give it the local port.
>
> No need.  Use lsof (in the ports collection).  Here are some examples
> my current netstat:
>
> Active Internet connections
> Proto Recv-Q Send-Q  Local Address          Foreign Address        (state)
> tcp        0      0  freebie.http           port7-22.gettysb.1084  FIN_WAIT_2
> tcp        0      0  freebie.http           port7-22.gettysb.1083  FIN_WAIT_2
> tcp        0      0  freebie.http           port7-22.gettysb.1082  FIN_WAIT_2
> tcp        0      0  freebie.945            h24-64-143-236.m.22    ESTABLISHED
> tcp        0      0  freebie.946            h24-64-143-218.m.22    ESTABLISHED
> tcp        0      0  freebie.6000           allegro.2596           ESTABLISHED
> tcp        0      0  freebie.3027           websitegarage.co.http  CLOSE_WAIT
> tcp        0      0  freebie.2082           ctp.netradio.net.http  CLOSE_WAIT
> tcp        0      0  freebie.2052           205.166.76.101.http    CLOSE_WAIT
> tcp        0      0  freebie.6000           razzia.1024            ESTABLISHED
> tcp        0      0  freebie.1016           razzia.1021            ESTABLISHED
> tcp        0      0  freebie.1017           razzia.cmd             FIN_WAIT_2
> tcp        0      0  freebie.1047           yana.6000              ESTABLISHED
> tcp        0      0  freebie.1018           yana.1020              ESTABLISHED
> tcp        0      0  freebie.cmd            yana.1021              CLOSE_WAIT
> tcp        0      0  freebie.6000           allegro.1141           ESTABLISHED
> tcp        0      0  freebie.1019           allegro.1021           ESTABLISHED
> tcp        0      0  freebie.1020           allegro.cmd            FIN_WAIT_2
> tcp        0      0  freebie.1021           freefall.FreeBSD.22    ESTABLISHED
> tcp        0      0  localhost.10000        localhost.1027         ESTABLISHED
> tcp        0      0  localhost.1027         localhost.10000        ESTABLISHED
> tcp        0      0  freebie.domain         *.*                    LISTEN
> tcp        0      0  localhost.domain       *.*                    LISTEN
> tcp        0      0  freebie.domain         *.*                    LISTEN
> udp        0      0  freebie.domain         *.*
> udp        0      0  localhost.ntp          *.*
> udp        0      0  freebie.ntp            *.*
> udp        0      0  localhost.domain       *.*
> udp        0      0  freebie.domain         *.*
>
> # lsof -i tcp:http
> COMMAND    PID   USER   FD   TYPE     DEVICE SIZE/OFF NODE NAME
> httpd      266   root   15u  inet 0xf8a54180      0t0  TCP *:http (LISTEN)
> netscape   717   yana   28u  inet 0xf8a59f00      0t0  TCP freebie.lemis.com:2052->205.166.76.101:http (CLOSE_WAIT)
> netscape   717   yana   30u  inet 0xf8a58ba0      0t0  TCP freebie.lemis.com:3027->websitegarage.com:http (CLOSE_WAIT)
> netscape   717   yana   33u  inet 0xf8a593c0      0t0  TCP freebie.lemis.com:2082->ctp.netradio.net:http (CLOSE_WAIT)
> httpd    17003 nobody   15u  inet 0xf8a54180      0t0  TCP *:http (LISTEN)
> httpd    17694 nobody   15u  inet 0xf8a54180      0t0  TCP *:http (LISTEN)
> httpd    20193 nobody   15u  inet 0xf8a54180      0t0  TCP *:http (LISTEN)
> httpd    20195 nobody   15u  inet 0xf8a54180      0t0  TCP *:http (LISTEN)
> httpd    20196 nobody   15u  inet 0xf8a54180      0t0  TCP *:http (LISTEN)
> httpd    20197 nobody   15u  inet 0xf8a54180      0t0  TCP *:http (LISTEN)
> httpd    20198 nobody   15u  inet 0xf8a54180      0t0  TCP *:http (LISTEN)
> httpd    20203 nobody   15u  inet 0xf8a54180      0t0  TCP *:http (LISTEN)
> httpd    20204 nobody   15u  inet 0xf8a54180      0t0  TCP *:http (LISTEN)
> httpd    20398 nobody   15u  inet 0xf8a54180      0t0  TCP *:http (LISTEN)
> You have new mail in /var/mail/grog
> # lsof -i udp:domain
> COMMAND PID USER   FD   TYPE     DEVICE SIZE/OFF NODE NAME
> named   125 root   20u  inet 0xf89bcea0      0t0  UDP freebie.lemis.com:domain
> named   125 root   22u  inet 0xf89bce40      0t0  UDP localhost.lemis.com:domain
> named   125 root   24u  inet 0xf89bc960      0t0  UDP freebie.lemis.com:domain
>
> Greg
> --
> See complete headers for address, home page and phone numbers
> finger grog@lemis.com for PGP public key
>
> To Unsubscribe: send mail to majordomo@FreeBSD.org
> with "unsubscribe freebsd-questions" in the body of the message


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?364909D4.1203EA83>