{"id":728,"date":"2019-04-25T11:40:06","date_gmt":"2019-04-25T03:40:06","guid":{"rendered":"https:\/\/www.linuxcool.com\/?p=728"},"modified":"2022-05-06T17:27:57","modified_gmt":"2022-05-06T09:27:57","slug":"netstat","status":"publish","type":"post","link":"https:\/\/www.linuxcool.com\/netstat","title":{"rendered":"netstat\u547d\u4ee4 – \u663e\u793a\u7f51\u7edc\u72b6\u6001"},"content":{"rendered":"\n

netstat\u547d\u4ee4\u6765\u81ea\u4e8e\u82f1\u6587\u8bcd\u7ec4\u201dnetwork statistics\u201c\u7684\u7f29\u5199\uff0c\u5176\u529f\u80fd\u662f\u7528\u4e8e\u663e\u793a\u5404\u79cd\u7f51\u7edc\u76f8\u5173\u4fe1\u606f\uff0c\u4f8b\u5982\u7f51\u7edc\u8fde\u63a5\u72b6\u6001\u3001\u8def\u7531\u8868\u4fe1\u606f\u3001\u63a5\u53e3\u72b6\u6001\u3001NAT\u3001\u591a\u64ad\u6210\u5458\u7b49\u7b49\u3002<\/p>\n\n\n\n

netstat\u547d\u4ee4\u4e0d\u4ec5\u5e94\u7528\u4e8eLinux\u7cfb\u7edf\uff0c\u800c\u4e14\u5728Windows XP\u3001Windows 7\u3001Windows 10\u53caWindows 11\u4e2d\u5747\u5df2\u9ed8\u8ba4\u652f\u6301\uff0c\u5e76\u4e14\u53ef\u7528\u53c2\u6570\u4e5f\u76f8\u540c\uff0c\u6709\u7ecf\u9a8c\u7684\u8fd0\u7ef4\u4eba\u5458\u53ef\u4ee5\u76f4\u63a5\u4e0a\u624b\u3002<\/p>\n\n\n\n

\u8bed\u6cd5\u683c\u5f0f\uff1a<\/strong>netstat [\u53c2\u6570]<\/p>\n\n\n\n

\u5e38\u7528\u53c2\u6570\uff1a<\/strong><\/p>\n\n\n\n

-a<\/td>\u663e\u793a\u6240\u6709\u8fde\u7ebf\u4e2d\u7684Socket <\/td><\/tr>
-p<\/td>\u663e\u793a\u6b63\u5728\u4f7f\u7528Socket\u7684\u7a0b\u5e8f\u8bc6\u522b\u7801\u548c\u7a0b\u5e8f\u540d\u79f0 <\/td><\/tr>
-l<\/td>\u4ec5\u5217\u51fa\u5728\u76d1\u542c\u7684\u670d\u52a1\u72b6\u6001<\/td><\/tr>
-t<\/td>\u663e\u793aTCP\u4f20\u8f93\u534f\u8bae\u7684\u8fde\u7ebf\u72b6\u51b5 <\/td><\/tr>
-u<\/td>\u663e\u793aUDP\u4f20\u8f93\u534f\u8bae\u7684\u8fde\u7ebf\u72b6\u51b5 <\/td><\/tr>
-i
<\/td>
\u663e\u793a\u7f51\u7edc\u754c\u9762\u4fe1\u606f\u8868\u5355 <\/td><\/tr>
-r<\/td>\u663e\u793a\u8def\u7531\u8868\u4fe1\u606f<\/td><\/tr>
-n<\/td>\u76f4\u63a5\u4f7f\u7528IP\u5730\u5740\uff0c\u4e0d\u901a\u8fc7\u57df\u540d\u670d\u52a1\u5668 <\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n

\u53c2\u8003\u5b9e\u4f8b<\/strong><\/p>\n\n\n\n

\u663e\u793a\u7cfb\u7edf\u7f51\u7edc\u72b6\u6001\u4e2d\u7684\u6240\u6709\u8fde\u63a5\u4fe1\u606f\uff1a<\/p>\n\n\n\n

[root@linuxcool ~]# netstat -a<\/strong>\nActive Internet connections (servers and established)\nProto Recv-Q Send-Q Local Address           Foreign Address         State      \ntcp        0      0 0.0.0.0:http            0.0.0.0:*               LISTEN     \ntcp        0      0 0.0.0.0:https           0.0.0.0:*               LISTEN     \ntcp        0      0 0.0.0.0:ms-wbt-server   0.0.0.0:*               LISTEN     \n<\/pre>\n\n\n\n

\u663e\u793a\u7cfb\u7edf\u7f51\u7edc\u72b6\u6001\u4e2d\u7684UDP\u8fde\u63a5\u4fe1\u606f\uff1a<\/p>\n\n\n\n

[root@linuxcool ~]# netstat -nu<\/strong>\nActive Internet connections (w\/o servers)\nProto Recv-Q Send-Q Local Address           Foreign Address         State      \nudp        0      0 172.19.226.238:68       172.19.239.253:67       ESTABLISHED<\/pre>\n\n\n\n

\u663e\u793a\u7cfb\u7edf\u7f51\u7edc\u72b6\u6001\u4e2d\u7684UDP\u8fde\u63a5\u7aef\u53e3\u53f7\u4f7f\u7528\u4fe1\u606f\uff1a<\/p>\n\n\n\n

[root@linuxcool ~]# netstat -apu <\/strong>\nActive Internet connections (servers and established)\nProto Recv-Q Send-Q Local Address    Foreign Address       State    PID\/Program name    \nudp        0      0 linuxcool:bootpc _gateway:bootps  ESTABLISHED   1024\/NetworkManager \nudp        0      0 localhost:323           0.0.0.0:*               875\/chronyd         \nudp6       0      0 localhost:323           [::]:*                  875\/chronyd <\/pre>\n\n\n\n

\u663e\u793a\u7f51\u5361\u5f53\u524d\u72b6\u6001\u4fe1\u606f\uff1a<\/p>\n\n\n\n

[root@linuxcool~]# netstat -i<\/strong> \nKernel Interface table\nIface             MTU    RX-OK RX-ERR RX-DRP RX-OVR    TX-OK TX-ERR TX-DRP TX-OVR Flg\neth0             1500    31945      0      0 0         39499      0      0      0 BMRU\nlo              65536        0      0      0 0             0      0      0      0 LRU\n<\/pre>\n\n\n\n

\u663e\u793a\u7f51\u7edc\u8def\u7531\u8868\u72b6\u6001\u4fe1\u606f\uff1a<\/p>\n\n\n\n

[root@linuxcool ~]# netstat -r<\/strong>\nKernel IP routing table\nDestination     Gateway         Genmask         Flags   MSS Window  irtt Iface\ndefault         _gateway        0.0.0.0         UG        0 0          0 eth0\n172.19.224.0    0.0.0.0         255.255.240.0   U         0 0          0 eth0<\/pre>\n\n\n\n

\u627e\u5230\u67d0\u4e2a\u670d\u52a1\u6240\u5bf9\u5e94\u7684\u8fde\u63a5\u4fe1\u606f\uff1a<\/p>\n\n\n\n

[root@linuxcool ~]# netstat -ap | grep ssh<\/strong>\nunix  2      [ ]         STREAM     CONNECTED     89121805 203890\/sshd: root [  \nunix  3      [ ]         STREAM     CONNECTED     27396    1754\/sshd            \nunix  3      [ ]         STREAM     CONNECTED     89120965 203890\/sshd: root [  \nunix  2      [ ]         STREAM     CONNECTED     89116510 203903\/sshd: root@p  \nunix  2      [ ]         STREAM     CONNECTED     89121803 203890\/sshd: root [  \nunix  2      [ ]         STREAM     CONNECTED     29959    1754\/sshd            \nunix  2      [ ]         DGRAM                    89111175 203890\/sshd: root [  \nunix  3      [ ]         STREAM     CONNECTED     89120964 203903\/sshd: root@p  \n<\/pre>\n","protected":false},"excerpt":{"rendered":"

netstat\u547d\u4ee4\u6765\u81ea\u4e8e\u82f1\u6587\u8bcd\u7ec4\u201dnetwork statistics\u201c\u7684\u7f29\u5199\uff0c\u5176\u529f\u80fd\u662f\u7528\u4e8e\u663e\u793a\u5404\u79cd\u7f51\u7edc\u76f8\u5173\u4fe1 […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[6],"tags":[],"_links":{"self":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts\/728"}],"collection":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/comments?post=728"}],"version-history":[{"count":17,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts\/728\/revisions"}],"predecessor-version":[{"id":9320,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts\/728\/revisions\/9320"}],"wp:attachment":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/media?parent=728"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/categories?post=728"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/tags?post=728"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}