LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   list all connections to a specific port (https://www.linuxquestions.org/questions/linux-networking-3/list-all-connections-to-a-specific-port-946389/)

drhart4000 05-22-2012 09:44 PM

list all connections to a specific port
 
is there a command I can use to list all connections made to a specific port such as port 5060? I want to list the clients not the services binded to the port, can netstat do this?


Thanks,

Wayne

nikmit 05-23-2012 02:17 AM

cat /proc/net/ip_conntrack | grep sport=123 (or "dport=345") does the job on a debian system.
interesting to know if there is a more sofisticated way :)

lithos 05-23-2012 04:39 AM

Hi,

maybe "lsof" will help you:
Code:

root@~#>lsof -i :80
COMMAND  PID  USER  FD  TYPE DEVICE SIZE NODE NAME
httpd    1931  root    3u  IPv6  3153      TCP *:http (LISTEN)
httpd    9346 httpd    3u  IPv6  3153      TCP *:http (LISTEN)
httpd  14809 httpd    3u  IPv6  3153      TCP *:http (LISTEN)
httpd  16423 httpd    3u  IPv6  3153      TCP *:http (LISTEN)
httpd  20864 httpd    3u  IPv6  3153      TCP *:http (LISTEN)
httpd  25164 httpd    3u  IPv6  3153      TCP *:http (LISTEN)
httpd  25581 httpd    3u  IPv6  3153      TCP *:http (LISTEN)
httpd  26118 httpd    3u  IPv6  3153      TCP *:http (LISTEN)
httpd  26251 httpd    3u  IPv6  3153      TCP *:http (LISTEN)
httpd  26252 httpd    3u  IPv6  3153      TCP *:http (LISTEN)
httpd  26253 httpd    3u  IPv6  3153      TCP *:http (LISTEN)
httpd  26251 httpd  19u  IPv6 983561      TCP 192.168.0.10:http->1.2.3.4.dynamic.net:50453 (ESTABLISHED)
httpd  26252 httpd    3u  IPv6  3153      TCP *:http (LISTEN)
httpd  26252 httpd  19u  IPv6 983623      TCP 192.168.0.10:http->1.2.3.4.dynamic.net:50456 (ESTABLISHED)
httpd  26253 httpd    3u  IPv6  3153      TCP *:http (LISTEN)
httpd  26253 httpd  19u  IPv6 983619      TCP 192.168.0.10:http->1.2.3.4.dynamic.net:50455 (ESTABLISHED)

see the outlined lines show connections to HTTP


All times are GMT -5. The time now is 03:41 PM.