{"id":113,"date":"2010-09-08T10:32:55","date_gmt":"2010-09-08T10:32:55","guid":{"rendered":"http:\/\/www.huzs.top\/?p=113"},"modified":"2012-10-12T12:00:20","modified_gmt":"2012-10-12T04:00:20","slug":"113","status":"publish","type":"post","link":"https:\/\/www.huzs.top\/?p=113","title":{"rendered":"Linux netstat\u547d\u4ee4\u8be6\u89e3"},"content":{"rendered":"<h1><strong>\u7b80\u4ecb<\/strong><\/h1>\n<p>Netstat \u547d\u4ee4\u7528\u4e8e\u663e\u793a\u5404\u79cd\u7f51\u7edc\u76f8\u5173\u4fe1\u606f\uff0c\u5982\u7f51\u7edc\u8fde\u63a5\uff0c\u8def\u7531\u8868\uff0c\u63a5\u53e3\u72b6\u6001 (Interface Statistics)\uff0cmasquerade \u8fde\u63a5\uff0c\u591a\u64ad\u6210\u5458 (Multicast Memberships) \u7b49\u7b49\u3002<\/p>\n<h1><strong>\u8f93\u51fa\u4fe1\u606f\u542b\u4e49<\/strong><\/h1>\n<p>\u6267\u884cnetstat\u540e\uff0c\u5176\u8f93\u51fa\u7ed3\u679c\u4e3a<\/p>\n<div><\/p>\n<div><a title=\"\u590d\u5236\u4ee3\u7801\"><img decoding=\"async\" src=\"http:\/\/common.cnblogs.com\/images\/copycode.gif\" alt=\"\u590d\u5236\u4ee3\u7801\" \/><\/a><\/div>\n<p><\/p>\n<pre>Active Internet connections (w\/o servers)<br>Proto Recv-Q Send-Q Local Address Foreign Address State<br>tcp 0 2 210.34.6.89:telnet 210.34.6.96:2873 ESTABLISHED<br>tcp 296 0 210.34.6.89:1165 210.34.6.84:netbios-ssn ESTABLISHED<br>tcp 0 0 localhost.localdom:9001 localhost.localdom:1162 ESTABLISHED<br>tcp 0 0 localhost.localdom:1162 localhost.localdom:9001 ESTABLISHED<br>tcp 0 80 210.34.6.89:1161 210.34.6.10:netbios-ssn CLOSE<br><br>Active UNIX domain sockets (w\/o servers)<br>Proto RefCnt Flags Type State I-Node Path<br>unix 1 [ ] STREAM CONNECTED 16178 @000000dd<br>unix 1 [ ] STREAM CONNECTED 16176 @000000dc<br>unix 9 [ ] DGRAM 5292 \/dev\/log<br>unix 1 [ ] STREAM CONNECTED 16182 @000000df<\/pre>\n<p><\/p>\n<div><a title=\"\u590d\u5236\u4ee3\u7801\"><img decoding=\"async\" src=\"http:\/\/common.cnblogs.com\/images\/copycode.gif\" alt=\"\u590d\u5236\u4ee3\u7801\" \/><\/a><\/div>\n<p><\/div>\n<p>\u4ece\u6574\u4f53\u4e0a\u770b\uff0cnetstat\u7684\u8f93\u51fa\u7ed3\u679c\u53ef\u4ee5\u5206\u4e3a\u4e24\u4e2a\u90e8\u5206\uff1a<\/p>\n<p>\u4e00\u4e2a\u662fActive Internet connections\uff0c\u79f0\u4e3a\u6709\u6e90TCP\u8fde\u63a5\uff0c\u5176\u4e2d&#8221;Recv-Q&#8221;\u548c&#8221;Send-Q&#8221;\u6307%0A\u7684\u662f\u63a5\u6536\u961f\u5217\u548c\u53d1\u9001\u961f\u5217\u3002\u8fd9\u4e9b\u6570\u5b57\u4e00\u822c\u90fd\u5e94\u8be5\u662f0\u3002\u5982\u679c\u4e0d\u662f\u5219\u8868\u793a\u8f6f\u4ef6\u5305\u6b63\u5728\u961f\u5217\u4e2d\u5806\u79ef\u3002\u8fd9\u79cd\u60c5\u51b5\u53ea\u80fd\u5728\u975e\u5e38\u5c11\u7684\u60c5\u51b5\u89c1\u5230\u3002<\/p>\n<p>\u53e6\u4e00\u4e2a\u662fActive UNIX domain sockets\uff0c\u79f0\u4e3a\u6709\u6e90Unix\u57df\u5957\u63a5\u53e3(\u548c\u7f51\u7edc\u5957\u63a5\u5b57\u4e00\u6837\uff0c\u4f46\u662f\u53ea\u80fd\u7528\u4e8e\u672c\u673a\u901a\u4fe1\uff0c\u6027\u80fd\u53ef\u4ee5\u63d0\u9ad8\u4e00\u500d)\u3002<br \/>Proto\u663e\u793a\u8fde\u63a5\u4f7f\u7528\u7684\u534f\u8bae,RefCnt\u8868\u793a\u8fde\u63a5\u5230\u672c\u5957\u63a5\u53e3\u4e0a\u7684\u8fdb\u7a0b\u53f7,Types\u663e\u793a\u5957\u63a5\u53e3\u7684\u7c7b\u578b,State\u663e\u793a\u5957\u63a5\u53e3\u5f53\u524d\u7684\u72b6\u6001,Path\u8868\u793a\u8fde\u63a5\u5230\u5957\u63a5\u53e3\u7684\u5176\u5b83\u8fdb\u7a0b\u4f7f\u7528\u7684\u8def\u5f84\u540d\u3002<\/p>\n<h1><strong>\u5e38\u89c1\u53c2\u6570<\/strong><\/h1>\n<p>-a (all)\u663e\u793a\u6240\u6709\u9009\u9879\uff0c\u9ed8\u8ba4\u4e0d\u663e\u793aLISTEN\u76f8\u5173<br \/>-t (tcp)\u4ec5\u663e\u793atcp\u76f8\u5173\u9009\u9879<br \/>-u (udp)\u4ec5\u663e\u793audp\u76f8\u5173\u9009\u9879<br \/>-n \u62d2\u7edd\u663e\u793a\u522b\u540d\uff0c\u80fd\u663e\u793a\u6570\u5b57\u7684\u5168\u90e8\u8f6c\u5316\u6210\u6570\u5b57\u3002<br \/>-l \u4ec5\u5217\u51fa\u6709\u5728 Listen (\u76d1\u542c) \u7684\u670d\u52d9\u72b6\u6001<\/p>\n<p>-p \u663e\u793a\u5efa\u7acb\u76f8\u5173\u94fe\u63a5\u7684\u7a0b\u5e8f\u540d<br \/>-r \u663e\u793a\u8def\u7531\u4fe1\u606f\uff0c\u8def\u7531\u8868<br \/>-e \u663e\u793a\u6269\u5c55\u4fe1\u606f\uff0c\u4f8b\u5982uid\u7b49<br \/>-s \u6309\u5404\u4e2a\u534f\u8bae\u8fdb\u884c\u7edf\u8ba1<br \/>-c \u6bcf\u9694\u4e00\u4e2a\u56fa\u5b9a\u65f6\u95f4\uff0c\u6267\u884c\u8be5netstat\u547d\u4ee4\u3002<\/p>\n<p>\u63d0\u793a\uff1aLISTEN\u548cLISTENING\u7684\u72b6\u6001\u53ea\u6709\u7528-a\u6216\u8005-l\u624d\u80fd\u770b\u5230<\/p>\n<p>&nbsp;<\/p>\n<h1><strong>\u5b9e\u7528\u547d\u4ee4\u5b9e\u4f8b<\/strong><\/h1>\n<p><\/p>\n<h2><strong>\u00a0<\/strong><\/h2>\n<p><\/p>\n<h2><strong>1. \u5217\u51fa\u6240\u6709\u7aef\u53e3 (\u5305\u62ec\u76d1\u542c\u548c\u672a\u76d1\u542c\u7684)<\/strong><\/h2>\n<p><strong>\u00a0 \u5217\u51fa\u6240\u6709\u7aef\u53e3 netstat -a<\/strong><\/p>\n<div><\/p>\n<div><\/p>\n<div><\/p>\n<div><a title=\"\u590d\u5236\u4ee3\u7801\"><img decoding=\"async\" src=\"http:\/\/common.cnblogs.com\/images\/copycode.gif\" alt=\"\u590d\u5236\u4ee3\u7801\" \/><\/a><\/div>\n<p><\/p>\n<pre># netstat -a | more<br> Active Internet connections (servers and established)<br> Proto Recv-Q Send-Q Local Address           Foreign Address         State<br> tcp        0      0 localhost:30037         *:*                     LISTEN<br> udp        0      0 *:bootpc                *:*<br> <br>Active UNIX domain sockets (servers and established)<br> Proto RefCnt Flags       Type       State         I-Node   Path<br> unix  2      [ ACC ]     STREAM     LISTENING     6135     \/tmp\/.X11-unix\/X0<br> unix  2      [ ACC ]     STREAM     LISTENING     5140     \/var\/run\/acpid.socket<\/pre>\n<p><\/p>\n<div><a title=\"\u590d\u5236\u4ee3\u7801\"><img decoding=\"async\" src=\"http:\/\/common.cnblogs.com\/images\/copycode.gif\" alt=\"\u590d\u5236\u4ee3\u7801\" \/><\/a><\/div>\n<p><\/div>\n<p><\/div>\n<p><\/div>\n<p><strong>\u00a0 \u5217\u51fa\u6240\u6709 tcp \u7aef\u53e3 netstat -at<\/strong><\/p>\n<div><\/p>\n<div><\/p>\n<div><\/p>\n<div><a title=\"\u590d\u5236\u4ee3\u7801\"><img decoding=\"async\" src=\"http:\/\/common.cnblogs.com\/images\/copycode.gif\" alt=\"\u590d\u5236\u4ee3\u7801\" \/><\/a><\/div>\n<p><\/p>\n<pre># netstat -at<br> Active Internet connections (servers and established)<br> Proto Recv-Q Send-Q Local Address           Foreign Address         State<br> tcp        0      0 localhost:30037         *:*                     LISTEN<br> tcp        0      0 localhost:ipp           *:*                     LISTEN<br> tcp        0      0 *:smtp                  *:*                     LISTEN<br> tcp6       0      0 localhost:ipp           [::]:*                  LISTEN<\/pre>\n<p><\/p>\n<div><a title=\"\u590d\u5236\u4ee3\u7801\"><img decoding=\"async\" src=\"http:\/\/common.cnblogs.com\/images\/copycode.gif\" alt=\"\u590d\u5236\u4ee3\u7801\" \/><\/a><\/div>\n<p><\/div>\n<p><\/div>\n<p><\/div>\n<p><strong>\u00a0 \u5217\u51fa\u6240\u6709 udp \u7aef\u53e3 netstat -au<\/strong><\/p>\n<div><\/p>\n<div><\/p>\n<div><\/p>\n<pre># netstat -au<br> Active Internet connections (servers and established)<br> Proto Recv-Q Send-Q Local Address           Foreign Address         State<br> udp        0      0 *:bootpc                *:*<br> udp        0      0 *:49119                 *:*<br> udp        0      0 *:mdns                  *:*<\/pre>\n<p><\/div>\n<p><\/div>\n<p><\/div>\n<p><\/p>\n<h2><strong>\u00a0<\/strong><\/h2>\n<p><\/p>\n<h2><strong>2. \u5217\u51fa\u6240\u6709\u5904\u4e8e\u76d1\u542c\u72b6\u6001\u7684 Sockets<\/strong><\/h2>\n<p><strong>\u00a0 \u53ea\u663e\u793a\u76d1\u542c\u7aef\u53e3 netstat -l<\/strong><\/p>\n<div><\/p>\n<div><\/p>\n<div><\/p>\n<pre># netstat -l<br> Active Internet connections (only servers)<br> Proto Recv-Q Send-Q Local Address           Foreign Address         State<br> tcp        0      0 localhost:ipp           *:*                     LISTEN<br> tcp6       0      0 localhost:ipp           [::]:*                  LISTEN<br> udp        0      0 *:49119                 *:*<\/pre>\n<p><\/div>\n<p><\/div>\n<p><\/div>\n<p><strong>\u00a0 \u53ea\u5217\u51fa\u6240\u6709\u76d1\u542c tcp \u7aef\u53e3 netstat -lt<\/strong><\/p>\n<div><\/p>\n<div><\/p>\n<div><\/p>\n<pre># netstat -lt<br> Active Internet connections (only servers)<br> Proto Recv-Q Send-Q Local Address           Foreign Address         State<br> tcp        0      0 localhost:30037         *:*                     LISTEN<br> tcp        0      0 *:smtp                  *:*                     LISTEN<br> tcp6       0      0 localhost:ipp           [::]:*                  LISTEN<\/pre>\n<p><\/div>\n<p><\/div>\n<p><\/div>\n<p><strong>\u00a0 \u53ea\u5217\u51fa\u6240\u6709\u76d1\u542c udp \u7aef\u53e3 netstat -lu<\/strong><\/p>\n<div><\/p>\n<div><\/p>\n<div><\/p>\n<pre># netstat -lu<br> Active Internet connections (only servers)<br> Proto Recv-Q Send-Q Local Address           Foreign Address         State<br> udp        0      0 *:49119                 *:*<br> udp        0      0 *:mdns                  *:*<\/pre>\n<p><\/div>\n<p><\/div>\n<p><\/div>\n<p><strong>\u00a0 \u53ea\u5217\u51fa\u6240\u6709\u76d1\u542c UNIX \u7aef\u53e3 netstat -lx<\/strong><\/p>\n<div><\/p>\n<div><\/p>\n<div><\/p>\n<div><a title=\"\u590d\u5236\u4ee3\u7801\"><img decoding=\"async\" src=\"http:\/\/common.cnblogs.com\/images\/copycode.gif\" alt=\"\u590d\u5236\u4ee3\u7801\" \/><\/a><\/div>\n<p><\/p>\n<pre># netstat -lx<br> Active UNIX domain sockets (only servers)<br> Proto RefCnt Flags       Type       State         I-Node   Path<br> unix  2      [ ACC ]     STREAM     LISTENING     6294     private\/maildrop<br> unix  2      [ ACC ]     STREAM     LISTENING     6203     public\/cleanup<br> unix  2      [ ACC ]     STREAM     LISTENING     6302     private\/ifmail<br> unix  2      [ ACC ]     STREAM     LISTENING     6306     private\/bsmtp<\/pre>\n<p><\/p>\n<div><a title=\"\u590d\u5236\u4ee3\u7801\"><img decoding=\"async\" src=\"http:\/\/common.cnblogs.com\/images\/copycode.gif\" alt=\"\u590d\u5236\u4ee3\u7801\" \/><\/a><\/div>\n<p><\/div>\n<p><\/p>\n<pre><br><br><\/pre>\n<p><\/div>\n<p><\/div>\n<p><\/p>\n<h2><strong>3. \u663e\u793a\u6bcf\u4e2a\u534f\u8bae\u7684\u7edf\u8ba1\u4fe1\u606f<\/strong><\/h2>\n<p><strong>\u00a0 \u663e\u793a\u6240\u6709\u7aef\u53e3\u7684\u7edf\u8ba1\u4fe1\u606f netstat -s<\/strong><\/p>\n<div><\/p>\n<div><\/p>\n<div><\/p>\n<div><a title=\"\u590d\u5236\u4ee3\u7801\"><img decoding=\"async\" src=\"http:\/\/common.cnblogs.com\/images\/copycode.gif\" alt=\"\u590d\u5236\u4ee3\u7801\" \/><\/a><\/div>\n<p><\/p>\n<pre># netstat -s<br> Ip:<br> 11150 total packets received<br> 1 with invalid addresses<br> 0 forwarded<br> 0 incoming packets discarded<br> 11149 incoming packets delivered<br> 11635 requests sent out<br> Icmp:<br> 0 ICMP messages received<br> 0 input ICMP message failed.<br> Tcp:<br> 582 active connections openings<br> 2 failed connection attempts<br> 25 connection resets received<br> Udp:<br> 1183 packets received<br> 4 packets to unknown port received.<br> .....<\/pre>\n<p><\/p>\n<div><a title=\"\u590d\u5236\u4ee3\u7801\"><img decoding=\"async\" src=\"http:\/\/common.cnblogs.com\/images\/copycode.gif\" alt=\"\u590d\u5236\u4ee3\u7801\" \/><\/a><\/div>\n<p><\/div>\n<p><\/div>\n<p><\/div>\n<p><strong>\u00a0 \u663e\u793a TCP \u6216 UDP \u7aef\u53e3\u7684\u7edf\u8ba1\u4fe1\u606f netstat -st \u6216 -su<\/strong><\/p>\n<div><\/p>\n<div><\/p>\n<div><\/p>\n<pre># netstat -st <br># netstat -su<\/pre>\n<p><\/div>\n<p><\/div>\n<p><\/div>\n<p><\/p>\n<h4><\/h4>\n<p><\/p>\n<h2><strong>4. \u5728 netstat \u8f93\u51fa\u4e2d\u663e\u793a PID \u548c\u8fdb\u7a0b\u540d\u79f0 netstat -p<\/strong><\/h2>\n<p>netstat -p \u53ef\u4ee5\u4e0e\u5176\u5b83\u5f00\u5173\u4e00\u8d77\u4f7f\u7528\uff0c\u5c31\u53ef\u4ee5\u6dfb\u52a0 \u201cPID\/\u8fdb\u7a0b\u540d\u79f0\u201d \u5230 netstat \u8f93\u51fa\u4e2d\uff0c\u8fd9\u6837 debugging \u7684\u65f6\u5019\u53ef\u4ee5\u5f88\u65b9\u4fbf\u7684\u53d1\u73b0\u7279\u5b9a\u7aef\u53e3\u8fd0\u884c\u7684\u7a0b\u5e8f\u3002<\/p>\n<div><\/p>\n<div><\/p>\n<div><\/p>\n<pre># netstat -pt<br> Active Internet connections (w\/o servers)<br> Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID\/Program name<br> tcp        1      0 ramesh-laptop.loc:47212 192.168.185.75:www        CLOSE_WAIT  2109\/firefox<br> tcp        0      0 ramesh-laptop.loc:52750 lax:www ESTABLISHED 2109\/firefox<\/pre>\n<p><\/div>\n<p><\/div>\n<p><\/div>\n<p><\/p>\n<h2><strong>5. \u5728 netstat \u8f93\u51fa\u4e2d\u4e0d\u663e\u793a\u4e3b\u673a\uff0c\u7aef\u53e3\u548c\u7528\u6237\u540d (host, port or user)<\/strong><\/h2>\n<p>\u5f53\u4f60\u4e0d\u60f3\u8ba9\u4e3b\u673a\uff0c\u7aef\u53e3\u548c\u7528\u6237\u540d\u663e\u793a\uff0c\u4f7f\u7528 netstat -n\u3002\u5c06\u4f1a\u4f7f\u7528\u6570\u5b57\u4ee3\u66ff\u90a3\u4e9b\u540d\u79f0\u3002<\/p>\n<p>\u540c\u6837\u53ef\u4ee5\u52a0\u901f\u8f93\u51fa\uff0c\u56e0\u4e3a\u4e0d\u7528\u8fdb\u884c\u6bd4\u5bf9\u67e5\u8be2\u3002<\/p>\n<div><\/p>\n<div><\/p>\n<div><\/p>\n<pre># netstat -an<\/pre>\n<p><\/div>\n<p><\/div>\n<p><\/div>\n<p>\u5982\u679c\u53ea\u662f\u4e0d\u60f3\u8ba9\u8fd9\u4e09\u4e2a\u540d\u79f0\u4e2d\u7684\u4e00\u4e2a\u88ab\u663e\u793a\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4<\/p>\n<div><\/p>\n<div><\/p>\n<div><\/p>\n<pre># netsat -a --numeric-ports<br># netsat -a --numeric-hosts<br># netsat -a --numeric-users<\/pre>\n<p><\/div>\n<p><\/div>\n<p><\/div>\n<p><\/p>\n<h4><\/h4>\n<p><\/p>\n<h2><strong>6. \u6301\u7eed\u8f93\u51fa netstat \u4fe1\u606f<\/strong><\/h2>\n<p>netstat \u5c06\u6bcf\u9694\u4e00\u79d2\u8f93\u51fa\u7f51\u7edc\u4fe1\u606f\u3002<\/p>\n<div><\/p>\n<div><\/p>\n<div><\/p>\n<div><a title=\"\u590d\u5236\u4ee3\u7801\"><img decoding=\"async\" src=\"http:\/\/common.cnblogs.com\/images\/copycode.gif\" alt=\"\u590d\u5236\u4ee3\u7801\" \/><\/a><\/div>\n<p><\/p>\n<pre># netstat -c<br> Active Internet connections (w\/o servers)<br> Proto Recv-Q Send-Q Local Address           Foreign Address         State<br> tcp        0      0 ramesh-laptop.loc:36130 101-101-181-225.ama:www ESTABLISHED<br> tcp        1      1 ramesh-laptop.loc:52564 101.11.169.230:www      CLOSING<br> tcp        0      0 ramesh-laptop.loc:43758 server-101-101-43-2:www ESTABLISHED<br> tcp        1      1 ramesh-laptop.loc:42367 101.101.34.101:www      CLOSING<br> ^C<\/pre>\n<p><\/p>\n<div><a title=\"\u590d\u5236\u4ee3\u7801\"><img decoding=\"async\" src=\"http:\/\/common.cnblogs.com\/images\/copycode.gif\" alt=\"\u590d\u5236\u4ee3\u7801\" \/><\/a><\/div>\n<p><\/div>\n<p><\/div>\n<p><\/div>\n<p><\/p>\n<h4><\/h4>\n<p><\/p>\n<h2><strong>7. \u663e\u793a\u7cfb\u7edf\u4e0d\u652f\u6301\u7684\u5730\u5740\u65cf (Address Families)<\/strong><\/h2>\n<p><\/p>\n<div><\/p>\n<div><\/p>\n<div><\/p>\n<pre>netstat --verbose<\/pre>\n<p><\/div>\n<p><\/div>\n<p><\/div>\n<p>\u5728\u8f93\u51fa\u7684\u672b\u5c3e\uff0c\u4f1a\u6709\u5982\u4e0b\u7684\u4fe1\u606f<\/p>\n<div><\/p>\n<div><\/p>\n<div><\/p>\n<pre>netstat: no support for `AF IPX' on this system.<br>netstat: no support for `AF AX25' on this system.<br>netstat: no support for `AF X25' on this system.<br>netstat: no support for `AF NETROM' on this system.<\/pre>\n<p><\/div>\n<p><\/div>\n<p><\/div>\n<p><\/p>\n<h4><\/h4>\n<p><\/p>\n<h2><strong>8. \u663e\u793a\u6838\u5fc3\u8def\u7531\u4fe1\u606f netstat -r<\/strong><\/h2>\n<p><\/p>\n<div><\/p>\n<div><\/p>\n<div><\/p>\n<pre># netstat -r<br> Kernel IP routing table<br> Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface<br> 192.168.1.0     *               255.255.255.0   U         0 0          0 eth2<br> link-local      *               255.255.0.0     U         0 0          0 eth2<br> default         192.168.1.1     0.0.0.0         UG        0 0          0 eth2<\/pre>\n<p><\/div>\n<p><\/div>\n<p><\/div>\n<p><strong>\u6ce8\u610f\uff1a<\/strong>\u00a0\u4f7f\u7528 netstat -rn \u663e\u793a\u6570\u5b57\u683c\u5f0f\uff0c\u4e0d\u67e5\u8be2\u4e3b\u673a\u540d\u79f0\u3002<\/p>\n<h4><\/h4>\n<p><\/p>\n<h2><strong>9. \u627e\u51fa\u7a0b\u5e8f\u8fd0\u884c\u7684\u7aef\u53e3<\/strong><\/h2>\n<p>\u5e76\u4e0d\u662f\u6240\u6709\u7684\u8fdb\u7a0b\u90fd\u80fd\u627e\u5230\uff0c\u6ca1\u6709\u6743\u9650\u7684\u4f1a\u4e0d\u663e\u793a\uff0c\u4f7f\u7528 root \u6743\u9650\u67e5\u770b\u6240\u6709\u7684\u4fe1\u606f\u3002<\/p>\n<div><\/p>\n<div><\/p>\n<div><\/p>\n<pre># netstat -ap | grep ssh<br> tcp        1      0 dev-db:ssh           101.174.100.22:39213        CLOSE_WAIT  -<br> tcp        1      0 dev-db:ssh           101.174.100.22:57643        CLOSE_WAIT  -<\/pre>\n<p><\/div>\n<p><\/div>\n<p><\/div>\n<p><strong>\u00a0 \u627e\u51fa\u8fd0\u884c\u5728\u6307\u5b9a\u7aef\u53e3\u7684\u8fdb\u7a0b<\/strong><\/p>\n<div><\/p>\n<div><\/p>\n<div><\/p>\n<pre># netstat -an | grep ':80'<\/pre>\n<p><\/div>\n<p><\/div>\n<p><\/div>\n<p><\/p>\n<h4><\/h4>\n<p><\/p>\n<h2><strong>10. \u663e\u793a\u7f51\u7edc\u63a5\u53e3\u5217\u8868<\/strong><\/h2>\n<p><\/p>\n<div><\/p>\n<div><\/p>\n<div><\/p>\n<pre># netstat -i<br> Kernel Interface table<br> Iface   MTU Met   RX-OK RX-ERR RX-DRP RX-OVR    TX-OK TX-ERR TX-DRP TX-OVR Flg<br> eth0       1500 0         0      0      0 0             0      0      0      0 BMU<br> eth2       1500 0     26196      0      0 0         26883      6      0      0 BMRU<br> lo        16436 0         4      0      0 0             4      0      0      0 LRU<\/pre>\n<p><\/div>\n<p><\/div>\n<p><\/div>\n<p>\u663e\u793a\u8be6\u7ec6\u4fe1\u606f\uff0c\u50cf\u662f ifconfig \u4f7f\u7528 netstat -ie:<\/p>\n<div><\/p>\n<div><a title=\"\u590d\u5236\u4ee3\u7801\"><img decoding=\"async\" src=\"http:\/\/common.cnblogs.com\/images\/copycode.gif\" alt=\"\u590d\u5236\u4ee3\u7801\" \/><\/a><\/div>\n<p><\/p>\n<pre># netstat -ie<br> Kernel Interface table<br> eth0      Link encap:Ethernet  HWaddr 00:10:40:11:11:11<br> UP BROADCAST MULTICAST  MTU:1500  Metric:1<br> RX packets:0 errors:0 dropped:0 overruns:0 frame:0<br> TX packets:0 errors:0 dropped:0 overruns:0 carrier:0<br> collisions:0 txqueuelen:1000<br> RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)<br> Memory:f6ae0000-f6b00000<\/pre>\n<p><\/p>\n<div><a title=\"\u590d\u5236\u4ee3\u7801\"><img decoding=\"async\" src=\"http:\/\/common.cnblogs.com\/images\/copycode.gif\" alt=\"\u590d\u5236\u4ee3\u7801\" \/><\/a><\/div>\n<p><\/div>\n<p><\/p>\n<h2><strong>\u00a0<\/strong><\/h2>\n<p><\/p>\n<h2><strong>11. IP\u548cTCP\u5206\u6790<\/strong><\/h2>\n<p><strong>\u00a0 \u67e5\u770b\u8fde\u63a5\u67d0\u670d\u52a1\u7aef\u53e3\u6700\u591a\u7684\u7684IP\u5730\u5740<\/strong><\/p>\n<div><\/p>\n<div><a title=\"\u590d\u5236\u4ee3\u7801\"><img decoding=\"async\" src=\"http:\/\/common.cnblogs.com\/images\/copycode.gif\" alt=\"\u590d\u5236\u4ee3\u7801\" \/><\/a><\/div>\n<p><\/p>\n<pre>wss8848@ubuntu:~$ netstat -nat | grep \"192.168.1.15:22\" |awk '{print $5}'|awk -F: '{print $1}'|sort|uniq -c|sort -nr|head -20<br>18 221.136.168.36<br>3 154.74.45.242<br>2 78.173.31.236<br>2 62.183.207.98<br>2 192.168.1.14<br>2 182.48.111.215<br>2 124.193.219.34<br>2 119.145.41.2<br>2 114.255.41.30<br>1 75.102.11.99<\/pre>\n<p><\/p>\n<div><a title=\"\u590d\u5236\u4ee3\u7801\"><img decoding=\"async\" src=\"http:\/\/common.cnblogs.com\/images\/copycode.gif\" alt=\"\u590d\u5236\u4ee3\u7801\" \/><\/a><\/div>\n<p><\/div>\n<p><strong>\u00a0 TCP\u5404\u79cd\u72b6\u6001\u5217\u8868<\/strong><\/p>\n<div><\/p>\n<div><a title=\"\u590d\u5236\u4ee3\u7801\"><img decoding=\"async\" src=\"http:\/\/common.cnblogs.com\/images\/copycode.gif\" alt=\"\u590d\u5236\u4ee3\u7801\" \/><\/a><\/div>\n<p><\/p>\n<pre>wss8848@ubuntu:~$ netstat -nat |awk '{print $6}'<br>established)<br>Foreign<br>LISTEN<br>TIME_WAIT<br>ESTABLISHED<br>TIME_WAIT<br>SYN_SENT<\/pre>\n<p><\/p>\n<div><a title=\"\u590d\u5236\u4ee3\u7801\"><img decoding=\"async\" src=\"http:\/\/common.cnblogs.com\/images\/copycode.gif\" alt=\"\u590d\u5236\u4ee3\u7801\" \/><\/a><\/div>\n<p><\/div>\n<p><\/p>\n<pre>  \u5148\u628a\u72b6\u6001\u5168\u90fd\u53d6\u51fa\u6765,\u7136\u540e\u4f7f\u7528uniq -c\u7edf\u8ba1\uff0c\u4e4b\u540e\u518d\u8fdb\u884c\u6392\u5e8f\u3002<\/pre>\n<p><\/p>\n<div><\/p>\n<div><a title=\"\u590d\u5236\u4ee3\u7801\"><img decoding=\"async\" src=\"http:\/\/common.cnblogs.com\/images\/copycode.gif\" alt=\"\u590d\u5236\u4ee3\u7801\" \/><\/a><\/div>\n<p><\/p>\n<pre>wss8848@ubuntu:~$ netstat -nat |awk '{print $6}'|sort|uniq -c<br>143 ESTABLISHED<br>1 FIN_WAIT1<br>1 Foreign<br>1 LAST_ACK<br>36 LISTEN<br>6 SYN_SENT<br>113 TIME_WAIT<br>1 established)<\/pre>\n<p><\/p>\n<div><a title=\"\u590d\u5236\u4ee3\u7801\"><img decoding=\"async\" src=\"http:\/\/common.cnblogs.com\/images\/copycode.gif\" alt=\"\u590d\u5236\u4ee3\u7801\" \/><\/a><\/div>\n<p><\/div>\n<p><\/p>\n<pre>  \u6700\u540e\u7684\u547d\u4ee4\u5982\u4e0b:<\/pre>\n<p><\/p>\n<div><\/p>\n<pre>netstat -nat |awk '{print $6}'|sort|uniq -c|sort -rn<\/pre>\n<p><\/div>\n<p><\/p>\n<pre><strong>\u5206\u6790access.log\u83b7\u5f97\u8bbf\u95ee\u524d10\u4f4d\u7684ip\u5730\u5740<\/strong><\/pre>\n<p><\/p>\n<div><\/p>\n<pre>awk '{print $1}' access.log |sort|uniq -c|sort -nr|head -10<\/pre>\n<p><\/div>\n<p> \u6765\u6e90\uff1ahttp:\/\/www.cnblogs.com\/ggjucheng\/archive\/2012\/01\/08\/2316661.html<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u7b80\u4ecb Netstat \u547d\u4ee4\u7528\u4e8e\u663e\u793a\u5404\u79cd\u7f51\u7edc\u76f8\u5173\u4fe1\u606f\uff0c\u5982\u7f51\u7edc\u8fde\u63a5\uff0c\u8def\u7531\u8868\uff0c\u63a5\u53e3\u72b6\u6001 (Interface Sta [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[27],"class_list":["post-113","post","type-post","status-publish","format-standard","hentry","category-windows","tag-windows"],"_links":{"self":[{"href":"https:\/\/www.huzs.top\/index.php?rest_route=\/wp\/v2\/posts\/113","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.huzs.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.huzs.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.huzs.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.huzs.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=113"}],"version-history":[{"count":2,"href":"https:\/\/www.huzs.top\/index.php?rest_route=\/wp\/v2\/posts\/113\/revisions"}],"predecessor-version":[{"id":1189,"href":"https:\/\/www.huzs.top\/index.php?rest_route=\/wp\/v2\/posts\/113\/revisions\/1189"}],"wp:attachment":[{"href":"https:\/\/www.huzs.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=113"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.huzs.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=113"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.huzs.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=113"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}