Is it possible to list all processes which connected to particular ip and port?
I want to list the processes which connected to Particular IP and port. Is there any command to achieve this?
Take a look at
ss which is a replacement for the old
As root, will list all current TCP connections on the server with processes names and PIDs.
man ss for more options.
lsof -nPi @192.168.1.123:443
-t if your only want the process ids).
That lists sockets bound to that address as well.
iproute2 on Linux):
ss state established dst 192.168.1.123 'dport = :443'
fuser -n tcp ,192.168.1.123,443 fuser -n udp ,192.168.1.123,443
However note that it (at least version 22.21 here) won’t report the IPv6-mapped IPv4 addresses, you’d need separate queries for those:
fuser -n tcp ,::FFFF:C0A8:017B,443
::FFFF:C0A8:017B being the IPv6-mapped version of 192.168.1.123).
The format is:
lsof -i [tcp|udp][@hostaddr][:[service name|port]]
lsof -i TCP@188.8.131.52:443