{"id":90462,"date":"2024-03-06T17:46:12","date_gmt":"2024-03-06T09:46:12","guid":{"rendered":"http:\/\/gulass.cn\/?p=90462"},"modified":"2024-03-06T17:46:12","modified_gmt":"2024-03-06T09:46:12","slug":"linux-netstat","status":"publish","type":"post","link":"https:\/\/gulass.cn\/linux-netstat.html","title":{"rendered":"Linux\u4e0b netstat\u7684\u4f7f\u7528"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\nnetstat \u662f\u4e00\u4e2a\u544a\u8bc9\u6211\u4eec\u7cfb\u7edf\u4e2d\u6240\u6709 tcp\/udp\/unix socket \u8fde\u63a5\u72b6\u6001\u7684\u547d\u4ee4\u884c\u5de5\u5177\u3002\u5b83\u4f1a\u5217\u51fa\u6240\u6709\u5df2\u7ecf\u8fde\u63a5\u6216\u8005\u7b49\u5f85\u8fde\u63a5\u72b6\u6001\u7684\u8fde\u63a5\u3002 \u8be5\u5de5\u5177\u5728\u8bc6\u522b\u67d0\u4e2a\u5e94\u7528\u76d1\u542c\u54ea\u4e2a\u7aef\u53e3\u65f6\u7279\u522b\u6709\u7528\uff0c\u6211\u4eec\u4e5f\u80fd\u7528\u5b83\u6765\u5224\u65ad\u67d0\u4e2a\u5e94\u7528\u662f\u5426\u6b63\u5e38\u7684\u5728\u76d1\u542c\u67d0\u4e2a\u7aef\u53e3\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

\"\"<\/p>\n

netstat \u547d\u4ee4\u8fd8\u80fd\u663e\u793a\u5176\u5b83\u5404\u79cd\u5404\u6837\u7684\u7f51\u7edc\u76f8\u5173\u4fe1\u606f\uff0c\u4f8b\u5982\u8def\u7531\u8868\uff0c \u7f51\u5361\u7edf\u8ba1\u4fe1\u606f\uff0c \u865a\u5047\u8fde\u63a5\u4ee5\u53ca\u591a\u64ad\u6210\u5458\u7b49\u3002<\/p>\n

\u672c\u6587\u4e2d\uff0c\u6211\u4eec\u4f1a\u901a\u8fc7\u51e0\u4e2a\u4f8b\u5b50\u6765\u5b66\u4e60 netstat\u3002<\/p>\n

1 - \u68c0\u67e5\u6240\u6709\u7684\u8fde\u63a5<\/strong><\/div>\n

\u4f7f\u7528a \u9009\u9879\u53ef\u4ee5\u5217\u51fa\u7cfb\u7edf\u4e2d\u7684\u6240\u6709\u8fde\u63a5\uff0c
\n$ netstat -a<\/code><\/p>\n

\u8fd9\u4f1a\u663e\u793a\u7cfb\u7edf\u6240\u6709\u7684 tcp\u3001udp \u4ee5\u53ca unix \u8fde\u63a5\u3002<\/p>\n

2 - \u68c0\u67e5\u6240\u6709\u7684 tcp\/udp\/unix socket \u8fde\u63a5<\/strong><\/div>\n

\u4f7f\u7528 t\u9009\u9879\u53ea\u5217\u51fa tcp\u00a0\u8fde\u63a5\uff0c
\n$ netstat -at<\/code><\/p>\n

\u7c7b\u4f3c\u7684\uff0c\u4f7f\u7528u \u9009\u9879\u53ea\u5217\u51faudp \u00a0\u8fde\u63a5\uff0c
\n$ netstat -au<\/code><\/p>\n

\u4f7f\u7528 x\u00a0\u9009\u9879\u53ea\u5217\u51fa Unix socket \u8fde\u63a5\uff0c
\n$ netstat -ax<\/code><\/p>\n

3 - \u540c\u65f6\u5217\u51fa\u8fdb\u7a0b ID\/\u8fdb\u7a0b\u540d\u79f0<\/strong><\/div>\n

\u4f7f\u7528 p\u9009\u9879\u53ef\u4ee5\u5728\u5217\u51fa\u8fde\u63a5\u7684\u540c\u65f6\u4e5f\u663e\u793a PID \u6216\u8005\u8fdb\u7a0b\u540d\u79f0\uff0c\u800c\u4e14\u5b83\u8fd8\u80fd\u4e0e\u5176\u4ed6\u9009\u9879\u8fde\u7528\uff0c
\n$ netstat -ap<\/code><\/p>\n

4 - \u5217\u51fa\u7aef\u53e3\u53f7\u800c\u4e0d\u662f\u670d\u52a1\u540d<\/strong><\/div>\n

\u4f7f\u7528 n \u9009\u9879\u53ef\u4ee5\u52a0\u5feb\u8f93\u51fa\uff0c\u5b83\u4e0d\u4f1a\u6267\u884c\u4efb\u4f55\u53cd\u5411\u67e5\u8be2\uff08LCTT \u8bd1\u6ce8\uff1a\u8fd9\u91cc\u539f\u6587\u6709\u8bef\uff09\uff0c\u800c\u662f\u76f4\u63a5\u8f93\u51fa\u6570\u5b57\u3002 \u7531\u4e8e\u65e0\u9700\u67e5\u8be2\uff0c\u56e0\u6b64\u7ed3\u679c\u8f93\u51fa\u4f1a\u5feb\u5f88\u591a\u3002
\n$ netstat -an<\/code><\/p>\n

5 - \u53ea\u8f93\u51fa\u76d1\u542c\u7aef\u53e3<\/strong><\/div>\n

\u4f7f\u7528l \u9009\u9879\u53ea\u8f93\u51fa\u76d1\u542c\u7aef\u53e3\u3002\u5b83\u4e0d\u80fd\u4e0e a\u00a0\u9009\u9879\u8fde\u7528\uff0c\u56e0\u4e3a a\u00a0\u4f1a\u8f93\u51fa\u6240\u6709\u7aef\u53e3\uff0c
\n$ netstat -l<\/code><\/p>\n

6 - \u8f93\u51fa\u7f51\u7edc\u72b6\u6001<\/strong><\/div>\n

\u4f7f\u7528 s\u00a0\u9009\u9879\u8f93\u51fa\u6bcf\u4e2a\u534f\u8bae\u7684\u7edf\u8ba1\u4fe1\u606f\uff0c\u5305\u62ec\u63a5\u6536\/\u53d1\u9001\u7684\u5305\u6570\u91cf\uff0c
\n$ netstat -s<\/code><\/p>\n

7 - \u8f93\u51fa\u7f51\u5361\u72b6\u6001<\/strong><\/div>\n

\u4f7f\u7528 I\u00a0\u9009\u9879\u53ea\u663e\u793a\u7f51\u5361\u7684\u7edf\u8ba1\u4fe1\u606f\uff0c
\n$ netstat -i<\/code><\/p>\n

8 - \u663e\u793a\u591a\u64ad\u7ec4multicast group<\/rt><\/ruby>\u4fe1\u606f<\/strong><\/div>\n

\u4f7f\u7528g \u9009\u9879\u8f93\u51fa \u00a0IPV4\u4ee5\u53caIPV6 \u00a0\u7684\u591a\u64ad\u7ec4\u4fe1\u606f\uff0c
\n$ netstat -g<\/code><\/p>\n

9 - \u663e\u793a\u7f51\u7edc\u8def\u7531\u4fe1\u606f<\/strong><\/div>\n

\u4f7f\u7528 r\u00a0\u8f93\u51fa\u7f51\u7edc\u8def\u7531\u4fe1\u606f\uff0c
\n$ netstat -r<\/code><\/p>\n

10 - \u6301\u7eed\u8f93\u51fa<\/strong><\/div>\n

\u4f7f\u7528 c\u00a0\u9009\u9879\u6301\u7eed\u8f93\u51fa\u7ed3\u679c
\n$ netstat -c<\/code><\/p>\n

11 - \u8fc7\u6ee4\u51fa\u67d0\u4e2a\u7aef\u53e3<\/strong><\/div>\n

\u4e0egrep \u00a0\u8fde\u7528\u6765\u8fc7\u6ee4\u51fa\u67d0\u4e2a\u7aef\u53e3\u7684\u8fde\u63a5\uff0c
\n$ netstat -anp | grep 3306<\/code><\/p>\n

12 - \u7edf\u8ba1\u8fde\u63a5\u4e2a\u6570<\/strong><\/div>\n

\u901a\u8fc7\u4e0ewc \u548c grep\u00a0\u547d\u4ee4\u8fde\u7528\uff0c\u53ef\u4ee5\u7edf\u8ba1\u6307\u5b9a\u7aef\u53e3\u7684\u8fde\u63a5\u6570\u91cf
\n$ netstat -anp | grep 3306 | wc -l<\/code><\/p>\n

\u8fd9\u4f1a\u8f93\u51fa mysql \u670d\u52a1\u7aef\u53e3\uff08\u5373 3306\uff09\u7684\u8fde\u63a5\u6570\u3002<\/p>\n

\u8fd9\u5c31\u662f\u6211\u4eec\u7b80\u77ed\u7684\u6848\u4f8b\u6307\u5357\u4e86\uff0c\u5e0c\u671b\u5b83\u5e26\u7ed9\u4f60\u7684\u4fe1\u606f\u91cf\u8db3\u591f\u3002 \u6709\u4efb\u4f55\u7591\u95ee\u6b22\u8fce\u63d0\u51fa\u3002<\/p>\n


\n

via: http:\/\/linuxtechlab.com\/learn-use-netstat-with-examples\/<\/a><\/p>\n

\u4f5c\u8005\uff1aShusain<\/a> \u8bd1\u8005\uff1alujun9972<\/a> \u6821\u5bf9\uff1awxy<\/a><\/p>\n

\u672c\u6587\u7531 LCTT<\/a> \u539f\u521b\u7f16\u8bd1\uff0cLinux\u4e2d\u56fd<\/a> \u8363\u8a89\u63a8\u51fa<\/p>\n

\n

\u539f\u6587\u6765\u81ea\uff1ahttps:\/\/linux.cn\/article-9128-1.html<\/a><\/p>\n

\u672c\u6587\u5730\u5740\uff1ahttp:\/\/gulass.cn\/linux-netstat.html<\/a>\u7f16\u8f91\uff1a\u4efb\u7ef4\u56fd\uff0c\u5ba1\u6838\u5458\uff1a\u9004\u589e\u5b9d<\/span><\/p>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"

\u5bfc\u8bfb netstat \u662f\u4e00\u4e2a\u544a\u8bc9\u6211\u4eec\u7cfb\u7edf\u4e2d\u6240\u6709 tcp\/udp\/unix socket \u8fde\u63a5\u72b6\u6001\u7684\u547d\u4ee4\u884c\u5de5\u5177\u3002 […]<\/p>\n","protected":false},"author":63,"featured_media":89784,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-90462","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/90462","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/users\/63"}],"replies":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/comments?post=90462"}],"version-history":[{"count":7,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/90462\/revisions"}],"predecessor-version":[{"id":90491,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/90462\/revisions\/90491"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/media\/89784"}],"wp:attachment":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/media?parent=90462"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/categories?post=90462"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/tags?post=90462"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}