{"id":124,"date":"2008-04-04T10:42:51","date_gmt":"2008-04-04T18:42:51","guid":{"rendered":"http:\/\/jaredrobinson.com\/blog\/?p=124"},"modified":"2009-07-11T04:15:24","modified_gmt":"2009-07-11T04:15:24","slug":"what-programs-are-listening-to-the-network","status":"publish","type":"post","link":"https:\/\/jaredrobinson.com\/blog\/what-programs-are-listening-to-the-network\/","title":{"rendered":"What programs are listening to the network?"},"content":{"rendered":"<p>Sometimes, I&#8217;d like to know what programs on my system are listening to the network, and to quote the Perl motto, &#8220;there&#8217;s more than one way to do it&#8221;. On Linux, there&#8217;s `lsof -Pi` and `netstat -p`. On Windows XP and Vista, there&#8217;s the built-in `netstat -b[v] -a` and a separate utility called [tcpview](http:\/\/technet.microsoft.com\/en-us\/sysinternals\/bb897437.aspx). I&#8217;ve included example usages and outputs.<\/p>\n<p>__lsof__ (Linux)<\/p>\n<p>    sudo lsof -Pni<\/p>\n<p>    COMMAND     PID    USER   FD   TYPE DEVICE SIZE NODE NAME<br \/>\n    python     1886    root    4u  IPv4   6621       TCP 127.0.0.1:2207 (LISTEN)<br \/>\n    cupsd      1898    root    3u  IPv4   6663       TCP 127.0.0.1:631 (LISTEN)<br \/>\n    cupsd      1898    root    4u  IPv6   6664       TCP [::1]:631 (LISTEN)<br \/>\n    cupsd      1898    root    6u  IPv4   6667       UDP *:631<br \/>\n    sshd       1912    root    3u  IPv4   6711       TCP *:22 (LISTEN)<br \/>\n    httpd     20084  apache    4u  IPv6   7293       TCP *:80 (LISTEN)<br \/>\n    httpd     20085  apache    4u  IPv6   7293       TCP *:80 (LISTEN)<br \/>\n    httpd     20086  apache    4u  IPv6   7293       TCP *:80 (LISTEN)<br \/>\n    httpd     20087  apache    4u  IPv6   7293       TCP *:80 (LISTEN)<br \/>\n    httpd     20088  apache    4u  IPv6   7293       TCP *:80 (LISTEN)<br \/>\n    httpd     20089  apache    4u  IPv6   7293       TCP *:80 (LISTEN)<br \/>\n    httpd     20090  apache    4u  IPv6   7293       TCP *:80 (LISTEN)<br \/>\n    httpd     20091  apache    4u  IPv6   7293       TCP *:80 (LISTEN)<\/p>\n<p>__netstat__ (Linux)<\/p>\n<p>    sudo netstat -lp &#8211;inet &#8211;numeric-hosts<\/p>\n<p>    Active Internet connections (only servers)<br \/>\n    Proto Recv-Q Send-Q Local Address    Foreign Address  State   PID\/Program name<br \/>\n    tcp        0      0 0.0.0.0:ssh      0.0.0.0:*        LISTEN  1912\/sshd<br \/>\n    tcp        0      0 127.0.0.1:ipp    0.0.0.0:*        LISTEN  1898\/cupsd<br \/>\n    tcp        0      0 127.0.0.1:2207   0.0.0.0:*        LISTEN  1886\/python<br \/>\n    udp        0      0 0.0.0.0:ipp      0.0.0.0:*                1898\/cupsd<\/p>\n<p>Where&#8217;s `httpd`? It should be there, and it is, when I exclude the `&#8211;inet` option:<\/p>\n<p>    Proto Recv-Q Send-Q Local Address    Foreign Address  State   PID\/Program name<br \/>\n    tcp        0      0 :::http          :::*             LISTEN  2038\/httpd<br \/>\n    tcp        0      0 ::1:ipp          :::*             LISTEN  1898\/cupsd<\/p>\n<p>__TcpView__ (Windows)<\/p>\n<p>[Download](http:\/\/technet.microsoft.com\/en-us\/sysinternals\/bb897437.aspx) and start TcpView. From the menu, choose File > Save. Here&#8217;s the output from the file.<\/p>\n<p>    Process           Protocol Local Address            Remote Address   State<br \/>\n    svchost.exe:1064  TCP      jareds-xp:epmapi         jareds-xp:0      LISTENING<br \/>\n    System:4          TCP      jareds-xp:microsoft-ds   jareds-xp:0      LISTENING<br \/>\n    svchost.exe:976   TCP      jareds-xp:3389i          jareds-xp:0      LISTENING<br \/>\n    nxssh.exe:2032    TCP      jareds-xp:11000          jareds-xp:0      LISTENING<\/p>\n<p>__netstat__ (Windows)<\/p>\n<p>Note that this runs quite slowly on Windows.<\/p>\n<p>   netstat -bva<\/p>\n<p>    Active Connections<\/p>\n<p>    Proto  Local Address          Foreign Address        State           PID<br \/>\n    TCP    jareds-xp:epmap  jareds-xp.mydomain.com:0  LISTENING       1064<br \/>\n    c:\\windows\\system32\\WS2_32.dll<br \/>\n    C:\\WINDOWS\\system32\\RPCRT4.dll<br \/>\n    c:\\windows\\system32\\rpcss.dll<br \/>\n    C:\\WINDOWS\\system32\\svchost.exe<br \/>\n    C:\\WINDOWS\\system32\\ADVAPI32.dll<br \/>\n    [svchost.exe]<\/p>\n<p>    TCP    jareds-xp:microsoft-ds  jareds-xp.mydomain.com:0  LISTENING       4<br \/>\n    &#8212; unknown component(s) &#8212;<br \/>\n    [System]<\/p>\n<p>    TCP    jareds-xp:3389  jareds-xp.mydomain.com:0  LISTENING 976<br \/>\n    &#8212; unknown component(s) &#8212;<br \/>\n    c:\\windows\\system32\\rpcss.dll<br \/>\n    C:\\WINDOWS\\system32\\svchost.exe<br \/>\n    C:\\WINDOWS\\system32\\ADVAPI32.dll<br \/>\n    [svchost.exe]<\/p>\n<p>    TCP    jareds-xp:11000  jareds-xp.mydomain.com:0  LISTENING       2032<br \/>\n    [nxssh.exe]<\/p>\n<p>    TCP    jareds-xp:3389  jareds-xp.mydomain.com:0  LISTENING 976<br \/>\n    &#8212; unknown component(s) &#8212;<br \/>\n    c:\\windows\\system32\\rpcss.dll<br \/>\n    C:\\WINDOWS\\system32\\svchost.exe<br \/>\n    C:\\WINDOWS\\system32\\ADVAPI32.dll<br \/>\n    [svchost.exe]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Sometimes, I&#8217;d like to know what programs on my system are listening to the network, and to quote the Perl motto, &#8220;there&#8217;s more than one way to do it&#8221;. On Linux, there&#8217;s `lsof -Pi` and `netstat -p`. On Windows XP and Vista, there&#8217;s the built-in `netstat -b[v] -a` and a separate utility called [tcpview](http:\/\/technet.microsoft.com\/en-us\/sysinternals\/bb897437.aspx). I&#8217;ve &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/jaredrobinson.com\/blog\/what-programs-are-listening-to-the-network\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;What programs are listening to the network?&#8221;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6,9,17,18],"tags":[],"class_list":["post-124","post","type-post","status-publish","format-standard","hentry","category-fedora","category-linux","category-tech","category-windows"],"_links":{"self":[{"href":"https:\/\/jaredrobinson.com\/blog\/wp-json\/wp\/v2\/posts\/124","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jaredrobinson.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jaredrobinson.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jaredrobinson.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/jaredrobinson.com\/blog\/wp-json\/wp\/v2\/comments?post=124"}],"version-history":[{"count":1,"href":"https:\/\/jaredrobinson.com\/blog\/wp-json\/wp\/v2\/posts\/124\/revisions"}],"predecessor-version":[{"id":392,"href":"https:\/\/jaredrobinson.com\/blog\/wp-json\/wp\/v2\/posts\/124\/revisions\/392"}],"wp:attachment":[{"href":"https:\/\/jaredrobinson.com\/blog\/wp-json\/wp\/v2\/media?parent=124"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jaredrobinson.com\/blog\/wp-json\/wp\/v2\/categories?post=124"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jaredrobinson.com\/blog\/wp-json\/wp\/v2\/tags?post=124"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}