Subject: Re: Identifying Process/Command For Listening Socket
To: Julian Coleman <jdc@coris.demon.co.uk>
From: Andrew Brown <atatat@atatdot.net>
List: netbsd-help
Date: 12/23/2002 13:03:40
>> The "netstat -an" command shows me UDP port 65506 is open for listening:
>
>> How can I identify the PID or Command for a listening UDP port on NetBSD 1.5.2?
>
>Use fstat?  For example (port 993) :
>
>  $ netstat -an
>  	...
>  tcp        0      0  *.993                  *.*                    LISTEN
>  	...
>  $ fstat | grep 993
>  root     inetd        265   23* internet stream tcp f083b6f8 *:993

actually...i'd suggest doing it with the pcb address.  it gives less
false positives (as, for example, 993 may be part of a pcb address).

    % netstat -Aan
    ...
    f0a1ff00 udp        0      0  *.4785             *.*
    ...
    % fstat | grep f0a1ff00
    root     named      10287    8* internet dgram udp f0a1ff00

or lsof, since that allows you to find out in a more direct manner.

    % netstat -an
    ...
    udp        0      0  *.4785                 *.*
    ...
    % lsof -iUDP:4785
    COMMAND   PID USER   FD   TYPE     DEVICE SIZE/OFF NODE NAME
    named   10287 root    8u  inet 0xf0a1ff00      0t0  UDP *:4785

-- 
|-----< "CODE WARRIOR" >-----|
codewarrior@daemon.org             * "ah!  i see you have the internet
twofsonet@graffiti.com (Andrew Brown)                that goes *ping*!"
werdna@squooshy.com       * "information is power -- share the wealth."