如何获取连接外部ip的pid号?

如何获取连接外部ip的pid号?

某个程序从我的本地ip 111.111.111.111与130.239.18.176:80连接,如何获取pid号?

 netstat  -np
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 111.111.111.111:46243    52.89.80.240:443        TIME_WAIT   -               
tcp        0      1 111.111.111.111:36553    173.239.79.210:443      SYN_SENT    2630/firefox-esr
tcp        0      0 111.111.111.111:48470    130.239.18.176:80       ESTABLISHED -               
tcp        0      1 111.111.111.111:36552    173.239.79.210:443      SYN_SENT    2630/firefox-esr
tcp        0      1 111.111.111.111:34202    74.125.204.101:80       SYN_SENT    2630/firefox-esr
tcp        0      0 111.111.111.111:52243    203.208.48.79:443       ESTABLISHED 2630/firefox-esr
tcp        0      1 111.111.111.111:46521    74.125.203.93:443       SYN_SENT    2630/firefox-esr
tcp        0      1 111.111.111.111:34200    74.125.204.101:80       SYN_SENT    2630/firefox-esr
tcp        0      0 111.111.111.111:48424    130.239.18.176:80       ESTABLISHED -               
tcp        0      0 111.111.111.111:46238    52.89.80.240:443        TIME_WAIT   -               
tcp        0      1 111.111.111.111:46523    74.125.203.93:443       SYN_SENT    2630/firefox-esr
tcp        0      0 111.111.111.111:34204    74.125.204.101:80       TIME_WAIT   -               
tcp        0      0 111.111.111.111:33700    104.24.98.177:443       ESTABLISHED 2630/firefox-esr
tcp        0      1 111.111.111.111:34206    74.125.204.101:80       SYN_SENT    2630/firefox-esr
tcp        0      0 127.0.0.1:49941         127.0.0.1:80            ESTABLISHED 2630/firefox-esr

答案1

输出netstat很好地解释了这一点:

(并非所有进程都能被识别,非拥有的进程信息将不会显示,您必须是 root 才能看到全部。)

只需以 root 身份运行(例如sudo netstat -np

相关内容