Operating System - HP-UX
1833275 Members
2937 Online
110051 Solutions
New Discussion

Re: Match IP with process

 
SOLVED
Go to solution

Match IP with process

I have a process which listens to a port and spawn processes whenever someone connects on that port. e.g.
ps -ef | grep user
user 1234 1 master
user 2345 1234 child_1
user 3456 1234 child_2

I use
netstat -an | grep $PORT
to see which IP is connected to $PORT e.g.
IP_1 port
IP_2 port


I'd like to link the two, match an IP to a process, how could this be done?
If it ain't rough it ain't me
3 REPLIES 3

Re: Match IP with process

P.S. Unfortunately, I'll browse for answers in 24hrs from now.
If it ain't rough it ain't me
Jordan Bean
Honored Contributor
Solution

Re: Match IP with process

And everyone says: "Use lsof."

Get it here:
http://hpux.cs.utah.edu/hppd/hpux/Sysadmin/lsof-4.61/

With it you can find everything in use by a process or port.

$ lsof -np
$ lsof -ni [proto][@host|addr][:port_list]

For example, let's see all the processes on port 23:

# lsof -ni tcp:23

sven verhaegen
Respected Contributor

Re: Match IP with process

I agree , LSOF is the tool to use , it tells you the info you need to know follow the previous advise
...knowing one ignores a greath many things is the first step to wisdom...